• 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

Assembly Codes

Multiply Two 8 Bit BCD Numbers

May 4, 2011 by ProjectsGeek Leave a Comment

Objective

In this post we will see how to write assembly program to Multiply Two 8 Bit BCD Numbers. Both the numbers will be provided as input to the program which in the end will calculate product. After calculation it will be adjusted before printing it to screen.

Multiple two 8 bit BCD numbers Algorithm

Step I      :    Initialize the data segment.
Step II     :    Get the first unpacked BCD number.
Step III    :    Get the second unpacked BCD number.
Step IV    :    Multiply the two numbers.
Step V     :    Adjust result to valid unpacked BCD number in AX.
Step VI    :    Display the result.
Step VII   :    Stop.

 

Multiply Two 8 Bit BCD Numbers

Program Code

We need to declare two number and load the first number in AL and then second number in BL. Do the multiplication of these numbers and adjust based on unpacked BCD number which is must before printing the result.

 

.model small

.data

a db 04H

b db 06H

.code

mov ax, @data ; Initialize data section

mov ds, ax

mov ah, 0

mov al, a ; Load number1 in al

mov bl, b ; Load number2 in bl

mul bl ; multiply numbers and result in ax

aam ; adjust result to valid unpacked BCD

mov ch, 04h ; Count of digits to be displayed

mov cl, 04h ; Count to roll by 4 bits

mov bx, ax ; Result in reg bx

rol bx, cl ; roll bl so that msb comes to lsb

mov dl, bl ; 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

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

 

You can find more assembly language codes on this link. You can run this program using TASM which need to be installed on windows machine. Program running steps are :

C:\programs>tasm mult8bit.asm
Turbo Assembler  Version 3.0  Copyright (c) 1988, 1991 Borland International
Assembling file:  mult8bit.ASM
Error messages:    None
Warning messages:  None
Passes:            1
Remaining memory:  437k
Please leave a comment if you like this post.

Other Projects to Try:

  1. Add 8 Bit BCD Numbers
  2. Pack the Two Unpacked BCD Numbers Code
  3. Program to Multiply Two 16 Bit Numbers
  4. Multiply Two 8 Bit Numbers using Add and Shift Method
  5. Multiply Two 8 Bit Numbers Successive Addition Method

Filed Under: Assembly Codes Tagged With: Assembly Codes

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

Add 8 Bit BCD Numbers

May 4, 2011 by ProjectsGeek Leave a Comment

Add 8 bit BCD numbers

Add 8 Bit BCD Numbers is the program written in assembly language and describes the algorithm of adding two 8 bit BCD numbers through Assembly program code. This program will take numbers as input one by one and then add those BCD numbers. You can find complete steps and algorithm below step by step.
Algorithm :
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    :    Add the two BCD numbers.
Step V     :    Using DAA, adjust result to valid BCD number.
Step VI    :    Display the result.
Step VII  :    Stop.
  Program : 

 

 .model small  
 .data  
 a db 09H                                                 
 b db 02H  
 .code  
     mov  ax, @data  ; Initialize data section  
     mov  ds, ax  
     mov  al, a       ; Load number1 in al  
     mov  bl, b      ; Load number2 in bl  
     add   al, bl      ; add numbers and result in al  
     daa            ; 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  
   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  
   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  

 

Other Projects to Try:

  1. BCD to 7 Segment Code Conversion
  2. Add Two 8 Bit Numbers Code Assembly Language
  3. Add Two 16 Bit BCD Numbers Code
  4. Multiply Two 8 Bit BCD Numbers
  5. Subtract 8 Bit BCD Numbers

Filed Under: Assembly Codes Tagged With: Assembly Codes

Multiply Two 8 Bit Numbers using Add and Shift Method

May 4, 2011 by ProjectsGeek Leave a Comment

Write a program to Multiply Two 8 Bit Numbers using  Add and Shift Method in Assembly language .Program should take first and second numbers as input to the program . Now it should implement certain logic to multiply 8 bit Numbers using  Add and Shift Method .
Consider that one byte is present in the AL register and another byte is present in the BL register.
We have to multiply the byte in AL with the byte in BL.
We will multiply the numbers using add and shift method. In this method, you add number with itself and rotate the other number each time and shift it by one bit to left alongwith carry. If carry is present add the two numbers.
Initialize the count to 4 as we are scanning for 4 digits. Decrement counter each time the bits are added. The result is stored in AX. Display the result.
                        For example :   AL = 11 H,  BL = 10 H, Count = 4
Step I       :
AX =
11
+
11
22 H
                               Rotate BL by one bit to left along with carry.
BL = 10 H
0
¬
0
0
0
1
0
0
0
0
 ­
