Re: Asm question (port from linux ppc)
Re: Asm question (port from linux ppc)
- Subject: Re: Asm question (port from linux ppc)
- From: Jonas Maebe <email@hidden>
- Date: Sat, 27 Nov 2004 13:35:06 +0100
On Nov 27, 2004, at 05:03, email@hidden wrote:
$cat setsp.s
.globl _setstack
_setstack:
lis 1, newstackptr@ha
lwz 1, newstackptr@l(1)
blr
.align 4
% cc setsp.S
setsp.s:5:Parameter syntax error (parameter 1)
setsp.s:5:Invalid mnemonic 'ha'
setsp.s:6:Parameter syntax error (parameter 2)
setsp.s:6:Invalid mnemonic 'l(r1)'
What the correct code on Darwin is depends. If newstackptr is simply a
global variable in another object file and you're compiling without
PIC, then you can use code like this:
---
.text
.globl _setstack
_setstack:
lis r3,ha16(_newstackptr)
lwz r1,lo16(_newstackptr)(r3)
blr
---
(note that r1 must always be valid and thus mist always changed using a
single instruction under any PPC ABI I know of; your original linux
code is wrong in that respect)
If it's a variable imported from another shared library or if you're
compiling PIC code, then you need something like this:
---
.text
.globl _setstack
_setstack:
lis r3,ha16(L_newstackptr$non_lazy_ptr)
lwz r3,lo16(L_newstackptr$non_lazy_ptr)(r3)
lwz r1,0(r3)
blr
.data
.non_lazy_symbol_pointer
L_newstackptr$non_lazy_ptr:
.indirect_symbol _newstackptr
.long 0
---
In general, check the output of "gcc -S somefile.c" to see how things
are done under Darwin/Mac OS X.
Jonas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden