***************************************************************************** Set_IP: cs:push.w CodSource+2 ; cs:push.w CursorPos ; cs:pop.w S_IP ; cs:pop.w S_CS ; pop.w ax ; bra.w _P_Loop1 ; ***************************************************************************** BrkIllegal: pushf.w ;Save the flags. cs:cmp.b #!GETINST, Debug ;Am I Dissassembling code? beq.s _Recover ;Yes, so rescue the debugger! cs:move.b #0, Debug ;Set all debugging as paused. bsr.w ResetBrkPoint ;Restore the break instructions. cs:move.b #!PROG_ILL, Program :Set the flag. cs:pop.w S_FLAGS ;Restore the flags. cs:pop.w S_IP ;Save the Instruction pointer. cs:pop.w S_CS ;Save the code segment. cs:push.w CodeSegment ;Push the debugger segment. cs:push.w #ResetProgReg :Where to return to. bra.s _Illegal_Exit ;Jump to it. _Recover: popf.w ;Restore the flags. cs:pop.l TmpIllegal ;Pop the IP and the Code segment. pusha.l ;Save the registers... push.w ds ;Push DS. cs:move.w TmpIllegal, si ;Get the instrution offset. cs:move.w TmpIllegal+2, ds ;Set the segment to for the IP. bsr.w Get_Inst_Forward ;Get the next instruction. cs:move.w ax, TmpIllegal ;Save it... pop.w ds ;Restore DS. popa.l ;Restore the GP registers. cs:push.l TmpIllegal ;Push the Code segment. _Illegal_Exit: rti *-+-* TmpIllegal ds.w 2 OldIllegal ds.w 2 ***************************************************************************** StepLine: cs:cmp.b #!PROG_PAWS, Program ;Do we have a program? blt.w _No_Program ;Nope... pop.w ax ;Dump the return address. bsr.w _Show_MainScreen ;Show the program screen. cs:move.w #StepRet1-BPR1, BPR1-2 ;Return address A. cs:move.b #2, Debug ;Set instruction step mode. bra.w SetProgReg ;Set the programs registers. StepRet1: cs:push.w S_CS ;Load the programs code segment. cs:push.w S_IP ;Load the instruction pointer. cs:or.b #$01, S_FLAGS+1 ;Set single step mode. cs:push.l S_FLAGS ; popf.l ;Set single step mode. rtsf ***************************************************************************** StepOver: cs:cmp.b #!PROG_PAWS, Program ;Do we have a program? blt.w _No_Program ;Nope... cs:move.w S_CS, ds ;Get the current code segment. cs:move.w S_IP, si ;Set the current offset. bsr.w Get_Inst_Forward ;Calculate the next instruction. cs:move.w ds, CursorPos+2 ;Set the breakpoint segment. cs:move.w ax, CursorPos ;Set the breakpoint offset. move.w ax, si ;Set our work register. bra.s SetRunBrk ;Save some code. ***************************************************************************** RunToCurs: cs:cmp.b #!PROG_PAWS, Program ;Do we have a program? blt.w _No_Program ;Nope... cs:move.w CodSource+2, ds ;Set DS to our Cursor segment. cs:move.w ds, CursorPos+2 ;Save the cursor segment. cs:move.w CursorPos, si ;Set SI to the cursor offset. cs:cmp.w si, S_IP ;Check to see if we are trying bne.s SetRunBrk ;to run to the current position. move.w ds, ax ;Get the CS. cs:cmp.w ax, S_CS ;Compare Code Segments. bne.s SetRunBrk rts SetRunBrk: move.b #$CC, al ;The breakpoint byte. ds:xchg.b al, (si) ;Exchange the bytes. cs:move.b al, CursorPos+4 ;Save the byte. cs:move.b #1, CursorPos+5 ;Set it as a valid breakpoint. bra.s RunTheProg ***************************************************************************** RunProg: cs:cmp.b #!PROG_PAWS, Program ;Do we have a program? blt.w _No_Program ;Nope... RunTheProg: pop ax ;Dump the return address. cs:move.w #RunRet1-BPR1, BPR1-2 ;Return address A. bsr.w _Show_MainScreen ;Show the program screen. bra.w SetProgReg ;Set the programs registers. RunRet1: cs:push.w S_CS ;Load the programs code segment. cs:push.w S_IP ;Load the instruction pointer. cs:and.b #$FE, S_FLAGS+1 ;Mask off the single step bit. cs:push.l S_FLAGS ;Push the saved flags. popf.l ;Set the saved flags. rtsf ***************************************************************************** _No_Program: move.b #1, cl move.w #CANNOTEXEC, dx bra.w DrawInfoBox ***************************************************************************** ChildExit: cs:cmp.b #!PROG_PAWS, Program ;Do we have a program? blt.w ChildClosed ;Yes, so skip this lot. cs:move.b #!PROG_DONE, Program ;Let parent know of change. bra.w ResetProgReg ChildClosed: bra.w Prog_Loop ;Swap screens & save work screen. ***************************************************************************** BreakPnt: intoff ;Just in case. cs:pop.w S_IP ;Save the instruction offset. cs:pop.w S_CS ;Save the instruction segment. cs:push.w CodeSegment ;Set the return segment. push.w #ResetProgReg ;Set the return offset. bsr.w ResetBrkPoint ;Restore the instruction. inton ;Turn interrupts back on. rti ***************************************************************************** Prog_Exit: cs:cmp.b #!PROG_PAWS, Program ;Do we have a program? blt.w Just_Exit ;Nope - so just quit. cs:move.b #0, Program ;Clear program loaded. cs:move.w S_PSP, fs ;Get the programs PSP. fs:move.w cs, $000C ;The segment to return to. fs:move.w #Prog_Exit, $000A ;Set the return address. Just_Exit: move.b #$4c, ah trap #$21 ***************************************************************************** ResetBrkPoint: pushf.w ;Save the flags. pusha ;Save the data registers. push.w es ;Save the extra segment. move.b #!MAX_BREAK, cl ;The maximum breakpoints allowed. move.w #CursorPos, si ;Load our breakpoint list. RBP_Loop: cs:cmp.b #1, 5(si) ;Do we have a breakpoint? bne.s RBP_Next ;No... cs:les (si), di ;Setup the ES:DI combination. cs:move.b 4(si), al ;Get the byte. stos.b ;Restore it. RBP_Next: lea 6(si), si ;Move to the next breakpoint. dec.b cl ;Decrement the count. bne.s RBP_Loop ;Go again if not zero. RBP_Exit: pop.w es ;Restore ES. popa ;Restore the data registers. popf.w ;Restore the flags. rts ***************************************************************************** DOSCall: pushf.w :Save flags. cmp.b #$4C, ah ;Program quitting? beq.s _DOS_Save ;Yes... popf.w ***++++++++++++++++++++++++++++++++++++++*** JmpOld dc.b $EA ;Jmp to the old handler. OldDOSCall ds.w 2 ;Where to jump. ***++++++++++++++++++++++++++++++++++++++*** _DOS_Save: popf.w ;Restore flags. cs:pop.w S_IP ;Save the offset. cs:sub.w #2, S_IP ;Move back to the trap command. cs:pop.w S_CS ;Save the segment. cs:push.w S_CS ;Push the segment back on. cs:push.w S_IP ;Push the offset back on. bra.s JmpOld ;Skip the pop. ***************************************************************************** DivZero: rti ***************************************************************************** BreakAdd: rti ***************************************************************************** SingleStep: pushf.w ;Save the flags. cs:pop.w StackBot ; intoff ;Turn interrupts off. cs:cmp.b #0, Debug ;Are we to set up the instruction? beq.s _StepExit ;No, so skip this lot. cs:dec.b Debug ;Set for instruction catch. bne.s _StepExit cs:pop.w S_IP ;Save the Instruction Pointer. cs:pop.w S_CS ;Save the Code Segment. cs:push.w CodeSegment ;Set the return segment. push.w #ResetProgReg ;Set the return offset. bsr.w ResetBrkPoint ;Restore the instruction. _StepExit: inton ;Turn interrupts back on. cs:push.w StackBot ;Restore the flags. popf.w ; rti ***************************************************************************** SetProgReg: cs:move.w es, P_ES ; cs:move.w ds, P_DS ; cs:move.w fs, P_FS ; cs:move.w gs, P_GS ; cs:move.w ss, P_SS ; cs:move.w sp, P_SP ;All important registers saved. ***+++++++++++++++++++++++++++++++++++++++*** intoff dc.b $66 ;Extend... cs:move.w S_SP, sp ;Set the stack pointer. cs:move.w S_SS, ss ;Set the stack segment. inton ***+++++++++++++++++++++++++++++++++++++++*** cs:move.l S_AX, a cs:move.l S_BX, b cs:move.l S_CX, c cs:move.l S_DX, d dc.b $66 cs:move.w S_DI, di dc.b $66 cs:move.w S_SI, si dc.b $66 cs:move.w S_BP, bp ***+++++++++++++++++++++++++++++++++++++++*** cs:move.w S_DS, ds cs:move.w S_ES, es cs:move.w S_FS, fs cs:move.w S_GS, gs ***+++++++++++++++++++++++++++++++++++++++*** bra.w StepRet1 BPR1: ***************************************************************************** ResetProgReg: cs:move.l a, S_AX cs:move.l b, S_BX cs:move.l c, S_CX cs:move.l d, S_DX dc.b $66 cs:move.w di, S_DI dc.b $66 cs:move.w si, S_SI dc.b $66 cs:move.w bp, S_BP ***+++++++++++++++++++++++++++++++++++++++*** cs:move.w ds, S_DS cs:move.w es, S_ES cs:move.w fs, S_FS cs:move.w gs, S_GS ***+++++++++++++++++++++++++++++++++++++++*** pushf.l ;Push the flags. pop.l a ;Get the flags. cs:move.l a, S_FLAGS ;Save them. and.w #$FAFF, ax ;Mask off Single step & Direction. push.w ax ;Push them. popf.w ;Set them. ***+++++++++++++++++++++++++++++++++++++++*** cs:move.w ss, S_SS dc.b $66 ;Extend... cs:move.w sp, S_SP ;Set the stack segment. ***+++++++++++++++++++++++++++++++++++++++*** intoff dc.b $66 ;Extend... cs:move.w P_SP, sp ;All important registers saved. cs:move.w P_SS, ss ; inton ***+++++++++++++++++++++++++++++++++++++++*** cs:move.w P_ES, es ; cs:move.w P_DS, ds ; cs:move.w P_FS, fs ; cs:move.w P_GS, gs ; ***+++++++++++++++++++++++++++++++++++++++*** cs:move.w S_CS, ax ;Get the program segment. cs:move.w S_IP, bx ;Get the program Pointer. push.w #Prog_Loop ;Where to return to. cs:cmp.w ax, CodSource+2 ;Same segment as window? bne.s UpdateSegment ;No, so update. cs:cmp.w bx, NextPage ; bne.s CheckOnScreen ; bra.w _Get_Next CheckOnScreen: cs:cmp.w CodSource, bx ; blt.s UpdatePointer cs:cmp.w NextPage, bx bgt.s UpdatePointer rts UpdateSegment: cs:move.w ax, CodSource+2 ;Reset the dissassembly - UpdatePointer: cs:move.w bx, CodSource ;display address. JustReturn: rts *****************************************************************************