CY
BL =
0
0
0
1
0
0
0
0
0
CY
2
0
Step II     :    Now decrement counter count = 3.
                               Check for carry, carry is not there so add number with itself.
AX =
22
+
22
44 H
                               Rotate BL to left,
BL =
0
¬
0
1
0
0
0
0
0
0
CY
4
0
                               Carry is not there.
                               Decrement count, count=2
Step III   :    Add number with itself
AX =
44
+
44
88 H
                      Rotate BL to left,
BL =
0
1
0
0
0
0
0
0
0
CY
8
0
                               Carry is not there.
Step IV :      Decrement counter count = 1.
                               Add number with itself as carry is not there.
AX =
88
+
88
110 H
                               Rotate BL to left,
BL =
1
0
0
0
0
0
0
0
0
CY
0
0
                               Carry is there.
Step V :        Decrement counter = 0.
                               Carry is present.
                               \ add AX, BX
\
0110
i.e.
11 H
+
0000
´
10 H
0110 H
0110 H

Algorithm to Multiply Two 8 Bit Numbers using  Add and Shift Method: 

 

Step I          :    Initialize the data segment.
Step II        :    Get the first number.
Step III      :    Get the second number.
Step IV       :    Initialize count = 04.
Step V        :    number 1 = number 1 ´ 2.
Step VI       :    Shift multiplier to left along with carry.
Step VII     :    Check for carry, if present go to step VIII else go to step IX.
Step VIII   :    number 1 = number1 + shifted number 2.
Step IX      :    Decrement counter.
Step X        :    If not zero, go to step V.
Step XI      :    Display the result.
Step XII     :    Stop.

 

Multiply Two 8 Bit Numbers using Add and Shift Method 2

 

Program to Multiply Two 8 Bit Numbers using  Add and Shift Method:

 

.model small  
 .data  
 a db 11H  
 b db 10H  
 .code  
      mov      ax, @data     ; Initialize data section  
      mov      ds, ax  
      mov      al, a         ; Load number1 in al  
      mov      bl, b         ; Load number2 in bl  
      mov      ah, 0       
      mov      dl, 04h       ; initialize counter  
 ad:      add      ax, ax    ; add numbers. Result in dx                           
      rcl      bl, 01  
      jnc      skip  
      add      ax, bx   
 skip:      dec      dl      ; dec number  
      jnz      ad                 
      mov      ch, 04h       ; Count of digits to be   
                ; displayed  
      mov      cl, 04h       ; Count to roll by 4 bits  
      mov      bx, ax        ; Result in reg bx  
 l2:     rol      bx, cl     ; roll bl so that msb   
                ; comes to lsb   
      mov      dl, bl        ; 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  

How to Run this Program :

For Running this program you should have installed Tasm on you computer . If you have not installed Tasm  yet please install from Here .

C:\programs>tasm shaddmul.asm
Turbo Assembler  Version 3.0  Copyright (c) 1988, 1991 Borland International
Assembling file:   shaddmul.asm
Error messages:    None
Warning messages:  None
Passes:            1
Remaining memory:  438k
C:\programs>tlink shaddmul.obj
Turbo Link  Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\programs>shaddmul
0110

Other Projects to Try:

  1. Add 8 Bit BCD Numbers
  2. 2s Complement of a Numbers Assembly Code
  3. Multiply Two 8 Bit Numbers Successive Addition Method
  4. Program to Multiply Two 16 Bit Numbers
  5. Multiply Two 8 Bit BCD Numbers

Filed Under: Assembly Codes Tagged With: Assembly Codes

Multiply Two 8 Bit Numbers Successive Addition Method

May 4, 2011 by ProjectsGeek 2 Comments

Multiply Two 8 Bit Numbers by Successive Addition Method

Write a Program to Multiply Two 8 Bit Numbers  Successive Addition Method in Assembly language . Program should take first number and counter as input for the program and after implementing given below logic it should produce desired result .
Consider that a byte is present in the AL register and second byte is present in the BL register.
We have to multiply the byte in AL with the byte in BL.
We will multiply the numbers using successive addition method.
In successive addition method, one number is accepted and other number is taken as a counter. The first number is added with itself, till the counter decrements to zero.
Result is stored in DX register. Display the result, using display routine.
For example :   AL = 12 H,  BL = 10 H
                                Result = 12H + 12H + 12H + 12H + 12H + 12H + 12H + 12H + 12H + 12H
                                Result = 0120 H

Algorithm  to Multiply Two 8 Bit Numbers  Successive Addition Method

Step I          :   Initialize the data segment.
Step II        :   Get the first number.
Step III      :   Get the second number as counter.
Step IV       :   Initialize result = 0.
Step V        :   Result = Result + First number.                                               
Step VI       :   Decrement counter
Step VII     :   If count ¹ 0, go to step V.
Step VIII   :   Display the result.
Step IX      :   Stop.

 

