當我在我的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