Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

In Assembly Language Programming (I am using Dos Box) program the following Code: - The user inputs two digits from 0 to 9. Both digits

In Assembly Language Programming (I am using Dos Box) program the following Code: - The user inputs two digits from 0 to 9. Both digits most be non negative and it most be a single digit per entry. - The program has to do the following arithmetic operations: - Addition and display the result of the addition. - Multiply and display the result. - Division and display the result. - Subtraction and display the result. In subtraction the result can sometimes be negative you should display the negative result but remember that the digits the user enters most be non negative.

I already have like 70% of the code here is the code that I have:

.MODEL SMALL

.STACK

.DATA

STRING db "Enter a digit: ",13,10,13,10,'$' ADDITION db "The sum is: ",13,10,13,10,'$' MULTIPLICATION db "The product is: ",13,10,13,10,'$' DIVISION db "The quotient is: ",13,10,13,10,'$' SUBTRACTION db "The difference is: ",13,10,13,10,'$' DIGIT1 db ? DIGIT2 db ? RESULT db ?

.CODE MAIN PROC MOV AX, @DATA MOV DS, AX

call SHOW_STRING

call READ_DIGIT mov DIGIT1, al

call SHOW_STRING

call READ_DIGIT mov DIGIT2, al

call ADD_DIGITS call SHOW_STRING call SHOW_RESULT

call MULTIPLY_DIGITS call SHOW_STRING call SHOW_RESULT

call DIVIDE_DIGITS call SHOW_STRING call SHOW_RESULT

call SUBTRACT_DIGITS call SHOW_STRING call SHOW_RESULT

MOV AX, 4C00h INT 21h MAIN ENDP

;***********************************************************************************

SHOW_STRING PROC mov dx, offset STRING ; write all characters mov ah, 9 ; in the standard output int 21h ; DX has the offset of the first character RET ; the last character must be '$' SHOW_STRING ENDP

;***********************************************************************************

WRITE_CHARACTER PROC mov ah, 2h ; write a character to standard output mov dl, DIGIT1 ; DL has the character int 21H RET WRITE_CHARACTER ENDP

;***********************************************************************************

READ_DIGIT PROC mov ah, 1h ; read a character from standard input int 21h ; AL stores the character read sub al, 30h ; convert from ASCII to binary digit RET READ_DIGIT ENDP

;***********************************************************************************

ADD_DIGITS PROC mov al, DIGIT1 add al, DIGIT2 mov RESULT, al RET ADD_DIGITS ENDP

;***********************************************************************************

MULTIPLY_DIGITS PROC mov al, DIGIT1 mul DIGIT2 mov RESULT, al RET MULTIPLY_DIGITS ENDP

;***********************************************************************************

DIVIDE_DIGITS PROC mov ax, DIGIT1 mov bl, DIGIT2 xor ah, ah ; clear upper half of AX div bl mov RESULT, al RET DIVIDE_DIGITS ENDP

;***********************************************************************************

SUBTRACT_DIGITS PROC mov al, DIGIT1 sub al, DIGIT2 mov RESULT, al RET SUBTRACT_DIGITS ENDP

;***********************************************************************************

SHOW_RESULT PROC mov dx, offset RESULT mov ah, 9 int 21h mov dx, offset ADDITION mov ah, 9 int 21h RET SHOW_RESULT ENDP

;***********************************************************************************

end MAIN

It has a warning which I haven't been able to fix.

After you input the first digit the second input displays the first number at the beginning of the string.

And after you input the second digit the programs goes crazy and the computer starts beeping. I'm going to post a picture of the problems. image text in transcribed

Microsoft (R) Macro Assembler Version 5.00 Copyright (C) Microsoft Corp 1981-1985, 1987. All righ final.asm(99): warning A4031: Operand types must match 51036+438836 Bytes symbol space free 1 Warning Errors 0 Severe Errors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions