PDA

View Full Version : Newbie Segmentation fault question.



manjaba
August 7th, 2011, 03:50 PM
Not sure why I'm getting the Segmentation fault statement on this program which runs ok:

#HelloWorld.s my second assembly program

.data

HelloWorldString: #label
.ascii"Hello World\n"

.text

.globl _start

_start:
#load all the arguments for write()

movl $4, %eax
movl $1, %ebx
movl $HelloWorldString, %ecx
movl $12, %edx
int $0x80

Thanks

Zugzwang
August 7th, 2011, 04:19 PM
Hmmm, there should be some code to terminate the program after you print out "Hello World".

johnl
August 7th, 2011, 04:25 PM
You are not terminating your program correctly.

You need something like the following at the end.


movl $1, %eax ;; syscall 1 is exit()
movl $0, %ebx ;; argument to exit
int $0x80 ;; do it