Question: How can this assembly language code be fixed so that it displays ASCII operations of + or - when working with numbers larger than 10

How can this assembly language code be fixed so that it displays ASCII operations of + or - when working with numbers larger than 10 or negative numbers? Right now it is programmed to display/work on command prompt with numbers less than 10. For example, 8-3=5. The goal is for allowance of for example, 15-10=5 or 4-8=-4. Thank you in advance!!

Edit: Apologies if the code doesn't work. The professor who wrote it made it work while in class and this is a direct copy from him that was sent to the students. What i didn't mention is that we're working with 32-bit Assembly language in Windows 7 which is partitioned through Oracle VirtualBox on Windows 10. It's an old class =/.

.model small .stack 100h

.data

msg1 db "Enter the first number",0DH,0AH,"$" ; this is a alphanumeric variable optype db " Enter + or -" ,0dh,0ah, "$" msg2 db "Enter the second number",0DH,0AH,"$" msg3 db 0DH,0AH,"The result is ", "$" firstnum db ? op db ? secondnum db ? .code

main proc mov ax,@data ; set up data segment mov ds,ax

mov ah,9 ; send first message to screen mov dx,offset msg1 int 21h call keyin sub al, 30h ; remove the ascii mov firstnum , al ; saving the first number mov ah,9 ; + or - mov dx,offset optype int 21h call keyin mov op , al

mov ah,9 mov dx,offset msg2 ; dispaly enter 2nd number int 21h call keyin sub al, 30h mov secondnum, al mov ah,9 mov dx,offset msg3 int 21h cmp op , 2bh jz addition mov dl, firstnum sub dl, secondnum call display mov ax, 4c00h int 21h addition: mov dl, firstnum add dl, secondnum

call display mov ax, 4c00h int 21h keyin proc mov ah, 1 int 21h ret keyin endp display proc add dl, 30h mov ah, 6 int 21h ret display endp main endp end main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!