extern io_get_udec, io_print_udec, io_print_string, io_newline
section .data
yes_str db 'Yes', 0
no_str db 'No', 0
ten dd 10
section .text
global main
main:
push ebp
mov ebp, esp
push ebx
push esi
push edi
call io_get_udec
mov esi, eax
call io_get_udec
mov edi, eax
.loop:
test edi, edi
jz .check
push esi
call reverse_num
add esp, 4
add esi, eax
dec edi
jmp .loop
.check:
push esi
call reverse_num
add esp, 4
cmp eax, esi
jne .no
mov eax, yes_str
call io_print_string
call io_newline
mov eax, esi
call io_print_udec
call io_newline
jmp .finish
.no:
mov eax, no_str
call io_print_string
call io_newline
.finish:
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
xor eax, eax
ret
reverse_num:
push ebp
mov ebp, esp
push ebx
push esi
push edi
mov esi, [ebp + 8]
xor edi, edi
mov ebx, 10
.rev_loop:
test esi, esi
jz .done
mov eax, esi
xor edx, edx
div ebx
imul edi, edi, 10
add edi, edx
mov esi, eax
jmp .rev_loop
.done:
mov eax, edi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret