我想argv[1]
从另一个例程而不是从启动例程(这是入口点)打印(在 C 终端学中)。但它给出了一个段错误:
format ELF executable 3
entry start
segment readable executable
start:
pop ebx ;argc
pop ebp ;argv[0]
call printarg
;; exit
xor ebx,ebx
mov eax,1
int 80h
printarg:
pop ebp ;argv[1]
call puts
ret
puts:
pusha
mov eax,ebp
xor edx,edx
;; get string length
.loop1:
cmp byte [eax],0
je .loop2
inc eax
inc edx
jmp .loop1
;; print it
.loop2:
mov eax,4
mov ebx,1
mov ecx,ebp
int 80h
;print a new line
mov eax,4
mov ebx,1
mov ecx,NL
mov edx,1
int 80h
popa
ret
segment readable writeable
NL db 0xA
有人可以解释一下吗?