Chapter6 - Signed Number Arithmetic Operations
Chapter6 - Signed Number Arithmetic Operations
Operations
00000000 ➔ 0
00000001 ➔ +1
00000010 ➔ +2
00000011 ➔ +3
:
01111111 ➔ +127
10000000 ➔ -128
10000001 ➔ -127
:
11111111 ➔ -1
Example: Show -34H as it is represented internally.
34H ➔ 0011 0100
-34H ➔ 1100 1100 ➔ 0CCH
D7 D6 D5 D4 D3 D2 D1 D0
According to the CPU, the result is + 126, which is wrong. The error is
indicted by the fact that OF = I
= -32253 incorrect! OF = 1 CF = 0 SF = 1
MOV DS,AX
MOV CX,9
SUB BX,BX
MOV Sl,OFFSET SIGN_DAT
BACK: MOV AL,[SI]
CBW
ADD BX,AX
INC Sl
LOOP BACK
MOV AL,9
CBW
MOV CX,AX
MOV AX,BX
CWD
IDIV CX
MOV AVERAGE,AX
MOV REMAINDER,DX
The 80x86 Microprocessors 1.14 Assembly Language
SAR (shift arithmetic right)
These prefixes can be used with the CMPS and SCAS instructions for
testing purposes.
REPZ (repeat zero), which is the same as REPE (repeat equal), will
repeat the string operation as long as the source and destination
operands are equal (ZF = 1) or until CX becomes zero.
REPNZ (repeat not zero), which is the same as REPNE (repeat not
equal), will repeat the string operation as long as the source and
destination operands are not equal (ZF = O) or until CX become zero.