Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .MODEL SMALL
- .STACK 100
- .DATA
- NUM1 DB ?
- NUM2 DB ?
- RESULT DB ?
- MSG1 DB "ENTER FIRST NUMBER TO ADD : $"
- MSG2 DB 10,13,"ENTER SECOND NUMBER TO ADD : $"
- MSG3 DB 10,13,"RESULT OF ADDITION : $"
- .CODE
- MAIN PROC
- MOV AX, @DATA
- MOV DS, AX
- LEA DX, MSG1
- MOV AH, 9
- INT 21H
- MOV AH, 1
- INT 21H
- SUB AL, 30H
- MOV NUM1, AL
- LEA DX, MSG2
- MOV AH, 9
- INT 21H
- MOV AH, 1
- INT 21H
- SUB AL, 30H
- MOV NUM2, AL
- ADD AL, NUM1 ; ADDING TWO NUMBERS NUM1 AND ACCUMALOTOR VALUE WHICH HAVE THE NUM2 VALUE
- MOV RESULT, AL
- MOV AH, 0 ; REMOVE GARBAGE FROM AH ( ACCUMALATOR HIGH )
- AAA ; What AAA exactly does is it converts the result into BCD form and first digit is saved in
- ; AH register and second digit is saved in AL register.
- ADD AH, 30H ; By adding 30H to BCD will Convert it to ASCII code which will print the digit (number) on screen.
- ADD AL, 30H
- MOV BX, AX ; Since the AH register is used again and again. We cannot lose the result in AH and AL register,
- ; So to save the to be printed value in BH and BL register. By moving AX to BX.
- LEA DX, MSG3
- MOV AH, 9
- INT 21H
- MOV AH, 2 ; OUTPUT FIRST CHARACTER ON BASE REGISTOR
- MOV DL, BH ; PRINT BASE REGISTOR HIGHER PORTION ( BH )
- INT 21H
- MOV AH, 2 ; OUTPUT FIRST CHARACTER ON BASE REGISTOR
- MOV DL, BL ; PRINT BASE REGISTOR LOWER PORTION ( BL )
- INT 21H
- MOV AH, 4CH
- INT 21H
- MAIN ENDP
- ENDS PROC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement