Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .data
- digits: times 10 dd 0
- fmt: db "Digit %d: %d", 10, 0
- section .text
- global CMAIN
- extern printf
- CMAIN:
- mov ebp, esp; for correct debugging
- GET_DEC 4, eax
- cnt_loop:
- xor edx, edx
- mov ecx, 10
- div ecx
- mov ecx, dword[digits+4*edx]
- inc ecx
- mov dword[digits+4*edx], ecx
- cmp eax, 0
- jg cnt_loop
- xor eax, eax
- print_loop:
- mov ebx, dword[digits+4*eax]
- cmp ebx, 0
- je print_skip
- push ebx
- push eax
- push dword fmt
- call printf
- pop eax ; pop format argument
- pop eax
- pop ebx
- print_skip:
- add eax, 1
- cmp eax, 10
- jl print_loop
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement