SECTION .text
global _start
_start:
xor al, al ; strlen(esp + 4)
mov ecx, 255
mov edi, [esp + 4] ; edi now points to argv[0]
repnz scasb
mov byte [edi - 1], 0x0A ; replace terminating null with newline
mov edx, edi
mov ecx, [esp + 4] ; ecx now points to argv[0] + "\n"
sub edx, ecx ; edx is now strlen(esp + 4) + 1 (because newline)
mov eax, 4 ; sys_write 32-bit ABI
mov ebx, 1 ; to stdout
int 0x80
mov eax, 1 ; sys_exit 32-bit ABI
mov ebx, 0 ; no error
int 0x80