Helo there! I have a problem and i hope somebody can help me:) I need 2 macros: one to read and the other one to print a 32 bit integer I have a project for monday and I'm out of ideeas :( This is what I have until now:
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