你好!我有一个问题,我希望有人可以帮助我:) 我需要 2 个宏:一个用于读取,另一个用于打印 32 位整数 我有一个周一的项目,但我没有想法 :( 这就是我到现在为止:
Macro for reading:
reads macro x
local r, final
push eax
push ebx
push edx
xor eax,eax
mov ebx, 10
r:
mov ah,1h
int 21h
cmp al,0dh
je final
sub al,48
xor ah,ah
mov edx,eax
mov eax, x
mul ebx
add eax, edx
mov x,eax
jmp r
final:
pop edx
pop ebx
pop eax
endm
Macro for printing:
prints macro number
local decompose, printloop
push ax
push bx
push cx
push eax
push edx
mov bl, 10 ; need to divide by 10 to get the last digit
mov eax, number
mov cx,0
decompose:
mov ah,0
inc cx
div bl ; reminder stored in ah, quotient in al
mov number,eax
add edx,48 ; to convert to char
push edx
cmp number,0 ;the nr=0 means that the loop ends
jnz decompose
printloop: ;loops for as many times as counted before, in cx
pop edx
mov ah,2h ; prints whatever is in dl
int 21h
loop printloop
mov dl,' ' ; the space after a number
mov ah,2h
int 21h
pop edx
pop eax
pop cx
pop bx
pop ax
endm prints