To perform BCD addition of two 8-bit numbers from keyboard using INT 21H.
Create a file named exp5.asm in Notepad and save it in D:\TASM:
.model small
.stack 100h
.data
msg1 db "Enter first BCD digit: $"
msg2 db 0Dh,0Ah,"Enter second BCD digit: $"
resmsg db 0Dh,0Ah,"Sum = $"
.code
main proc
mov ax, @data
mov ds, ax
; Display first prompt
lea dx, msg1
mov ah, 09h
int 21h
; Input first digit
mov ah, 01h
int 21h
sub al, 30h ; Convert ASCII to numeric
mov bl, al
; Display second prompt
lea dx, msg2
mov ah, 09h
int 21h
; Input second digit
mov ah, 01h
int 21h
sub al, 30h
add al, bl
daa ; BCD adjust
add al, 30h ; Convert back to ASCII
; Display result message
lea dx, resmsg
mov ah, 09h
int 21h
; Display result
mov dl, al
mov ah, 02h
int 21h
mov ah, 4ch
int 21h
main endp
end main
Inside DOSBox, compile and run:
tasm filename.asm
tlink filename.obj
Run Debug:
td filename.exe