-2
我想用Irvine32庫的彙編語言輸入用戶的兩個數字,但不知道如何。這是我迄今爲止:用匯編語言輸入數字
INCLUDE Irvine32.inc
.data
number1 WORD
number2 WORD
.code
main PROC
exit
main ENDP
END main
我想用Irvine32庫的彙編語言輸入用戶的兩個數字,但不知道如何。這是我迄今爲止:用匯編語言輸入數字
INCLUDE Irvine32.inc
.data
number1 WORD
number2 WORD
.code
main PROC
exit
main ENDP
END main
我不熟悉irvine,但如何編寫自己的輸入和解碼程序?
DOS中間體21/A讀取從標準輸入線,並把公司到您的緩衝區
從ASCII解碼註冊是一個更棘手的;你必須走thoug每個數字,並添加它們逐一移位了短路電流值
這裏是一個辦法,只是有一個想法: (對不起,語法,最多不兼容於MASM,我還是用埃裏克·艾薩克森的A86彙編程序)
.org 0100
JMP start
buffer: db 10," " ; space for 10 digits
; read input to buffer
input: mov ah, 0ah ; input value
mov dx, buffer
int 21h
ret
; decode buffer to CX
decode: mov dx,0
mov si, buffer+2
mov cl, [buffer+1] ; while (numChars>0)
decLoop: cmp cl,0
je decEnd
mov ax, dx ; mul DX by 10
shl ax, 2
add ax, dx
shl ax, 1
mov dx, ax
mov al,[si] ; get current digit
inc si ; and point to next one
sub al,'0'
mov ah, 0
add dx, ax ; add the digit read
dec cl ; numChars--
jmp decLoop
decEnd: ret
; main()
start: call input
call decode
push dx
call input
call decode
pop cx
; CX now holds first, DX second number
; feel free to do with em what you feel like
int 20h ; quit
Irvine32.inc包含所有可用函數的列表以及解釋函數用途的簡短註釋。 – Michael