Re: Seg Fault



Dotanitis@xxxxxxxxx wrote:
Hello to all,

I'm SPARC newbie and I have tried to run this simple program:

.global main

main:

save %sp, -64, %sp
mov 9, %l0
sub %l0, 1, %o0
sub %l0, 7, %o1
call .mul
nop
sub %l0, 11, %o1
call .div
nop
mov %o0, %l1

mov 1, %g1
ta 0


After I compiled it using gcc (4.1.2) and tried to run the exec - I've
got segmentation error.
This example was taken from the book "SPARC Arch' Assembly language
programming and c" / Richard P.Paul

Thanks.

I'm just guessing here but I think you are referencing an uninitialized variable as a storage address. The line "> mov %o0, %l1" is where I'm guessing that the problem lies. Perhaps the "l1" was supposed to be "11"??

Whether or not I've guessed right about the line of code causing the failure, there is no question that your program is trying to access memory that doesn't belong to you. That's what "segmentation error" or "segmentation fault" means!

.



Relevant Pages

  • Re: Seg Fault
    ... I'm SPARC newbie and I have tried to run this simple program: ... call .div ... got segmentation error. ...
    (comp.unix.solaris)
  • Seg Fault
    ... I'm SPARC newbie and I have tried to run this simple program: ... After I compiled it using gcc and tried to run the exec - I've ... programming and c" / Richard P.Paul ...
    (comp.unix.solaris)