Code: Select all
section .text
global _start
_start:
pop ecx
pop ecx ; something along the lines of ./a.out
mov eax, 4
mov ebx, 1
mov edx, 20
int 0x80
...
So now I've tried this:
Code: Select all
section .text
global _start
_start:
pop eax
call printargv
mov eax, 1
mov ebx, 0
int 0x80
printargv:
pop esi
pop esi
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, msglen
int 0x80
.start
lodsb
or al, al
jz .done
mov ebx, 1
mov ecx, eax
mov eax, 4
;mov byte [buffer], al
;mov ecx, [buffer]
mov edx, 1
int 0x80
jmp .start
.done
ret
section .bss
buffer resb 1
section .data
msg db 'Entering printargv...', 13, 10, 0
msglen equ $-msg
The way I'm doing this probably looks weird, but thats because I'm adapting some code that talks to the BIOS to write code out character by character. How can I go through a string character by character in 32-bit code? Is there a better way to print out the command line arguments using assembly?
Just in case it's useful to anyone this is using the nasm assember.