
Calculadora
Ensamblador
Publicado el 12 de Junio del 2023 por Cinthya
1.139 visualizaciones desde el 12 de Junio del 2023
Necesito su ayuda para que está calculadora reciba números decimales por favor
INCLUDE 'emu8086.inc'
ORG 100h
.data
; Variables that will contain the results of the operations
num1 dd 0.0 ; dd defines double word to store decimal numbers
num2 dd 0.0
; Variables that contain texts
menu db 0Dh,0Ah,0Ah,"¿Desea realizar otra operación?:" ,0Dh,0Ah ; 0Dh and 0Ah format the page and give a line break
db 0Dh,0Ah,"1) Sí, 2) No: $",0Dh,0Ah
menu2 db 0Dh,0Ah,0Ah,"MENU" ,0Dh,0Ah
db "1) Suma" ,0Dh,0Ah
db "2) Resta" ,0Dh,0Ah
db 0Dh,0Ah, "¿Qué operación desea realizar?:$",0Dh,0Ah
operacion db 0Dh,0Ah,0Ah,"Proporcione un número: $",0Dh,0Ah
resultado db 0Dh,0Ah,0Ah,"El resultado es: $",0Dh,0Ah
num_buffer db 20 DUP ('$') ; Buffer to store the input and output numbers as strings
.code
imprimir macro string
mov dx, offset string
mov ah, 9
int 21h
endm
escribir macro
mov ah, 2
int 21h
endm
; Input and output procedures for decimal numbers
FLOAT_INPUT macro
finit
lea dx, num_buffer
mov ah, 0Ah
int 21h
fld num_buffer
endm
FLOAT_OUTPUT macro
finit
fstp num_buffer
lea dx, num_buffer
mov ah, 9
int 21h
endm
; Code
mov ax, @data
mov ds, ax
inicio:
imprimir menu
call decEt
jmp inicio
decEt:
call CLEAR_SCREEN
imprimir menu2
call decProc
cmp cx, 1
je sumaEt
cmp cx, 2
je restEt
jmp finDec
sumaEt:
call suma
jmp finDec
restEt:
call resta
jmp finDec
finDec:
ret
decProc proc near
call CLEAR_SCREEN
imprimir menu2
call decProc
cmp cx, 1
je sumaEt
cmp cx, 2
je restEt
jmp finDec
decProc endp
suma proc near
imprimir operacion
FLOAT_INPUT
fstp num1
imprimir operacion
FLOAT_INPUT
fstp num2
imprimir resultado
fld num1
fadd num2
FLOAT_OUTPUT
ret
suma endp
resta proc near
imprimir operacion
FLOAT_INPUT
fstp num1
imprimir operacion
FLOAT_INPUT
fstp num2
imprimir resultado
fld num1
fsub num2
FLOAT_OUTPUT
ret
resta endp
DEFINE_CLEAR_SCREEN
END
.exit
Comentarios sobre la versión: Emu8086 (0)
No hay comentarios