• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Subtract 8 Bit BCD Numbers

May 4, 2011 by ProjectsGeek Leave a Comment

Subtract 8 bit BCD numbers

Introduction 

Binary Coded Decimal Number system uses binary numbers to represent a decimal number.

Here Each decimal digit is represented by either 4-digit or 8-digit bits.

BCD is extensively used to display the numeric values in all electronic systems containing only digital logic without microprocessors.

BCD is more powerful than the binary representations. It helps in rounding off decimal values more effectively into human readable formats. 

The Disadvantages of BDC are some operations will be more complex to implement. Also BCD consumes around 20% more space compared to binary representation.

Below is the BCD representation chart for decimal digits from 0-15

Decimal Number Binary Number Binary Coded Decimal Number (BCD) 
0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
10 1010 0001 0000
11 1011 0001 0001
12 1100 0001 0010
13 1101 0001 0011
14 1110 0001 0100
15 1111 0001 0101

 

Subtract 8 Bit BCD Numbers 1

Algorithm to subtract 8-bit BCD numbers

Step I       :    Initialize the data memory.
Step II     :    Get the first BCD number in AL.
Step III   :    Get the second BCD number in BL.
Step IV    :    Subtract the two BCD numbers.
Step V     :    Adjust result to valid BCD number.
Step VI    :    Display the result.
Step VII  :    Stop.

Subtract 8 Bit BCD Numbers Program

 
.model small  
 .data                                                    
 a db 32H                              
 b db 17H  
 .code  
     mov  ax, @data      ; Initialize data section  
     mov  ds, ax                                        
     mov  al, a           ; Load number1 in al  
     mov  bl, b           ; Load number2 in bl  
     sub   al, bl          ; subtract numbers and result in al  
     das                 ; adjust result to valid BCD number  
     mov  ch, 02h        ; Count of digits to be displayed  
     mov  cl, 04h         ; Count to roll by 4 bits  
     mov  bh, al          ; Result in reg bh  
 l2:  rol    bh, cl          ; roll bl so that msb comes to lsb  
     mov  dl, bh          ; load dl with data to be displayed  
     and   dl, 0fH         ; get only lsb  
     cmp  dl, 09          ; check if digit is 0-9 or letter A-F  
     jbe   l4  
     add   dl, 07          ; if letter add 37H else only add 30H  
 l4:  add   dl, 30H  
     mov  ah, 02              ; Function 2 under INT 21H (Display character)  
     int    21H  
     dec   ch            ; Decrement Count  
     jnz   l2  
     mov  ah, 4cH        ; Terminate Program  
     int    21H  
     end  

For  more assembly language codes, please visit this page.

Other Projects to Try:

  1. Add 8 Bit BCD Numbers
  2. Pack the Two Unpacked BCD Numbers Code
  3. Program to Subtract Two 32 Bit Numbers
  4. Program to Subtract Two 16 Bit Numbers
  5. Subtract Two 8 Bit Numbers Code Assembly Language

Filed Under: Assembly Codes Tagged With: Assembly Codes

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy