Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .text
- global _start ;must be declared for using gcc
- _start:
- mov edx, 1 ; flag to be used later
- push edx
- mov ecx, 9 ; loop counter - 10 numbers to print for the 1st set
- mov eax, `01\n\0`; load the starting string
- l1:
- push ecx ; save the loop counter
- mov [num], eax ; save the updated string to num
- mov eax, 4 ; prepare to write
- mov ebx, 1 ; to stdout
- mov ecx, num ; from num's address
- add ecx, edx ; +1 if we're in the first set of loops
- ; to skip the 1st byte (the 10s digit)
- push edx
- mov edx, 3 ; total 3 bytes
- int 0x80 ; do the write
- pop edx
- mov eax, [num] ; load num so we can update it
- add eax, 0x100 ; increment 2nd byte (i.e. 1s digit)
- pop ecx ; restore the loop counter
- loop l1
- ; after loops are done
- cmp edx, 0 ; did we just finish the 2nd set?
- je done ; done if we did
- mov ecx, 3 ; if not, set it up - 4 numbers to print this time
- mov edx, 0 ; update the flag & stop skipping the 1st byte when writing
- mov eax, `10\n\0`; new string - 1s place starts at '0', 10s place is '1'
- jmp l1 ; start the 2nd set
- done:
- mov eax,1 ; exit
- int 0x80
- section .bss
- num resb 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement