pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pgubook-readers] functions


From: George Nyoro
Subject: [Pgubook-readers] functions
Date: Sat, 11 Jan 2014 12:20:58 +0300

Hey again,
Sorry for the barrage of questions.
I am now trying function power. But I am getting segmentation faults with my own code and couldn't trace the error so I tried to reduce it till I could locate it.
The reduced format is this:

.code32
.section .data
.section .text
.globl _start

_start:
    pushl $3
    pushl $2
    call power
    movl %eax, %ebx
    addl $8, %esp
    movl $1, %eax
    int $0x80

.type power,@function
power:
pushl %ebp
movl %esp, %ebp

movl %ebp, %esp
popl %ebp
movl $5, %eax
ret

When I remove the line in bold, it compiles alright and gives me the right result but when I include the offending line, it gives me an error of segmentation fault. Why does this happen? Does it mean my processor does not allow one to directly manipulate the %esp value?
Thanks again.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]