ASSEMBLY LANGUAGE Answer should be in ASSEMBLY LANGUAGE CODE

ASSEMBLY LANGUAGE

Answer should be in ASSEMBLY LANGUAGE CODE ONLY!

Enter first digit: 1 Enter second digit: 2 Sum = 3 Discussion: To read a digit from the keyboard we will use the author\'s routine, ReadDec. This routine is written to read in a number but we will use it to just read in a single digit. call ReadDec mov dig1, AL To write a digit to the screen we will use the author\'s routine, Write Dec. This routine is written to write a number but we will use it to just write a single digit. movzx EAX, digSum;Print digSum call WriteDec Solve the problem with pseudocode first. You can think of this problem as printing the sum of two numbers but the numbers are a single digit. Use the following definitions .data dig1Msg BYTE \"Enter first digit: \", 0 dig2Msg BYTE \"Enter second digit: \", 0 sumMsg BYTE \"Sum = \", 0 dsig1 BYTE ? dig2 BYTE? digSum BYTE?

Solution

.model small
.stack 100h
.data
Message1 db \"Enter First Digit : $\"
Message2 db ,0dh,0ah,\"Enter Second Digit : $\"
Message3 db ,0dh,0ah,\"SUM of Entered Numbers = $\"
No1 db ?;
No2 db ?,;
ans db ?,\"$\"
.code
main proc
  
mov ax,@data ;initiaize ds
mov ds,ax
mov dx,offset Message1 ;load and display msg1
mov ah,09
int 21h
mov ah,1h ;read first initial
int 21h
sub al,30h
mov No1,al
mov dx,offset Message2 ;load and display msg2
mov ah,9
int 21h
;read second initial
mov ah,1h
int 21h
sub al,30h
mov No2,al
mov dx,offset Message3
mov ah,9 ;load and display msg3
int 21h
mov al,No1 ;add No1 and No1
add al,No2
add al,30h ;moves value into ans
mov ans,al
mov dx,offset ans ;load and display msg3
mov ah,9
int 21h
;returns control to dos
mov ah, 4ch
int 21h
main endp
end main

ASSEMBLY LANGUAGE Answer should be in ASSEMBLY LANGUAGE CODE ONLY! Enter first digit: 1 Enter second digit: 2 Sum = 3 Discussion: To read a digit from the keybo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site