Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DOSBOX: I am having problems with the code: see image .model small .stack print macro m lea dx,m mov ah,09h int 21h endm read macro

DOSBOX:

I am having problems with the code: see image

image text in transcribed

.model small

.stack

print macro m

lea dx,m

mov ah,09h

int 21h

endm

read macro

mov ah,01h

int 21h

sub al,30h

endm

display macro n

mov dl,n

add dl,30h

mov ah,02h

int 21h

endm

input macro

read

mov bl,0ah

mul bl

mov cl,al

read

add al,cl

endm

result macro

mov ah,00h

mov bl,0ah

div bl

mov bh,ah

display al

display bh

endm

.data

a db 0ah,0dh,"Enter the first Number:$"

b db 0ah,0dh,"Enter the Second Number:$"

s db 0ah,0dh, "Sum = $"

n db 0ah,0dh,"Difference = $"

p db 0ah,0dh,"Product = $"

q db 0ah,0dh,"Quotient = $"

r db 0ah,0dh,"Reminder = $"

s1 db 0ah,0dh, "1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit$"

s2 db 0ah,0dh,"Enter your Choice: $"

d db ?

e db ?

.code

mov ax,@data

mov ds,ax

l1: print s1

print s2

read

mov ch,al

cmp al,05

je exit

print a

input

mov d,al

print b

input

mov e,al

cmp ch,01

je la

cmp ch,02

je ls

cmp ch,03

je lm

cmp ch,04

je ld

la: print s

mov al,d

add al,e

result

jmp l1

ls: print n

mov al,d

cmp al,e

jl l2

sub al,e

jmp l3

l2: mov bl,e

sub bl,al

mov al,bl

l3:result

jmp l1

lm: print p

mov al,d

mov cl,e

mul cl

result

jmp l1

ld: print q

mov al,d

mov cl,e

mov ah,00h

div cl

mov ch,ah

result

print r

mov al,ch

result

jmp l1

exit: mov ah,4ch

int 21h

end.8086

.MODEL SMALL

.STACK

.DATA

NEWLINE db 0Dh, 0Ah, '$'

PROMPT db "Entre una cadena de caracteres: ",'$'

CHARACTER db ?

STRING db 81 dup('$')

MAX_LEN equ 80

CARRIAGE_RETURN equ 0Dh

LINE_FEED equ 0Ah

.CODE

MAIN PROC

mov ax, @DATA

mov ds, ax

call NEW_LINE

call SHOW_PROMPT

call ASK_STRING

call NEW_LINE

call NEW_LINE

call SHOW_STRING

call NEW_LINE

call NEW_LINE

mov ax, 4c00h ; exit program

int 21h ; return AL

RET

MAIN ENDP

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

SHOW_PROMPT PROC

mov dx, offset PROMPT ; write all characters

mov ah, 09h ; in the standard output

int 21h ; DX has the offset of the first character

RET ; the last character must be '$'

SHOW_PROMPT ENDP

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

SHOW_CHARACTER PROC

mov ah, 02h ; write a character to standard ouput

mov dl, CHARACTER ; DL has the character

int 21H

RET

SHOW_CHARACTER ENDP

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

ASK_CHARACTER PROC

mov ah, 08h ; read a character without echo from standard input

int 21h ; AL stores the character read

mov CHARACTER, al

RET

ASK_CHARACTER ENDP

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

NEW_LINE PROC

mov dx, offset NEWLINE ; 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 '$'

NEW_LINE ENDP

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

ASK_STRING PROC

mov di, 0h

GET_NEXT:

call ASK_CHARACTER

call SHOW_CHARACTER

mov bl, CHARACTER

cmp bl, CARRIAGE_RETURN

jz EOL

cmp di, MAX_LEN

je SKIP

mov STRING[di], bl

inc di

SKIP:

jmp GET_NEXT

EOL:

mov STRING[di], '$'

call CLEAR_KEYBOARD_BUFFER

RET

ASK_STRING ENDP

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

SHOW_STRING PROC

mov dx, offset STRING ; write all characters

mov ah, 09h ; in the standard output

int 21h ; DX has the offset of the first character

RET ; the last character must be '$'

SHOW_STRING 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 ASK_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

STRING_TO_UNSIGNED_INT PROC

mov ax, 0h

mov cx, 0h

mov bx, 10

mov di, 0h

mov cl, STRING[di]

BACK:

cmp cl, '$'

jz CONVERTED

mul bx

sub cl, '0'

add ax, cx

inc di

mov cl, STRING[di]

jmp BACK

CONVERTED:

mov UNSIGNED_INT, ax

RET

STRING_TO_UNSIGNED_INT ENDP

UNSIGNED_INT_TO_STRING PROC

mov ax, UNSIGNED_INT

mov bx, 10

mov di, 0h

ANOTHER:

mov dx, 0h

div bx

add dl, '0'

mov STRING[di], dl

inc di

cmp ax, 0h

jnz ANOTHER

mov STRING[di], '$'

dec di

mov si, 0

OTHER:

mov ch, STRING[di]

mov cl, STRING[si]

mov STRING[di], cl

mov STRING[si], ch

dec di

inc si

cmp si, di

jb OTHER

RET

UNSIGNED_INT_TO_STRING ENDP

DOS BOX DOSBox 0.74-3, Cpu speed: 3000 cycles, Frameskip 0, Program: DOSBOX D:\cd programs D:\PROGRAMS>masm Microsoft (R) Macro Assembler Version 5.00 Copyright (c) Microsoft Corp 1981-1985, 1987. All rights reserved. Source filename L.ASM]: FP Dbject filename [FP.OBJ]: Source listing [NUL.LST]: FP Cross-reference [NUL.CRF): FP.ASM(111): error A2053: Jump out of range by 192 byte(s) FP.ASM(139): error A2053: Jump out of range by 24 byte(s) 51196 + 465316 Bytes symbol space free Warning Errors 2 Severe Errors D:\PROGRAMS>_ DOS BOX DOSBox 0.74-3, Cpu speed: 3000 cycles, Frameskip 0, Program: DOSBOX D:\cd programs D:\PROGRAMS>masm Microsoft (R) Macro Assembler Version 5.00 Copyright (c) Microsoft Corp 1981-1985, 1987. All rights reserved. Source filename L.ASM]: FP Dbject filename [FP.OBJ]: Source listing [NUL.LST]: FP Cross-reference [NUL.CRF): FP.ASM(111): error A2053: Jump out of range by 192 byte(s) FP.ASM(139): error A2053: Jump out of range by 24 byte(s) 51196 + 465316 Bytes symbol space free Warning Errors 2 Severe Errors D:\PROGRAMS>_

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions