Hello, I'm new to these forums, and have just started programming in assembly.
I wrote a small program to print out the first command line argument, and it's not working. It goes like this:
section .data empty db "The pointer was null",10,0 section .text global _start _start: mov rcx, [rsp + 16] mov rbx, 1 mov rdx, 40 mov rax, 4 int 80h end: mov rax, 1 int 80h error_message: mov rcx, empty mov rbx, 1 mov rdx, 22 mov rax, 4 int 80h jmp end
When I compile and run that, it just runs - no segmentation fault or anything, just runs. and it doesn't print out the first command line argument.
However, I tried using rep movsb to use the address in rcx to put the string in a buffer, like this(with 40 bytes reserved in section .bss for text):
mov rsi, rcx mov rdi, text mov rcx, 40 rep movsb
When I used linux syscalls to print out the 'text' buffer, It printed out the first argument, no problem. Why won't the above example work?
thanks in advance for any help.