It takes in a string from the command line. prints out the length of the string.
I'm mostly looking for tips and general convention suggestions
But I'm open to any other criticism also.
Roast it please thanks.
global _start
extern printf
section .data
arg_err db `Invalid Arg Length\n\0`
len_arg_err equ $ - arg_err
arg_frmt db `%d\n\0`
section .text
_start:
mov ecx, DWORD [esp]
cmp ecx, 2
jne _error_ext ; Args != 2?
mov eax,DWORD [esp+8] ;char** argv
mov ecx, eax
_label:
mov dl, byte [ecx]
cmp dl, 0; read byte and comp to 0
je _exit
add ecx, 1
jmp _label
_exit:
sub ecx,eax ; subtract end addr from start addr
push ecx
push arg_frmt
call printf
mov eax, 1
int 0x80
_error_ext:
mov ecx, arg_err
mov edx, len_arg_err
call _print
mov eax, 1
int 0x80
_print: ; needs ecx as char* edx as char* len
push eax
push ebx
mov eax, 4
mov ebx, 1
int 0x80
pop ebx
pop eax
retn
repnz
prefix. This answer is a good starting point. \$\endgroup\$