Douglas,

>If anyone can shed some light on this one, I'd be much obliged:
>
>Here's the disassembly from CW IDE:
>
>                               // Check that we have the correct ROMS.
>    suba.l    a2,a2
>                       error = RomVersionCompatible( 0x02000000,
>inLaunchFlags );
>    move.w    d6,-(a7)
>    move.l    #33554432,-(a7)
>    pea       *+16           ; 0x00000034
>    pea       *+6            ; 0x0000002e
>    addi.l    RomVersionCompatible__FUlUs,(a7)
>    rts
>    move.l    d0,d3
>                       if ( error == sysErrRomIncompatible ) { goto
>ErrorExit; }

This looks like the code I see when the compiler is setting up for a long
(> 32K) jump. Note that if you're calling a routine that it hasn't "seen"
(not defined yet) then it doesn't know whether the call will be a regular
jump, a long jump, or an A5-relative intersegment call. This isn't known
until either the routine occurs subsequently in the same file, or the
linker resolves it. The addi.l of RomVersionCompatible__FUlUs is the
placeholder for where the appropriate offset (if it is located inside of
the same segment) needs to get stuffed.

>Here's the same disassembly from the Debugger targeting POSE/Mac:
>
>
>                               // Check that we have the correct ROMS.
>                       error = RomVersionCompatible( 0x02000000,
>inLaunchFlags );
>1006F8DE: 3F06            move.w   d6,-(sp)
>1006F8E0: 2F3C02000000    move.l   #33554432,-(sp)
>1006F8E6: 600A            bra.s    *+12                    ; 0x1006f8f2
>1006F8E8: 2000            move.l   d0,d0
>1006F8EA: 2000            move.l   d0,d0
>1006F8EC: 2000            move.l   d0,d0
>1006F8EE: 2000            move.l   d0,d0
>1006F8F0: 2000            move.l   d0,d0
>1006F8F2: 4EADFBC8        jsr      -1080(a5)
>1006F8F6: 2600            move.l   d0,d3
>                       if ( error == sysErrRomIncompatible ) { goto
>ErrorExit; }
>1006F8F8: 0C830000050C    cmpi.l   #1292,d3
>1006F8FE: 5C4F            addq.w   #6,sp
>1006F900: 67000134        beq.w    *+310                   ; 0x1006fa36

This is the result after the linker has done its job - namely figuring out
that you've got an interseg jump, and thus it needs to use an A5-relative
jump table. Since space has already been allocated for the long jump
instructions by the compiler, all the linker can do is fix things up in
place. The only surprise here for me is that it doesn't set the
instructions to NOPs versus MOVE.L D0,D0

>BUT,  The code does not work.  the following line takes the code into lala
>land:
>
>1006F8F2: 4EADFBC8        jsr      -1080(a5)

This will fail if you're calling RomVersionCompatible in response to a
launch code which you receive when your A5 world isn't set up. The basic
rule is that all the code you use during a sub-launch call must be located
in the main segment, thus only routines called from the standard launch
code can be moved into other segments.

-- Ken

=======================
Ken Krugler
TransPac Software, Inc.
http://www.transpac.com
+1 530-470-9200


Reply via email to