You are on page 1of 5

1. Discuss MOV and XCHG instruction with their differences and restrictions?

[IST ,6d][2014,6d]

Difference between MOV and XCHG :

1. MOV: The MOV instruction copies a word or byte of data from a specified source to a specified
destination.
XCHG: The XCHG instruction exchanges the content of a register with the content of another
register or with the content of memory location(s).
2. MOV: The destination can be a register or a memory location. The source can be a register, a
memory location or an immediate number.
XCHG: It cannot directly exchange the content of two memory locations.
3. MOV : The source and destination cannot both be memory locations. They must both be of the
same type (bytes or words). MOV instruction does not affect any flag.
XCHG: The source and destination must both be of the same type (bytes or words). The segment
registers cannot be used in this instruction. This instruction does not affect any flag.

Restriction:
 For technical reasons, there are a few restrictions on the use of MOV and XCHG.
 In particular that a MOV or XCHG between memory locations is not allowed.
For example,
 ILLEGAL: MOV WORD1,WORD2
but we can get around this restriction by using a register:
 MOV AX,WORD2
 MOV WORD1, AX
2. Describe different types of JUMP instructions with proper examples?
3. Write down the assembly language statements which will perform the following operation:
[2012,4a]
1) Puts the offset address of the variable MSG into DX
2) Initialize the DS
3) Subs tract 0001H from 8000H and store the result in AX

Ans: 1) LEA DX,MSG

2) MOV AX,@DATA
MOV DS,AX ; Initialize DS

3) MOV AX, 8000H; AX=8000H


MOV AX, 0001H; AX=8000H-0001H

4. Write down the assembly language statements which will perform the following operation:
[2013,4a]
1) Read a character and if it’s an uppercase letter ,display it
2) Read characters until a blank is read

Ans: 1) Charles Marut Pdf EXAMPLE 6.6


2) Charles Marut Pdf EXAMPLE 6.10

5. Describe the operation of each of the following instruction and identify their addressing
mode:-
(1) LEA BP , 7986H;
(2) MOV [AL] , 39H;
(3) CMP [DS] , [CX] .

6. Write and assembly language program to display the string :


“ NATIONAL UNIVERSITY ” twenty times on the screen each with a new line.[2010,4c]

ANS:
.MODEL SMALL
.STACK 100H
.DATA

M1 DB 'NATIONAL UNIVERSITY',0DH,0AH,'$'
.CODE

MAIN PROC ; 0DH & 0AH taken for new line

MOV AX,@DATA
MOV DS,AX ; initializing text to data register

MOV CX,20 ; for printing 20 times


PRINT_LOOP:

MOV AH,9 ; output function


LEA DX,M1
INT 21H
DEC CX ; execution ending of loop

JNZ PRINT_LOOP

MOV AH,4CH
INT 21H

MAIN ENDP
END MAIN

7. Write a program in assembly language to display a message . [2014 , 7d]


ANS:

.MODEL SMALL

.STACK 100H

.DATA

MSG DB 'HELLO,HOW ARE YOU? $'

.CODE

MAIN PROC

MOV AX,@DATA

MOV DS ,AX

LEA DX,MSG

MOV AH,9

INT 21h

MOV AX,4CH

INT 21H

MAIN ENDP

END MAIN

8. Write an assembly language program to show your university name 10 time on screen.
[2013,7c]

ANS:

.MODEL SMALL
.STACK 100H
.DATA
M1 DB 'Institute of Science, Trade & Technology (ISTT)',0DH,0AH,'$'
.CODE

MAIN PROC ; 0DH & 0AH taken for new line

MOV AX,@DATA
MOV DS,AX ;initializing text to data register

MOV CX,10 ; for printing 10 times


PRINT_LOOP:

MOV AH,9 ; output function


LEA DX,M1
INT 21H
DEC CX ; execution ending of loop

JNZ PRINT_LOOP

MOV AH,4CH
INT 21H

MAIN ENDP
END MAIN

You might also like