Professional Documents
Culture Documents
Mnemonic Segment For Memory Access Symbolic Representation Description
Mnemonic Segment For Memory Access Symbolic Representation Description
MOV AX,BX
MOV AH,BL
MOV AX,[1000]
MOV AL,[1002]
MOV [1000],BX
MNEMONIC SEGMENT FOR SYMBOLIC DESCRIPTION
MEMORY ACCESS REPRESENTATION
MOV [1002],BL
MOV [1000],1234
MOV [1002],34
MOV AL,10
MOV AX,1000
MNEMONIC SEGMENT FOR SYMBOLIC DESCRIPTION
MEMORY ACCESS REPRESENTATION
MOV DS,AX
MOV DX,ES
MOV ES,[1000]
MOV [1000],DS
MNEMONIC SEGMENT FOR SYMBOLIC DESCRIPTION
MEMORY ACCESS REPRESENTATION
Contents Memory
(ASCII)
41h At the
MOV BX,1000
offset of MOV AL, EBCDIC CODE(C1H)
C1 h
XLAT
. .
. .
. .
Start of
the table,
BX
Initializing pointers
MOV BX,1000
MEMWDS(this is a label and it can be anyword)
is assumed to point at the word beginning at
location 1000h in the data segment
MOV BX, MEMWDS
BL <= [1000]
BH <=[1001]
LEA BX, MEMWDS
BX<= 1000
MNEMONIC SEGMENT FOR SYMBOLIC REPRESENTATION
MEMORY ACCESS
BX = 8010
DS = E000
AL = [E8010]
MOV AX,5000 H MEMORY CONTENT MEMORY CONTENT
SOURCE DEST
MOV DS,AX
52500 42 62500 98
MOV SI,2500H
MOV AX,6000H 52501 45 62501 34
MOV ES,AX
52502 34 62502 34
MOV DI,2500H
CLD 52503 23 62503 23
MOV CX,0004H
REPNE CMPSB DS:[SI] - ES:[DI] and increment DI
and SI (REPNE)
HLT
(CX=0004h) (DS=5000h)(SI=2500h)(DI=2500h)
(ES=6000h)
• 1st time REPNE CMPSB
DS:[SI] - ES:[DI] i.e. [52500]-[62500] i.e. 42-98(NE)
SI =2501 and DI = 2501
CX=0003h(this is cos of REP prefix)
• 2ND time REP CMPSB
DS:[SI] - ES:[DI] i.e. [52501]-[62501] i.e. 45-34(NE)
SI =2502 and DI = 2502
CX=0002h(this is cos of REP prefix)
• 3rd Time REPNE CMPSB
DS:[SI] - ES:[DI] i.e. [52502]-[62502] i.e. 34-34(E)
SI =2503 and DI = 2503
CX=0001h(this is cos of REP prefix)
• 4TH Time REPNE CMPSB will not happen cos locations are no
longer NE
STOSB AL=>ES:[DI]
After string opr, if DF = 0, then DI is Incremented by 1
and viceversa
STOSW
AX=>ES:[DI]
TO BE SPECIFIC
AL=>ES:[DI]
AH=>ES:[DI+1]
IF DF = 0, then DI is incremented by ??
2
If DF = 1, then DI is decremented by 2
BYTE WISE STRING INSTRUCTION WORD WISE STRING INSTRUCTION
STOSB STOSW
LODSB LODSW
MOVSB MOVSW
SCASB SCASW
CMPSB CMPSW
REP
String instructions can handle at a time one byte or one word, but to
handle large block of data, REP prefix is used with CX as a counter
Types
REP
dec CX by 1 and repeat that string
instruction if CX is non zero. Otherwise control continues sequentially
REPNE/REPNZ
dec CX by 1 and repeat that string instruction if CX is non zero AND if that string inst.
Produced non – zero result. Otherwise control continues sequentially
REPE/REPZ
dec CX by 1 and repeat that string instruction if CX is non zero AND if that string inst.
Produced zero result. Otherwise control continues sequentially
LOOP
It is used to execute series of instructions for a given number of times and that
number of times is stored in CX
Types
LOOP AGAIN
dec CX by 1 and transfer control to the instruction having label AGAIN if CX is non zero.
Otherwise control continues sequentially
LOOPNE/LOOPNZ
dec CX by 1 and transfer control to the instruction having label AGAIN if CX is non zero
AND if previous instruction produced non zero result. Otherwise control continues
sequentially
LOOPE/LOOPZ
dec CX by 1 and transfer control to the instruction having label AGAIN if CX is non zero
AND if previous instruction produced zero result. Otherwise control continues
sequentially
8086 sample programs
When both the numbers are positive
(+03)h x (+02)h = (+06)h
MOV AL,03H
MOV BL,02H
IMUL BL / MUL BL
Result: (+0006)h => AX
8086 sample programs
When both the numbers are not positive
(+03)h x (-02)h = (-06)h
2’s complement of 02
= 1’s complement of 00000010 + 1
=11111110 = FEh
MOV AL,03H
MOV BL,FEH
IMUL BL
Result: (FFFA)h => AX
(FFFA)h is actually –(0006)h
BUT IF MUL BL WAS USED IT WUD GIVE RESULT AS 02FA
8086 sample programs
(+09)h / (-02)h
MOV AX,0009H
MOV BL,FEH
IDIV BL
Result: (01FC)h => AX
01 =>AH is the remainder
FC =>AL is the quotient (-04)h
8086 sample programs
(-09)h / (+02)h
MOV AX,FFF7H
MOV BL,02H
IDIV BL
Result: (FFFC)h => AX
FF =>AH is the remainder (-01)h
FC =>AL is the quotient (-04)h
-1234/0002
1234 = 0001001000110100
1’s complement of 1234 = 1110110111001011
2’s complement of 1234 = 1110110111001100 = EDCC
MOV AX, EDCC
MOV BX,0002 CWD COPIES THE SIGN BIT OF A WORD
IDIV BX (DXAX/BX) IN AX TO ALL THE BITS IN DX
HENCE
MOV AX,EDCC
CWD (DX = FFFF, AX=EDCC)
MOV BX,0002
IDIV BX (DXAX/BX)
1 0 0 0 1 0 D W