Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Output in a bit more true assembly
;nasm 2.11.08 section .data theString1: db 'Small example of using calls instead of waterfalling code',0Ah,00 ; String with linefeed(hex) and zero terminator theString2: db 'This is the second string that is drawn by a call and NOT a newline!',10d,00 ; String with linefeed(dec) and zero terminator section .text global _start _start: push theString1 call _lenght ; No absolute values, just calculate the lenght of string push theString2 call _lenght mov eax,1 ; The system call for exit (sys_exit) mov ebx,0 ; Exit with return code of 0 (no error) int 80h _lenght: mov ecx,[rsp+8h] ; retrieve argument from the stack xor edx,edx ; lenght of string _loop: cmp byte [ecx],0 ; check for the terminator je _writeline ; if true, write line inc ecx ; address inc edx ; lenght of string + 1 jmp _loop _writeline: sub ecx,edx ; restore our offset by substracting lenght mov eax,4 ; The system call for write (sys_write) mov ebx,1 ; File descriptor 1 - standard output int 80h ; Call the kernel ret 8 ; return and pop 8 bytes extra (push in 64 bit = 8 bytes)
run
|
edit
|
history
|
help
1
p2.asm
sub
dsafdfsdafds
intfunct_64.asm
Assembly : Allocating Storage Space
calculate_age
Hello
mortgage
sdfafdsfds
fdsaffdsfsd