At 10:45 AM -0800 1/26/01, Wang Yan-FYA009 wrote:
>Hi, morning,
>
>I'm trying to call a C function from my assembly function. The code is like this:
>
>asm void foo() {
>       ...
>
>       jmp     TestC
>}
>
>UInt16 TestC(const Char *inText)
>{
>}
>
>But it can't work. Always jump to some unknow address. I checked disassemble
>of my asm function is like this, which looks fine.
>
>       jmp     TestC
>0000000C: 4EF9 0000 0000     jmp       TestC__FPCcUlPUs
>
>But when I debug to the jmp TestC in asm foo(), the code is 4E40000018A0
>which is a word jump to 18A0!

OK --

There's several things going on here.

First off, when the assembler sees a "jmp TestC" it does, emits a
jump instruction with a placeholder for the offset. That's because the
assembler has no idea where 'TestC' will end up in the final binary. It is
the linker's job to fix that.

This matches what you see in the object code (4EF9 0000 0000) and in the
executable (JMP 18A0).

Secondly, the code that you report (4E40 0000 18A0), isn't a jump instruction
at all, but rather a "Trap #0" instruction. I expect that you are setting a breakpoint
there, and that's what you are seeing. Set the breakpoint a few instructions before
the jump, and see what happens.


Thirdly, I suspect that what you really want there is not a JMP, but rather a JSR.
-- 
-- Marshall

Marshall Clow     Idio Software   <mailto:[EMAIL PROTECTED]>

"Perhaps it IS a good day to Die!  I say we ship it!"
-- Klingon Software Developer

-- 
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