%include "asm_io.inc"
segment .data
segment .bss
argument resb 32 ; argument[32]
segment .text
global main
main:
enter 0,0
mov ebx, 4
mov ecx, dword [ebp + 4 * ebx]
mov eax, dword [ecx + 4]
mov [argument], eax
mov al, byte [argument + 0]
sub al, 48
call print_int
end: leave
mov eax, 0
ret
i am trying to convert string from command line to integer(for example, when i type $./Hello 30 at command line, '30' has to be the integer parameter for program(procedure)). After finding that [argument + 0] == '30', [argument + 1] = bin/bash, i thought i can get the right number with [argument + 0]. but the result is like -1075579555.
Even a little comment, it would be very helpful. thank you
mov al, byte [argument + 0]doesn't zero the upper bytes of EAX. Maybe you wantmovzx eax, byte [ecx]. The store/reload toargumentmakes no sense. The+0and+1you show make sense as EBX values, not as offsets intoargv[1].