Question
In Assembly Language Programming (I am using Dos Box x86) program the following Code: - The user inputs two digits from 0 to 9. Both
In Assembly Language Programming (I am using Dos Box x86) 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 have also added some debug code to try to find the issue but to no avail. I will also be sending the output of my program.
Is the problem maybe at displaying the result? Or and storing the values when first inputted by the user. Or in the change of numbers to ASCII code?
The following is part of the code I was working on, please find the issue and fix:
.MODEL SMALL .STACK 100H .DATA
number1 db 0 number2 db 0 result db 0 prompt1 db "Enter the first number (0-9): $" prompt2 db "Enter the second number (0-9): $" prompt3 db "Result: $" crlf db 0DH, 0AH, '$'
.CODE
main proc mov ax, @data mov ds, ax ; prompt user to enter first number lea dx, prompt1 mov ah, 9 int 21h
; read first number from user input mov ah, 1 int 21h sub al, 48 mov number1, al
; prompt user to enter second number lea dx, prompt2 mov ah, 9 int 21h
; read second number from user input mov ah, 1 int 21h sub al, 48 mov number2, al
; add the two numbers together and store result in 'result' mov al, number1 add al, number2 mov result, al
; display result lea dx, prompt3 mov ah, 9 int 21h mov al, result add al, 48 mov dl, al mov ah, 2 int 21h
; new line lea dx, crlf mov ah, 9 int 21h
; exit program mov ax, 4c00h int 21h main endp end main
C:\FINAL>link final.obj,,;
Microsoft (R) Overlay Linker Version 3.60 Copyright (C) Microsoft Corp 1983-1987. All rights reserved.
C:\FINAL>final.exe Enter the first number (0-9): 3Enter the second number (0-9): 3Result: 6
C:\FINAL>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started