Showing posts with label 8086 SUBTRACTION PROGRAM. Show all posts
Showing posts with label 8086 SUBTRACTION PROGRAM. Show all posts

Wednesday, December 1, 2021

Subtraction of two decimal digits in 8086 Microprocessor x86 Assembly Language

Subtraction of two decimal digits in 8086 Microprocessor x86 Assembly Language

This 8086 microprocessor assembly program subtracts two decimal digits and prints the output accordingly. If you want to know how can you print a single character in 8086 assembly language you can find it IN THIS LINK. If you have questions or any problems feel free to ask in the comments section.





TITLE THE_LAME_PROGRAMMER 
.MODEL SMALL 
.STACK 100H 
.DATA 
    DIGIT1 DB 0AH, 0DH, "ENTER FIRST DIGIT: $" 
    DIGIT2 DB 0AH, 0DH, "ENTER SECOND DIGIT: $" 
    RESULT DB 0AH, 0DH, "RESULT IS: $" 
  
.CODE 
 
    MAIN: 
        MOV AX, @DATA 
        MOV DS, AX 
         
        MOV DX, OFFSET DIGIT1 
        MOV AH, 09H 
        INT 21H 
         
        MOV AH, 01H 
        INT 21H 
        SUB AL, 30H 
        MOV BH, AL 
         
        MOV DX, OFFSET DIGIT2 
        MOV AH, 09H 
        INT 21H 
         
        MOV AH, 01H 
        INT 21H 
        SUB AL, 30H 
        MOV BL, AL 
         
        CMP BH, BL 
         
        JL MINUS 
         
        SUB BH, BL 
         
        MOV DX, OFFSET RESULT 
        MOV AH, 09H 
        INT 21H 
         
        MOV DL, BH 
        ADD DL, 30H 
        MOV AH, 02H 
        INT 21H 
         
        JMP EXIT 
         
   MINUS: 
        SUB BL, BH 
         
        MOV DX, OFFSET RESULT 
        MOV AH, 09H 
        INT 21H 
         
        MOV DL, '-' 
        MOV AH, 02H 
        INT 21H 
         
        MOV DL, BL 
        ADD DL, 30H 
        MOV AH, 02H 
        INT 21H 
         
   EXIT: 
        MOV AH, 04CH 
        INT 21H 
   END MAIN 


OUTPUT OF THE PROGRAM
Subtraction of decimal digits in 8086 assembly Language














Subtraction of decimal digits in 8086 assembly Language


Complete Video Tutorials