Analyse and Identify the addressing mode in the following instructions: MOV A, B MVI, 05H LHLD, 3000H XCHG CMP B

Analyse and Identify the addressing mode in the following instructions:

MOV A, B          
MVI, 05H
LHLD, 3000H   
XCHG
CMP B

Answer:

MOV A,B -> It uses register address mode. This instruction will transfer the content from B into A. It occupies only 1 Byte in memory. 

For Example, if B=08H, 

Then, MOV A,B 

A=08H


MVI,05H -> It uses immediate addressing mode. This instruction will immediate move the content into the register. It occupies 2 bytes in memory.

For Example, if MVI A,05H,

Then, A=05H


LHLD,3000H -> It uses direct addressing mode. This instruction will move the content from the memory into HL pair. It occupies 3 bytes in memory.

For Example, 3000H have data 05H and 3001H have data 88H.

Then, After LHLD, 3000H

Content of 3000H location (i.e. 05H) is copied L register and Content of 3001H location (i.e. 88H) is copied into H register.


XCHG -> It uses implied addressing mode. This instruction will exchange the content of HL pair with DE pair. It occupies 1 byte in the memory.

For Example, H=01H , L=02H and D=03H, E=04H.

After XCHG,

H=03H,L=04H and D=01H, E=02H


CMP B -> It uses register addressing mode. This instruction use to compare the content of accumulator with register B. It occupies 1 byte in memory. It uses subtraction method and then set flags CY and Z.

For Example,

if A< Reg ( CY=1 & Z=0 ),

A=Reg ( CY=0 & Z=1 ),

A>Reg ( CY=0 & Z=0 )

Let A=08H and B=09H

Then, CMP B

It will set CY=1 and Z=0

Comments