Hexadecimal Representation

Decimal / Hexadecimal
8-bit unsigned / Decimal / Hexadecimal
8 – bit two’s compliment
16 / 10H / -1 / 256-1=255 FFH
17 / 11H / -2 / 256-2=254 FEH
18 / 12H / -3 / 256-3=253 FDH
19 / 13H / -4 / 256-4=252 FCH
20 / 14H / -5 / 256-5=251 FBH
21 / 15H / -6 / 256-6=250 FAH
22 / 16H / -7 / 256-7=249 F9H
23 / 17H / -8 / 256-8=248 F8H
24 / 18H / -9 / 256-9=247 F7H
25 / 19H / -10 / 256-10=246 F6H
26 / 1AH / -11 / 256-11=245 F5H
27 / 1BH / -12 / 256-12=244 F4H
28 / 1CH / -13 / 256-13=243 F3H
29 / 1DH / -14 / 256-14=242 F2H
30 / 1EH / -15 / 256-15=241 F1H
31 / 1FH / -16 / 256-16=240 F0H
32 / 20H / -17 / 256-17=239 EFH
50 / 32H / -18 / 256-18=238 EEH
100 / 64H / -19 / 256-19=237 EDH
127 / 7FH / -20 / 256-20=236 ECH
128 / 80H / -50 / 256-50=206 CEH
200 / C8H / -100 / 256-100=156 9CH
251 / FBH / -120 / 256-120=136 88H
252 / FCH / -125 / 256-125=131 83H
253 / FDH / -126 / 256-126=130 82H
254 / FEH / -127 / 256-127=129 81H
255 / FFH / -128 / 256-128=128 80H

Examples:

statements / flags
MOV AL, -128 AL = 80H
MOV BL, -2 BL = FEH
ADD AL, BL AL= AL+BL = 80H+FEH=17EH
( first digit will be ignored)
out of range positive and out of range negative
MOV AL, -100 AL = 9CH
MOV BL, 50 BL = 32H
SUB BL, AL BL = BL – AL = 32H- 9CH = 96H
In unsigned: 50 – 156 – negative – carry flag
In signed: 50 - ( -100) = 150 – out of range ( -128..127 ) overflow
Result 96H is negative – sign flag / O C
Overflow – if sum of two
negatives equals positive
or sum of two positive
equals negative.
The result of the arithmetic
operation is out of range in
signed system
( -128 .. 127 – range of
the signed 8 – bit numbers)
Carry – if the result of the
operation is out of range in
unsigned system:
(0…. 255 – range of positive
8-bit numbers)
or in subtraction we need
to take carry
O S C
MOV AL, -1 AL = FFH
MOV BL, 1 BL = 01H
ADD AL, BL Al = AL+BL = FFH + 01H =100H
The result in AL will be 00H – zero flag
In unsigned 255 + 1 = 256 –out of range – carry flag
In signed -1 + 1 = 0 - legal
If the ADD command will be replaced by
INC AL ( AL = AL - 1) the result in AL will be 00H
Zero flag will be set
Carry flag is not affected by INC command / Z C
Z
MOV AL , 5 AL= 05H
MOV BL, -8 BL = F8H
SUB BL, AL BL= BL-AL=F8H-05H=F3H – negative number / S
MOV AL, 100 AL= 64H
MOV BL, 100 BL = 64H
ADD AL, BL AL=AL+BL=64H+64H = C8H
Negative number, out of range in signed system C8H = 200
( signed range is: -128…127) / O S
MOV AL, -128 AL= 80H
DEC AL AL = AL - 1 = 80H – 01H = 7FH
-128 -1 = -129 out of range in signed system –
overflow
the same as SUB AL, 1 / O