我對8086程序集非常陌生,請原諒那些草率的代碼和可能不必要的行,我是自學的。這段代碼是我正在製作的另一個程序的一部分,它需要用戶輸入數字。這些具體的行接受輸入,然後產生一個電腦實際可以使用的數字。例如,採取5,4和3,並「編譯」數字到543.從內存中將正確的值加載到8086程序集的寄存器中
問題出現在第59行,在那裏我嘗試從內存加載一個數字註冊bx,在這種情況下,而不是加載正確的數字,如40(從前543),它只是加載一個1.
59行後的一些代碼可能不工作,因爲我卡在那裏。
我可能沒有使用正確的寄存器,但是我自學成才並且很難找到關於在線語法的簡單易懂的信息。
org 100h
mov si, 100d
input1:
mov ah, 1h ;input char
int 21h
push ax
sub al, 30h ;convert ascii to integer
mov dl, al ;put char into dl to be read
mov [si], al ;save char to ram for later
mov ah, 2h ;output char
inc si ;to save on next location in mem
pop ax
cmp al, 13 ;check if done
jne input1
dec si ;insert terination char
dec si ;decrement to save value of si for multilying by ten
push si ;save current si value
inc si ;then continue
mov al, 24h
mov [si], al
pop si
mov cx, 1
compileNum1:
mov ax, 0
mov bx, 0
mov dx, 0
.fixNum:
mov al, [si] ; load last num into ax to be multiplied by 10
mul cx
mov bp, ax
mov [si], bp
dec si
mov al, 10
mov bx, cx
mul bl
mov cx, ax
cmp si, 99d
jne .fixNum
mov si, 100d ;starts number addition
mov ax, [si] ;loads first number
inc si ;prepares second
mov bx, [si] ;loads second
cmp bx, 24h ;checks if there was only 1 number
je .terminate1 ;if there was, goto terminate
add ax, bx ;else add them together
.stloop1:
inc si ;prepares for third, fourth etc
mov bx, [si] ;loads it
cmp bx, 24h ;checks if numbver is 3 digts ot more long (depends on loop)
je .terminate1 ;terminate if so
add ax, bx ;add them together, store in ax
.terminate1:
mov [100d], ax
mov ax, 0 ;clear screen
int 10h
mov ah, 2h ;print char
int 21h
mov ah, 0
int 16h
ret
感謝您的幫助!
就是這樣!非常感謝! –