Question
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.
The following is part of the code I was working on:
.MODEL SMALL .STACK .DATA STRING db "Entre un digito: ",13,10,13,10,'$' CHARACTER db ? DIVIDEND dw 0040h DIVISOR db 02h QUOTIENT db ? REMAINDER db ? .CODE MAIN PROC MOV AX, @DATA MOV DS, AX ; your code goes here call SHOW_STRING call READ_CHARACTER call WRITE_CHARACTER call CLEAR_KEYBOARD_BUFFER mov ax, 0h mov al, CHARACTER sub al, 30h mov bl, DIVISOR div bl mov QUOTIENT, al mov REMAINDER, ah 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, CHARACTER ; DL has the character int 21H RET WRITE_CHARACTER ENDP ;*********************************************************************************** READ_CHARACTER PROC mov ah, 8h ; read a character without echo from standard input int 21h ; AL stores the character read mov CHARACTER, al RET READ_CHARACTER ENDP ;*********************************************************************************** CLEAR_KEYBOARD_BUFFER PROC mov ah, 0bh ; check standard input status int 21h ; AL = 0 if input buffer is empty cmp al, 0h ; jz CLEARED ; are there no more characters in the standard input NEXT: call READ_CHARACTER mov ah, 0bh ; check standard input status int 21h ; AL = 0 if input buffer is empty cmp al, 0h ; jnz NEXT ; are there more characters in the standard input CLEARED: RET CLEAR_KEYBOARD_BUFFER ENDP end MAIN
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