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 ebx
push esi
push edi
call io_get_udec
mov esi, eax
call io_get_udec
mov edi, eax
steps_loop:
test edi, edi
jz check_result
push esi
call reverse_num
add esp, 4
add esi, eax
dec edi
jmp steps_loop
check_result:
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
call io_newline
xor eax, eax
jmp finish
print_no:
mov eax, no_str
call io_print_string
call io_newline
xor eax, eax
finish:
pop edi
pop esi
pop ebx
ret
reverse_num:
push ebp
mov ebp, esp
push ebx
push ecx
push edx
mov eax, [ebp + 8]
xor ebx, ebx
rev_loop:
test eax, eax
jz rev_done
xor edx, edx
div dword [ten]
imul ebx, ebx, 10
add ebx, edx
jmp rev_loop
rev_done:
mov eax, ebx
pop edx
pop ecx
pop ebx
pop ebp
ret