Write an assembly language program to add all of the digits of D14643668 Solutio
ID: 1935819 • Letter: W
Question
Write an assembly language program to add all of the digits of D14643668Explanation / Answer
this program adds 2 1-digit numbers ;without carry ,sum < 10 or with carry , sum >9 ;coded by -----LenmorVash------ ;coded in emu8086 org 100h mov dx,offset str mov ah, 09h int 21h mov dx,offset str2 mov ah, 09h int 21h mov dx,offset str3 mov ah, 09h int 21h ;---new line--- mov ah, 2 mov dl, 10 int 21h mov ah, 2 mov dl, 13 int 21h ;--------------- ;======================================== mov dx,offset str5 mov ah, 09h int 21h ;accept 1 char from keyboard mov ah, 1 int 21h ;convert to number sub al,30h mov [temp],al ;======================================= ;--------------------------------------- mov dx,offset str6 mov ah, 09h int 21h ;accept 1 char from keyboard mov ah, 1 int 21h ;convert to number sub al,30h mov [temp2],al ;----------------------------------------- ;++++++++++++++++++++++++++++++++++++++++++ ;ADD [temp],[temp2] xxx illegal xxx mov bh, [temp] add bh, [temp2] ;jump to g10 if sum is greater than 9, >=10 cmp bh,09h jg g10 ;sub bh,30h ;sub bl,30h ;push bx ;print answer if not greater than 9 add bh, 30h ;convert back to ASCII equiv mov dx,offset str7 ;some message mov ah, 09h int 21h mov ah,2 ;print answer mov dl,bh ;mov dl,ch ;add dl, 30h int 21h jmp exit ;jump to program termination ;--------------------------------------- ;execution jumps here if answer >=10 g10: xor ax,ax ;clear ax to 00, ah=0h al=0h mov al, bh ;transfer prev. answer to al aaa ;separate result to AH and AL, and correct the ;sum using AAA mov cx,ax ;transfer AX to CX add cx, 3030h ;convert back to ASCII equiv mov dx,offset str7 ;some message mov ah, 09h int 21h mov ah,2 ;print answer mov dl,ch ;1st digit in CH int 21h mov dl,cl ;2nd digit in CL int 21h ;++++++++++++++++++++++++++++++++++++++++++ exit: ;pause....... mov ah,00h int 16h ;............ ret str db "Lab. Activity No.2 $" str2 db 10,13,"Codere: Lenmor Vash $" str3 db 10,13,"God Bless ^_^ $" temp db 0 temp2 db 0 str5 db "Enter the 1st No: $" str6 db 10,13,"Enter the 2nd No: $" str7 db 10,13,"The answer is: $"Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.