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
.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
xor eax, eax
ret
reverse_num:
push ebp
mov ebp, esp
push ebx
push esi
mov esi, [ebp + 8]
xor ebx, ebx
.rev_loop:
test esi, esi
jz .done
mov eax, esi
xor edx, edx
div dword [ten]
imul ebx, ebx, 10
add ebx, edx
mov esi, eax
jmp .rev_loop
.done:
mov eax, ebx
pop esi
pop ebx
pop ebp
ret