Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .text
- global _start:
- _start:
- push hw ; get the length to edx
- call strlen
- ; call the print function
- push hw ; message
- push edx ; length from strlen
- call printout
- ; call end of the programm function
- call endprogram
- section .data
- hw db "hello world, blyat!", 0
- strlen:
- pop ebx ; save the ret adress
- pop edx ; get the msg to the data-register
- push ebx ; get back the ret adress
- mov ecx, 0 ; counter
- _loop:
- inc ecx
- cmp byte[edx+ecx], 0
- je end ; if end-byte found
- inc ecx
- loop _loop ; if not found
- end:
- mov edx, ecx; push the result into data-register
- ret ; get back!
- printout:
- pop ebx ; save the ret adress
- pop edx ; get the length 2nd arg
- pop ecx ; get the message 1st arg
- push ebx ; push it back
- mov eax, 4 ; set up print
- mov ebx, 1 ; to the console output
- int 0x80 ; print it
- ret ; get back
- endprogram:
- mov eax, 1 ; exit instruction
- mov ebx, 0 ; error code
- int 0x80 ; call the interruption
Advertisement
Add Comment
Please, Sign In to add comment