Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4.

Similar presentations


Presentation on theme: "Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4."— Presentation transcript:

1 Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4

2 Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic BCD: Binary Coded Decimal Packed BCD Arithmetic –BCD Addition –BCD Subtraction Unpacked BCD Arithmetic –ASCII Addition –ASCII Subtracition –BCD Multiplication –BCD Division

3 Introduction to Computer Engineering by Richard E. Haskell Binary Coded Decimal Code decimal numbers using the binary digits, That is, Can NOT use the hex digits A - F. For example, the DECIMAL number 3582 would be coded in BCD as While this looks like the HEX number 3582H in BCD we interpret it as the DECIMAL number 3582.

4 Introduction to Computer Engineering by Richard E. Haskell BCD Addition Binary 35H H CH Decimal (BCD) 35H H H B0 35 MOV AL,35H ;AL = 35H ADD AL,47H ;AL = AL+47H DAA ;Decimal adjust

5 Introduction to Computer Engineering by Richard E. Haskell BCD Subtraction Binary 52H H DH Decimal (BCD) 52H H H B0 52 MOV AL,52H ;AL = 52H C 25 SUB AL,25H ;AL = AL-25H F DAS ;Decimal adjust

6 Introduction to Computer Engineering by Richard E. Haskell ASCII Addition DecimalASCII AH AL 0000 B MOV AX,0039H ;AL = 39H ADD AL,36H ;AL = AL + 36H AAA ;ASCII adjust

7 Introduction to Computer Engineering by Richard E. Haskell ASCII Subtraction DecimalASCII FF 07 AH AL 0000 B MOV AX,0036H ;AL = 36H C 39 SUB AL,39H ;AL = AL - 39H F AAS ;ASCII adjust Borrow = 1 Carry flag = 1

8 Introduction to Computer Engineering by Richard E. Haskell BCD Multiplication DecimalASCII 8 x x AH AL 0000 B0 08 MOV AL,08H ;AL = 08H 0002 B3 07 MOV BL,07H ;BL = 07H 0004 F6 E3 MUL BL ;AL = AL x BL 0006 D4 0A AAM ;ASCII adjust Binary(Hex) 08 x07 38

9 Introduction to Computer Engineering by Richard E. Haskell BCD Division 9 = quotient = remainder Decimal 0000 B MOV AX,0506H ;AX = 0506H 0003 B3 06 MOV BL,06H ;BL = 06H 0005 D5 0A AAD ;Adjust AX for ; BCD div 0007 F6 F3 DIV BL ;divide Hex


Download ppt "Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4."

Similar presentations


Ads by Google