extern io_get_udec, io_print_udec, io_print_string, io_newline
section .data
yes_str db 'Yes', 0
no_str db 'No', 0
section .text
global main
main:
call io_get_udec
mov esi, eax
call io_get_udec
mov ecx, eax
step_loop:
test ecx, ecx
jz done_steps
push esi
call reverse_num
add esp, 4
add esi, eax
dec ecx
jmp step_loop
done_steps:
push esi
call reverse_num
add esp, 4
cmp eax, esi
jne print_no
mov eax, yes_str
call io_print_string
call io_newline
mov eax, esi
call io_print_udec
ret
print_no:
mov eax, no_str
call io_print_string
ret
reverse_num:
push ebp
mov ebp, esp
push ebx
push esi
mov ebx, [ebp + 8]
xor esi, esi
rev_loop:
test ebx, ebx
jz rev_done
mov eax, ebx
xor edx, edx
mov ecx, 10
div ecx
imul esi, esi, 10
add esi, edx
mov ebx, eax
jmp rev_loop
rev_done:
mov eax, esi
pop esi
pop ebx
pop ebp
ret