21Fermer23
PpHdLe 15/06/2004 à 15:16
New version (bisbis):
newLine1111:
        movem.l d0/a0-a3,-(sp)
        move.l  (4*5+2)(sp),a0                  ; Crash address
        move.w  (a0)+,d0                        ; Crash code
        subi.w  #$F800,d0                       ; Check
        bls.s   crash_handler
        move.l  a0,a1                           ; Copy to a1
        adda.l  (a0)+,a1                        ; Get jump address if opcode JMP or JSR
        lea     \JumpPatch2(pc),a2              ; Patch return address 
        move.l  a2,a3                           ; Copy return address
        cmpi.w  #$FFF1-F800,d0                  ; Check if JMP
        beq.s   \DoJsr                          ; Yes
        subq.l  #\JumpPatch2-\JumpPatch1,a3     ; Fix patch address since it is like JSR
        cmpi.w  #$FFF0-F800,d0                  ; Check if JSR
        beq.s   \DoJsr                          ; Yes => Jsr (return: a0 go: a1 handler:a3)
        subq.l  #4,a0                           ; Fix a0 ptr (it has been increased by 4)
        cmpi.w  #$FFF2-F800,d0                  ; Check if BIG ROMCALL
        bne.s   \NoBigRomCall
                move.w  (a0)+,d0                ; Read new # of romcalls
                lsr.w   #2,d0                   ; /4 since we want the real #, not the offset
\NoBigRomCall:
        move.l  ($C8).w,a1                      ; Get romcall base
        cmp.w   -(a1),d0                        ; Check overflow
        bcc.s   crash_handler
        lsl.w   #2,d0                           ; index x4
        move.l  2(a1,d0.w),a1                   ; Get romcalls
\DoJsr  move.l  a0,\JumpPatch1+2-\JumpPatch2(a2); Return address
        move.l  a1,\JumpPatch2+2-\JumpPatch2(a2); Jump address
        move.l  a3,(4*5+2)(sp)                  ; Go to pea & jmp or to jmp only
        movem.l (sp)+,d0/a0-a3
        rte
\JumpPatch1:    pea     ($123456).l
\JumpPatch2:    jmp     ($789ABC).l