Multiply Two 8 Bit Numbers Successive Addition Method 3

Program  to Multiply Two 8 Bit Numbers  Successive Addition Method

.model small  
 .data  
 a db 12H  
 b db 10H  
 .code  
      mov      ax, @data      ; Initialize data section  
      mov      ds, ax  
      mov      al, a          ; Load number1 in al       
      mov      bl, b          ; Load number2 in bl  
      mov      ah, 0       
      mov      dx, 0          ; intialize result  
 ad:     add      dx, ax          ; add numbers. Result in dx  
      dec      bl             ; dec number  
      cmp      bl, 0                                                            Flowchart 11  
      jnz      ad                 
      mov      ch, 04h        ; Count of digits to be displayed  
      mov      cl, 04h        ; Count to roll by 4 bits  
      mov      bx, dx         ; Result in reg bx  
 l2:     rol      bx, cl      ; roll bl so that msb comes to lsb   
      mov      dl, bl         ; 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

How to Run this Program

For Running this program you should have installed Tasm on you computer . If you have not installed Tasm  yet please install from Here .

C:\programs>tasm succmul.asm
Turbo Assembler  Version 3.0  Copyright (c) 1988, 1991 Borland International
Assembling file:   succmul.asm
Error messages:    None
Warning messages:  None
Passes:            1
Remaining memory:  438k
C:\programs>tlink succmul
Turbo Link  Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\programs>succmul
0120

Other Projects to Try:

  1. Multiply Two 8 Bit Numbers using Add and Shift Method
  2. Multiply Two 8 Bit Numbers in Assembly Language
  3. Add 8 Bit BCD Numbers
  4. Multiply Two 8 Bit BCD Numbers
  5. Program to Multiply Two 16 Bit Numbers

Filed Under: Assembly Codes Tagged With: Assembly Codes

Multiply Two 8 Bit Numbers in Assembly Language

May 4, 2011 by ProjectsGeek Leave a Comment

Multiply Two 8 Bit Numbers in Assembly Language

Write a program to Multiply Two 8 Bit Numbers in assembly language . Program should load first number and second number in registers AL and BL registers . Then it should implement some logic for multiplication of two numbers .

 

Consider that a byte of data is present in the AL register and second byte of data is present in the BL register.
We have to multiply the byte in AL with the byte in BL.
Using MUL instruction, multiply the contents of two registers.
The multiplication of two 8 bit numbers may result into a 16 bit number. So result is stored in AX register.
The MSB is stored in AH and LSB in AL.      
                  
For example :
AL = 09 H
09 H
BL = 02 H
´
02 H
0012 H

Algorithm to Multiply Two 8 Bit Numbers

Step I       :    Initialize the data segment.
Step II      :    Get the first number in AL register.
Step III    :    Get the second number in BL register.                                     
Step IV    :    Multiply the two numbers.
Step V      :    Display the result.
Step VI    :    Stop 

 

Multiply Two 8 Bit Numbers in Assembly Language 4

 

Program to Multiply Two 8 Bit Numbers

 

.model small  
 .data                                                                   
 a db 09H  
 b db 02H  
 .code  
      mov      ax, @data           ; Initialize data section  
      mov      ds, ax  
      mov      ah, 0  
      mov      al, a               ; Load number1 in al  
      mov      bl, b               ; Load number2 in bl  
      mul      bl                  ; multiply numbers and result in ax  
      mov      ch, 04h             ; Count of digits to be displayed  
      mov      cl, 04h             ; Count to roll by 4 bits  
      mov      bx, ax              ; Result in reg bx  
 l2:     rol      bx, cl           ; roll bl so that msb comes to lsb   
      mov      dl, bl              ; 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

How to Run this Program

For Running this program you should have installed Tasm on you computer . If you have not installed Tasm  yet please install from Here .

C:\>tasm 8bit-mul.asm
Turbo Assembler  Version 3.0  Copyright (c) 1988, 1991 Borland International
Assembling file:   8bit-mul.asm
Error messages:    None
Warning messages:  None
Passes:            1
Remaining memory:  438k
C:\>tlink 8bit-mul.obj
Turbo Link  Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\>8bit-mul
0012

Other Projects to Try:

  1. Multiply Two 8 Bit Numbers Successive Addition Method
  2. Multiply Two 8 Bit Numbers using Add and Shift Method
  3. GCD of Two Numbers program in Assembly Language
  4. Subtract Two 8 Bit Numbers Code Assembly Language
  5. Add Two 8 Bit Numbers Code Assembly Language

Filed Under: Assembly Codes Tagged With: Assembly Codes

  • « Go to Previous Page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Page 5
  • Page 6
  • Go to Next Page »

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