Displaying two digit numbers in assembly? -
i new assembly programming. in of examples @ classwork required add 2 numbers , display sum, find cryptic display sum when 2 digit number. here's code.
mov al,num1 mov bl,num2 add al,bl add ax,3030h mov dl,ah mov ah,02h int 21h mov dl,al mov ah,02h int 21h mov ah,4ch int 21h
while addition might result in packed number, how unpack , display 2 different numbers in decimal?
i'm new assembly. think you.
.model small .stack 100h .data msg1 db "enter number 1:$" msg2 db "enter number 2:$" msg3 db "sum is:$" no1 db 0 no2 db 0 mysum db 0 rem db 0 .code mov ax,@data mov ds,ax ;print msg 1 mov dx,offset msg1 mov ah,09h int 21h ;read input no1 mov ah,01h int 21h sub al,48 mov no1,al ;print new line mov dl,10 mov ah,02h int 21h ;print msg2 mov dx,offset msg2 mov ah,09h int 21h ;read input 2 mov ah,01h int 21h sub al,48 mov no2,al ;print new line mov dl,10 mov ah,02h int 21h ;print msg3 mov dx,offset msg3 mov ah,09h int 21h ;add 2 numbers mov dl,no1 add dl,no2 ;moving sum mysum mov mysum,dl ;clear ah use reminder mov ah,00 ;moving sum al mov al,mysum ;take bl=10 mov bl,10 ;al/bl --> twodigit number/10 = decemel value div bl ;move reminder rim mov rem,ah ;to print (al) move al dl mov dl,al add dl,48 mov ah,02h int 21h ;to print reminder mov dl,rem add dl,48 mov ah,02h int 21h mov ax,4c00h int 21h end
here i've done took total , move al can keep it. divide 10 , print quotient , reminder. if feel problem. can ask. thank !
Comments
Post a Comment