Академический Документы
Профессиональный Документы
Культура Документы
8086
DAA
The DAA instruction functions like
AAA
Handles packed BCD (binary code
decimal)
DAA's main purpose is to add strings
of BCD digits (with two digits per
byte).
The Algorithm
The algorithm for daa is
if ( (AL and 0Fh) > 9 or (AuxC = 1)) then
al := al + 6 AuxC := 1
carry.
endif
;Set Auxilliary
Program Example
AL = 53
ADD AL,CL
DAA
C>9)
CL = 29
;AL <- (AL)+(CL)
;AL <- 7C
;AL<- 7C+06(AS
;AL = 82
AL = 73
CL = 29
ADD AL, CL
; AL <- AL+ CL
; AL <- 73+29
; AL<- 9C;
;AL <- 02 CF = 1
DAA
; AL<-02 AND CF = 1
AL = 73 CL = 29
AL + CL = 9C
9 C + 06 = A 2 msb> 9
So A2 + 60 GIVES CF = 1 ; SET CF
AND 02 IN AL or AL<- 02
DAS
The DAS instruction handles DECIMAL
ADJUST BCD values,
algorithm:
if ( (AL and 0Fh) > 9 or (AuxC = 1)) then
al := al -6
AuxC = 1
endif
if ((AL AND F0h )>9or Carry = 1) then
al := al - 60h
Carry := 1 ;Set the Carry flag.
endif
AL = 75
BH = 46
SUB AL, BH
; AL<- 2 F = (AL)-(BH)
;AF = 1
AL = 38 CH = 61
SUB AL, CH
;AL <- D7 CF
=1(BORROW )
DAS
; AL<- 77( as D>9 , D-6 =7)
;CF = 1(borrow)
NEG
Negate Instruction
takes the two's complement of a byte or word.
It takes a single (destination) operation and
negates it.
The syntax for this instruction is
NEG DEST
J := -K
MOV AX, K
NEG AX
MOV J, AX
MUL
Unsigned Multiplication
MUL multiplies an unsigned byte or
word by the contents of AL
The unsigned byte or word in any of
the GPR
Result in AX
All Flags modified
Immediate operand not allowed
If MSB or word is 0 CF and OF set
Unsigned Multiplication
MUL REG
MUL MEM
Examples
MUL BH
;(AX) <- (AL)x(BH)
MUL CX
;(DX)(AX) <-(AX)(CX)
MUL WORD PTR[SI]
;(DX) (AX) <(AX)x([SI])
IMUL
Similar to MUL
OPERANDS ARE SIGNED
PRODUCT IS ALSO SIGNED
SOURCE = GPR, MEMORY OPERAND,
INDEX REGISTER OR BASE REGISTER
NO IMMEDIATE DATA
IF RESULT = 32 BIT HIGEHER ORDER
WORD IS STORED IN DX LOWER
WORD IN AX
CBW, CWD
CONVERT SIGNED BYTE TO WORD
CONVERT SIGNED WORD TO DOUBLE WORD
All these instructions sign-extend a short value
into a longer one, by replicating the top bit of
the original value to fill the extended one.
CBW extends AL into AX by repeating the top
bit of AL in every bit of AH. CWD extends AX
into DX:AX by repeating the top bit of AX
throughout DX. CWDE extends AX into EAX,
and CDQ extends EAX into EDX:EAX.
CONDITIONAL BRANCHING
JZ/JE
JNZ/JNE
JS
JNS
JO
JNO
JP/JPE
JNP
JBE/JNA
JNBE/JA
JL/JNGE
JNL/JGE
JLE/JGC
JNLE/JE
JB/JNAE/JC
JNB/JAE/JNC
JA
JAE
JB
JBE
JC
JE
Above
Above or equal
Bellow
Bellow or equal
Carry
Equality
JG
Greater(s)
JGE
JL
JLE
JNA
Greater of equal(s)
Less(s)
Less equal(s)
Not above
Neither above nor
CF
equal
Not bellow
CF = 0
Neither bellow nor
CF = 0 and ZF = 0
equal
JNAE
JNB
JNBE
CF = 0 and ZF = 0
CF = 0
CF
CF or ZF
CF
ZF
ZF = 0 and SF =
OF
SF = OF
SF OF
ZF or SF OF
CF or ZF
JNC
JNE
JNG
JNGE
JNL
JNLE
JNO
JNP
JNS
JNZ
JO
JP
JPE
JPO
JS
Not carry
Not equal
Not greater
Neither greater
nor equal
Not less
CF = 0
ZF = 0
ZF or SF OF
SF OF
SF = OF
ZF = 0 and SF =
Not less nor equal
OF
Not overflow
OF = 0
Not parity
PF = 0
Not negative
SF = 0
Not zero
ZF = 0
Overflow(s)
OF
Parity
PF
Parity EVEN
PF
Parity ODD
PF = 0
Negative(s)
SF
Short jumps
Displacement is 8 bit only
(signed)jump destination = -128 to
127 bytes displaced from the current
value of IP
NEW IP = CURRENT IP +
OFFSET(8bit)
Eg:
OTHER JUMPS
UNCONDITIONAL
JMP REG16
INDIRECR JUMP
REG16 = AX,BX,CX,DX, ETC
REG16 = DESTIONATION
ADDRESS(OFFSET)
NOT A RELATIVE JUMP
IP = VALUE IN REG16
EG JMP BX, JMP SI
JMP [REG16]
DOUBLE INDIRECT JUMP
REGIG POINTS TO AN ADDRESS WHICH
CONTAINS THE JUMP LOCATION
EG JMP [SI]
JUMP TO THE ADDRESS WHICH IS STORED IN
THE MEMORY LOCATION POINTED BY SI
IF SI = 0987H , THE DEST ADDRS IS TAKEN
FROM THE DATA SEGMENT AT LOCATIONS
0987H AND 0988H. IP IS REPLACED BY THE
VALUE AT THESE ADDRESSES