Lab Session 7 Objectives: of Unsigned Numbers
Lab Session 7 Objectives: of Unsigned Numbers
Objectives
Theory:
Compare operands CF ZF
Destination >source 0 0
Destination = source 0 1
Destination < source 1 0
Flag settings of the CMP instruction.
BCD(Binary Coded Decimal and ASCII (American Standard Code for Information Interchange)
Instructions
¾ Binary representation of 0 to 9 (used by human beings) is called BCD.
Digit BCD
¾ There are two types of BCD numbers,
(1) unpacked BCD (2) packed BCD 0 0000
1 0001
Unpacked BCD: 1 byte is used to store 4 bit BCD code. E.g. 0000 1001 is 2 0010
unpacked BCD for 9. 3 0011
4 0100
Packed BCD: 1 byte is used to store two 4 bit BCD codes. E.g. 0101 1001 5 0101
is packed BCD for 59. More efficient in storing data. 6 0110
7 0111
8 1000
9 1001
ASCII numbers:
Key ASCII(Hex) Binary BCD (Unpacked)
0 30 011 0000 0000 0000
1 31 011 0001 0000 0001
2 32 011 0010 0000 0010
3 33 011 0011 0000 0011
4 34 011 0100 0000 0100
5 35 011 0101 0000 0101
6 36 011 0110 0000 0110
7 37 011 0111 0000 0111
8 38 011 1000 0000 1000
9 39 011 1001 0000 1001
Ex:
MOV AL,VAL1_BCD
MOV AH,AL ;copy AL to AH. Now AH=29 and AL=29
AND AX,F00FH ;mask 9 from AH and 2 from AL
MOV CL,04 ;CL=04 for shift
SHR AH,CL ;shift right AH to get unpacked BCD
OR AX,3030H combine with 30 to get ASCII
XCHG AH,AL ;swap for ASCII storage convention
MOV VAL3_ASC,AX ;store the ASCII