*-----------------------------------------------------------------------*
*       Fix each task's exit vector to point to ram version             *
*-----------------------------------------------------------------------*

checkcpu:
        moveq   #0,d4           ;d4 = 0, offset for fixptrs
        move.w  296(a6),d5      ;AttnFlags = 0 if cpu is 68000, set cond.
        beq.s   fixptrs         ;branch if cpu is 68000
        moveq   #4,d4           ;d4 = 4 if not 68000

fixptrs:
        lea     tasks,a4        ;a4 = address of task list
        bsr.s   nextset         ;a3 = tc_SPReg for listed task
        move.l  $46(a3,d4),a2   ;a2 = finalPC, td code that task exits to
        sub.l   d2,a2           ;a2 = offset of code from start (d2) in rom
        add.l   a2,a5           ;a5 = corresponding address in ram copy

        jsr     _LVODisable(a6)
        move.l  a5,$46(a3,d4)   ;replace corrected finalPC pointer
        jsr     _LVOEnable(a6)

fixloop:
        bsr.s   nextset
        beq.s   exit            ;exit on a1 = 0 (address next listed task)
        jsr     _LVODisable(a6)
        move.l  a5,$46(a3,d4)   ;replace corrected finalPC pointer
        jsr     _LVOEnable(a6)
        bra.s   fixloop

