參考資訊:
https://stackoverflow.com/questions/39377570/printing-argv-with-nasm
main.s
global main extern printf section .data fmt db "argc:%d, argv[0]:%s, argv[1]:%s", 10, 0 section .text main: push ebp mov ebp, esp mov eax, dword[ebp + 8] mov ebx, dword[ebp + 12] push dword [ebx + 4] push dword [ebx + 0] push eax push fmt call printf xor eax, eax mov esp, ebp pop ebp ret
編譯、執行
$ nasm -f elf32 main.s $ i686-linux-gnu-gcc main.o -o main -static $ qemu-i386 ./main test argc:2, argv[0]:./main, argv[1]:test