DEV Community

Discussion on: I'm an Expert in Memory Management & Segfaults, Ask Me Anything!

Collapse
 
klapauciusisgreat profile image
klapauciusisgreat

Yes, I'm sure. However, I made some progress:

in the original 32 bit code, I had an instruction like:

        mov $cold_start,%esi    // Initialise interpreter.      

that would work on macos (32 bit)

I found a 64 bit port somewhere that was instead using

    mov $cold_start,%rsi    // Initialise interpreter.

which is what I expected, but the apple clang assembler does not like this syntax because in 64 bit mode I have to use position independent addressing modes.

So I tried

mov cold_start(%rip),%rsi       // Initialise interpreter.  

but it seems that derefences cold_start instead of just putting the address in. Using $cold_start(%rip) gives errors.

I guess I just don't understand the apple assembler syntax esp for 64 bit code. Looking ...