8086 instruction Examples-
Addressing modes-
Direct memory address
indirect memory addressing - disp is signed 8bit or 16 bit ,may use operator +/-
Register indirect [SX]
Based Indexed [BP+DI]
Register relative [BX+disp]
Relative based indexed {BX+SI+disp]
Data Transfer: Example of some representative Instructions-
(All Data/Address in HEX)
Operation Content in Reg/Memory Content in Reg/Memory Remarks
BEFORE operation AFTER operation
MOV AL, AB AL=33 AL=AB
MOV SI,1234 SI = FEED SI=1000
MOV word ptr [SI], 123F SI=1000; [1000]=1122 SI=1000; [1000]=123F Content of word memory updates
MOV byte ptr [BX], 12h BX=2345;[2345]=67;[2346]=45 BX=2345;[2345]=4512 Content of byte memory updates
MOV CH,AL CH=67; AL=FF CH=FF; AL=FF
MOV [2000],DL DL=44; [2000]=88; [2001]=99; DL=44; [2000]=44; [2001]=99;
MOV CX,[2000] CX=5544; [2000]=44; [2001]=99; CX=9944; [2000]=44; [2001]=99;
LEA BX, variable-name Address of variable-name DS:0100
BX=100 variable-name is
declared in DS; BX
is loaded with offset address of it.
LEA BX,[100] BX=1234 BX=100 Memory offset is loaded in BX
[similar to LEA BX,variable-name]
LDS SI,[DI] DS=1000;SI=600 DS=4433;SI=2211 Four bytes read from memory to
[1000]=11;[1001]=22; update DS:SI
[1002]=33;[1003]=44;
PUSH AX AX=1234,SS=100;SP=FFFE; AX=1234,SS=100;SP=FFFC; Decrement stack by two bytes, load
[FFFD]=FF;[FFFC]=AA [FFFD]=34;[FFFC]=12 AX contents in stack
PUSH word ptr[200] [200]=BB;[201]=AA;SP=FFFC SS=100;SP=FFFA;[FFFB]=AA; Decrement stack by two bytes, load
SS=100; [FFFA]=BB direct memory contents in stack
PUSH word ptr[SI] SS=100;SP=FFFA; SI=2020; SS=100;SP=FFF8;[FFF9]=1A; Decrement stack by two bytes, load
[2020]=2F;[2021]=1A [FFF8]=2F indirect memory contents in stack
POP SS SP=FFF8;[FFF9]=1A; SP=FFFA; SS=1A2F Stack incremented. Stack Segment
[FFF8]=2F;SS=100 loaded from stack
POP word ptr DS:[BP] SS=1A2F;SP=FFFA;[FFFB]=31; SS=1A2F;SP=FFFC;[FFFD]=131; Stack incremented. Content in
[FFFA]=41;BP=300 [FFFC]=141;BP=300 memory pointed by BP(in Data
[300]=AC;[301]=AD; [300]=41;[301]=31; Segment not Stack Segment)
loaded from stack {segment
override : is used in DS:[BP] }
PUSH DX SS=1A2F;SP=FFFC;[FFFD]=131; SS=1A2F;SP=FFFA;[FFFB]=08;
[FFFC]=141;DX=0800 [FFFA]=00;DX=0800
Flag=0001 Flag=0001
POPF SS=1A2F;SP=FFFA;[FFFB]=08; SS=1A2F;SP=FFFC;[FFFD]=131; Stack incremented. Contents of flag
[FFFA]=00;Flag=0001 [FFFC]=141; updated from stack
Flag=0800
IN AL,40 AL=55 , port 40 has data FC AL=FC Read a byte from port 40
OUT DX,AL AL=FC, DX=45 Port 45 gets data FC Write a byte to indirect port
number 45
OUT DX,AX AL=11FC, DX=A45 Port A45 gets data 11FC Write a word to indirect port
number A45
Arithmetic Operations-
Operation Content in Reg/Memory Content in Reg/Memory Remarks
BEFORE operation AFTER operation
ADD [SI],AL SI=200;[200]=44 SI=200;AL=88; Byte memory updates and Parity
AL=88; Flag=0080 [200]=CC;flag=0084 flag set (even numbers of ‘1’)
CMP BX,[BX] BX=200,[200]=11; BX=200,[200]=11; AC and CF sets
[201]=22;Flag=0084 [201]=22;Flag=0089
CMP [BX],BX BX=200,[200]=11; BX=200,[200]=11; Only PF=1
[201]=22;Flag=0089 [201]=22;Flag=0004
DEC byte ptr[BX] BX=300;[300]=01;[301]=04; BX=300;[300]=00;[301]=04; ZF=1,PF=1
Flag=0080 Flag=0044
INC Word ptr[SI] SI=2000;[2000]=FF; SI=2000;[2000]=00; ZF=1,AC=1,PF=1
[2001]=FF;Flag=0044 [2001]=00;Flag=0054 (note CF=0)
DEC byte ptr[BX] BX=300;[300]=00;[301]=04; BX=300;[300]=FF;[301]=04; SF=1,AC=1,PF=1
Flag=0054 Flag=0094
SHL byte ptr[BX],CL BX=300;[300]=44; BX=300;[300]=00;
[301]=01;CL=0A;Flag=0080 [301]=01;CL=0A;Flag=0054
SAR Word ptr[SI],1 SI=200;[200]=22;[203]=33; SI=200;[200]=91;[203]=19;
Flag=0054 Flag=0010
RCR AX,CL AX=4321; CL=2;Flag=0010 AX=90C8; CL=2;Flag=0810 Division(right shift makes number
negative ?)
MUL CL AX=48; CL=AA;Flag=0080 AX=2FD0; CL=AA;Flag=0881 OF and CF=1; product in AX
IMUL word ptr[SI] DX=0;AX=F000;SI=200; DX=0100;AX=0000;SI=200; OF and CF=1; product in DX:AX
[200]=F000;Flag=0881 [200]=F000;Flag=0881 (signed number take 2’comp of
multiplier and multiplicand)
DIV byte ptr[BX] AX=00FF;BX=300; AX=1107;BX=300; Quotient AL=07(Q);Remainder
[300]=22;Flag=0881 [300]=22;Flag=0881 AH=11(R)(decimal 17);
DIV word ptr[BX] DX=4000;AX=2000;BX=300; DX=CFB2;AX=4037;BX=300; Quotient AX=4037(Q);Remainder
[300]=22;[301]=FF;Flag=0881 [300]=22;[301]=FF;Flag=0881 DX=CFB2(R)(decimal 53170)