Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; constants
- cr equ 13 ;carriage return
- lf equ 10 ;linefeed
- section .bss
- num resb 1
- tall resb 1
- section .data
- en db "1"
- crlf db cr,lf
- crlflen equ $ - crlf
- section .text
- global _start
- _start:
- mov ecx, 12
- mov eax, '1'
- l1:
- mov [num], eax ;num = value of eax
- mov eax, 4 ;sys_write
- mov ebx, 1 ;stndout
- push ecx ;push 12 to stack
- mov ecx, num ;save num in ecx (msg to write)
- mov edx, 1 ;length
- int 0x80 ;execute all previous
- call newline
- mov eax, [num] ;eax = value of num
- sub eax, '0' ;convert to number
- inc eax ;increase eax with +1
- cmp eax, 10
- jge tosiffer
- add eax, '0' ;convert to ascii
- pop ecx ;pop 12 from stack
- loop l1
- tosiffer:
- call skriven
- mov eax,'0'
- tiltolv:
- mov [tall], eax
- mov ecx, tall
- mov edx,1
- mov ebx,1
- mov eax,4
- int 0x80
- call newline
- call skriven
- mov eax, [tall]
- sub eax,'0'
- inc eax
- cmp eax, 3
- jge done
- add eax,'0'
- loop tiltolv
- skriven:
- mov edx,1
- mov ecx,en
- mov ebx,1
- mov eax,4
- int 0x80
- ret
- newline:
- mov edx,crlflen
- mov ecx,crlf
- mov ebx,1
- mov eax,4
- int 0x80
- ret
- done:
- mov eax,1 ;sys_exit
- int 0x80 ;execute all previous
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement