Assembly 用汇编语言输入数字
我试图使用Irvine32库用汇编语言从用户输入两个数字,但不知道如何输入。这就是我到目前为止所做的:Assembly 用汇编语言输入数字,assembly,x86,masm,irvine32,Assembly,X86,Masm,Irvine32,我试图使用Irvine32库用汇编语言从用户输入两个数字,但不知道如何输入。这就是我到目前为止所做的: INCLUDE Irvine32.inc .data number1 WORD number2 WORD .code main PROC exit main ENDP END main 我对欧文不熟悉,但是自己编写输入和解码例程怎么样 DOS int 21/a从stdin读取一行,并将其放入缓冲区 从ascii码到寄存器的解码是一个复杂的过程,但更复杂;您必须遍历每个数字,并通过移
INCLUDE Irvine32.inc
.data
number1 WORD
number2 WORD
.code
main PROC
exit
main ENDP
END main
我对欧文不熟悉,但是自己编写输入和解码例程怎么样 DOS int 21/a从stdin读取一行,并将其放入缓冲区 从ascii码到寄存器的解码是一个复杂的过程,但更复杂;您必须遍历每个数字,并通过移动当前值逐个添加它们 这里有一个方法,只是想了解一下: (很抱歉,max与masm不兼容,我仍然使用Eric Isaacson的A86汇编程序)
Irvine32.inc包含所有可用函数的列表以及解释函数用途的简短注释。
.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