Write a program in assembly language to swap two numbers – IGNOU MCA Assignment 2017 – 18

By | December 6, 2017

MASTER OF COMPUTER APPLICATIONS

Course Code : MCSL-017
Course Title : C and Assembly Language Programming (Lab Course)
Assignment Number : MCA(1)/L-017/Assignment/17-18
Maximum Marks : 50
Weightage : 25%

Write a program in assembly language to swap two numbers – IGNOU MCA Assignment 2017 – 18

Code:-

DATA SEGMENT
NUM1 DB 9H
NUM2 DB 7H
ENDS

CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX

MOV AL,NUM1
MOV BL,NUM2

XCHG AL,NUM2
XCHG BL,NUM1

MOV AH,4CH
INT 21H
ENDS
END START

DATA SEGMENT
NUM1 DB 9H
NUM2 DB 7H
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV AL,NUM1
MOV BL,NUM2
XCHG AL,NUM2
XCHG BL,NUM1
MOV AH,4CH
INT 21H
ENDS
END START

 

Screen Shots :-

Asm_program_XCHG_Two_Numbers

Before Execution :-

Asm_program_XCHG_Two_Numbers_Variables

After Execution :-

Asm_program_XCHG_Two_Numbers_Variables2

Note :- To see the variable and its value you have to click vars button in the emulator.