home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
new
/
util
/
moni
/
snoopy
/
snoopydebug.s
< prev
next >
Wrap
Text File
|
1993-12-30
|
2KB
|
72 lines
;-------------- this is it, the debug calling mechanism. don't modify or else...
;-------------- This function does NOT modify a6 to the outside, but for the
;-------------- called function. This means, a6 remains the same in the main
;-------------- programm, but the debugged subroutine will have scratched a6
;-------------- contents. Sorry folks, but thats about it!
SnoopyDebug: move.l a6,-(sp) ; push old a6
bsr.s sd_PrepareMsg ; setup message
move.l a6,-(sp) ; push message
move.l 16(sp),sumsg_Template(a6) ; set template
move.l 12(sp),a6 ; load function addr
jsr (a6) ; call function
move.l (sp)+,a6 ; get message
bsr sd_SendMsg ; send message
move.l (sp)+,a6 ; get old a6
move.l (sp),8(sp) ; set return addr
addq.l #8,sp ; skip stack
rts ; done
;-------------- this is used to prepare the message; i.e. allocate the
;-------------- needed memory and save the "registers-before-call"
sd_PrepareMsg: movem.l d0-d7/a0-a5,-(sp)
movea.l 4.w,a6
move.l #sumsg_SIZEOF,d0
move.l #$10001,d1 ; MEMF_PUBLIC|MEMF_CLEAR
jsr -198(a6) ; AllocMem()
movea.l d0,a0
move.l 276(a6),sumsg_Task(a0) ; ExecBase->ThisTask
movea.l d0,a6
movem.l (sp)+,d0-d7/a0-a5
cmpa.l #0,a6
beq sdpm_Failed
SAVEREGS sumsg_RegsBeforeCall
nop
sdpm_Failed: rts
;-------------- this procedure sends the message to snoopy. It is called
;-------------- after the user function has been executed, so that the
;-------------- "registers-after-call" field can be setup
sd_SendMsg: cmpa.l #0,a6
beq sdsm_Failed
SAVEREGS sumsg_RegsAfterCall
movem.l d0-d7/a0-a5,-(sp)
movea.l a6,a5 ; a5 = message
movea.l 4.w,a6 ; a6 = ExecBase
;-------------- find the message port to send our messages to
lea SnoopyPortName(pc),a1 ; name
jsr -390(a6) ; FindPort()
tst.l d0
beq.s sdsm_NoPort
movea.l d0,a4 ; a4 = port
;-------------- prepare message
move.b #5,8(a5) ; #NT_MESSAGE,LN_TYPE(a5)
move.w #sumsg_SIZEOF,18(a5) ; MN_LENGTH(a5)
move.w #MSGTYPEF_DEBUG,sumsg_Type(a5)
move.l #0,14(a5) ; MN_REPLYPORT(a5)
;-------------- send it
movea.l a4,a0 ; port
movea.l a5,a1 ; message
jsr -366(a6) ; PutMsg()
bra.s sdsm_Done
;-------------- port not found -> deallocate memory
sdsm_NoPort: movea.l a5,a1
move.l #sumsg_SIZEOF,d0
jsr -210(a6) ; FreeMem()
sdsm_Done: movem.l (sp)+,d0-d7/a0-a5
sdsm_Failed: rts