Add n BCD numbers Apr 10, 2006 • Rohit 8086 Assembly Language Programs (DOS) .model small .stack 100 .data current db 0h count db 0h sum db 0,0 strtmsg db "How many numbers to add (02-99)?", 13, 10, "$" msg1 db 13, 10, "Enter the number (", "$" msg2 db ") $", 13, 10 ansis db "The sum of the numbers is $" .code main proc far mov ax, @data mov ds, ax mov dx, offset strtmsg mov ah, 09h int 21h call get2dignum inc al mov count, al mov current, al dec current cmp al, 02h jae lop jmp ext lop: mov dx, offset msg1 ;Prompt to enter the number mov ah, 09h int 21h mov al, count sub al, current das mov dl, al mov ch, dl and dl, 0f0h mov cl, 04h rol dl, cl or dl, 30h mov ah, 02h int 21h mov dl, ch and dl, 0fh or dl, 30h mov ah, 02h int 21h mov dx, offset msg2 mov ah, 09h int 21h mov al, current sub al, 01h das mov current, al call get2dignum ;Add the number add al, sum+1 daa mov sum+1, al jnc nocarry inc sum nocarry:cmp current, 00h jne lop mov dl, 13 mov ah, 02h int 21h mov dl, 10 mov ah, 02h int 21h mov dx, offset ansis mov ah, 09h int 21h mov dl, sum mov ch, dl and dl, 0f0h mov cl, 04h rol dl, cl or dl, 30h mov ah, 02h int 21h mov dl, ch and dl, 0fh or dl, 30h mov ah, 02h int 21h mov dl, sum+1 mov ch, dl and dl, 0f0h mov cl, 04h rol dl, cl or dl, 30h mov ah, 02h int 21h mov dl, ch and dl, 0fh or dl, 30h mov ah, 02h int 21h ext: mov dl, 13 mov ah, 02h int 21h mov dl, 10 mov ah, 02h int 21h mov ah, 04ch int 21h main endp get2dignum proc near push dx mov ah, 01h int 21h mov bl, al and bl, 0fh mov ah, 01h int 21h mov cl, 04h rol bl, cl and al, 0fh add bl, al mov al, bl mov ah, 00h pop dx ret get2dignum endp end main Add reply Click here to reply to the blog post instead Send