当我在我的2个变量上输入数字时,我认为它没有读取它,所以mov
有0值。为什么打印num始终为零emu8086
没问题编译。
这里是我的代码:
include 'emu8086.inc'
org 100h
define_print_string
define_scan_num
define_print_num
define_print_num_uns
define_clear_screen
.model small
.data
;data
a db "oops",0
b db 0dh,0ah,"enter first number: ",0
c db 0dh,0ah,"the sum is :",0
d db 0dh,0ah,"Press 1 if adiition",0
e db 0dh,0ah,"Press 2 if subtraction",0
f db 0dh,0ah,"the diffirence is: ",0
g db 0dh,0ah,"enter second number: ",0
h db 0dh,0ah,"",0
num1 dw 0
num2 dw 0
result dw 0
;code
.code
start:
lea si,a
call print_string
lea si,d
call print_string
lea si,e
call print_string
mov ah,1
int 21h
cmp al,'1'
je addi
cmp al,'2'
je subt
cmp al,'?'
je start
;input number 1
proc enter1
lea si,b
call print_string
call scan_num
mov ax,num1
ret
endp enter1
;input number 2
proc enter2
lea si,g
call print_string
call scan_num
mov bx,num2
ret
endp enter2
addi:
call enter1
call enter2
add ax,bx
lea si,h
call print_string
lea si,c
call print_string
call print_num
subt:
end1:
end
请正确格式化您的代码。在每一行前面放四个空格。 – fuz
在你的'enterX'程序中,你从'num1'和'num2'设置'ax'和'bx'。你用零初始化的变量,永远不会再写入。了解如何[scan_num(https://github.com/AhmadNaserTurnkeySolutions/emu8086/blob/master/inc/emu8086.inc)的作品。跳过与格式的问题,而不是制造[MCVE]你应该处理更大的问题*现在*是你的代码是不可读(坏的格式和程序都在中间)和严重的结构('enter1'和'enter2'是*相同*程序)如果我是你的老师,我会立即失败,看到它,当然,修复它。 –
谢谢,它只是可能我们的教授不能解释宏(定义)一个和那个斧头,BX的东西。我的老师认为我们可以做到这一点,仅仅是因为我们的一位同学是先进的(他重复了8086个科目)做到了。我无法理解他的代码如何工作。 – wendellex