我想從另一個例程打印argv[1]
(在C terminallogy中),而不是從啓動例程(即入口點)打印。但它給了一個seg故障:爲什麼這給出了seg故障?
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
有人可以解釋它嗎?
這是功課嗎? – fons 2013-02-14 01:15:24
編號:(真的好像? – Jack 2013-02-14 01:20:09