Callling clib from assembly language
Callling clib from assembly language
- Subject: Callling clib from assembly language
- From: "David N. Williams" <email@hidden>
- Date: Fri, 14 Apr 2006 15:53:29 -0400
- Organization: University of Michigan
I'm porting the assembly language part of a Forth compiler
(kForth) to OS X ppc. This is my first serious attempt at ppc
assembly language programming. I've been using a "simplified"
linkage to clib functions, which is contrasted with the normal
linkage below.
My question is, what are the disadvantages of my approach? I'm
wondering whether I'm going to regret not having done it the
normal way, somewhere down the line!
-- David W.
Here's the gcc 4.0.1 assembly language output for a C call to
sqrt():
----------------------
...
bl L_sqrt$stub
...
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
.align 5
L_sqrt$stub:
.indirect_symbol _sqrt
mflr r0
bcl 20,31,"L00000000001$spb"
"L00000000001$spb":
mflr r11
addis r11,r11,ha16(L_sqrt$lazy_ptr-"L00000000001$spb")
mtlr r0
lwzu r12,lo16(L_sqrt$lazy_ptr-"L00000000001$spb")(r11)
mtctr r12
bctr
.lazy_symbol_pointer
L_sqrt$lazy_ptr:
.indirect_symbol _sqrt
.long dyld_stub_binding_helper
----------------------
Here's what I'm using:
---------------------
.data
kf_sqrt: .long _sqrt
.text
...
addis r2,0,ha16(kf_sqrt)
lwz r0,lo16(kf_sqrt)(r2)
mtctr r0
bctrl
...
---------------------
_______________________________________________
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