What code generation model do you have set?  Is is the Large Model?  According
to the Targeting Palm OS documentation:

Smart Model
-----------
When one function calls another function and the linker is sure they're in the
same segment, this model uses relative addressing (a 16-bit address). Otherwise,
it uses absolute addressing (a 32-bit address).

Small Model
-----------
This model uses relative addressing (a 16-bit address) for all function calls.
Small Model is best for small code resources and applications (under 32K), or
for code resources and applications in which all segments are under 32K.

Large Model
-----------
This model uses absolute addressing (a 32-bit address) for all function calls.
Large Model is useful when you have a source file that generates more than 32K
of code, or when the linker generates an out-of-range link error.

I found these descriptions to be accurate in my limited testing here.  I wrote a
small program that called two functions: one in the same segment (actually, the
same translation unit) and another in a different segment.  Compiling for Smart
Model, the far function generated the long instruction sequence, and the near
function used just a JSR.  Compiling for the Large Model, both calls used the
long sequence.

Functions in the same segment but different translation unit will also generate
the long sequence.

You can check the resulting (linked) object code by using CodeWarrior to Debug
your application.  Put a breakpoint on the code in question, run your
application to that point, switch the debugger over to Assembly or Mixed mode,
and examine the result.

-- Keith Rollin
-- Palm OS Emulator engineer








Ioi Lam <[EMAIL PROTECTED]> on 01/16/2001 06:46:51 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  Ioi Lam <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  How to see real disassembled code in Code Warrior



Hi,

I am looking at the "disassemble" view of a file, which makes a function
call foo(param). CW gives me the same output regardless of which segment
the foo() function is at. I though if foo() lives in a different segment
than the caller, wouldn't the instructions be different?

                foo(param);
                TraceMethodExit(thisMethod);
    move.l    a2,-(a7)
    pea       *+16           ; 0x00000b4c
    pea       *+6            ; 0x00000b46
    addi.l    invokeNativeFunction,(a7)
    rts

Is there a way to look at the assembler code after the final link stage?

Thanks!

- Ioi Lam





-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to