changeset 2010:a9560d9f59d1

Fixed bug where SP wasn't properly set when invoking F$Debug from system state. Now the stack pointer is retrieved some known offset from the current SP value. Kind of a kludge, but it works (so far).
author boisy
date Mon, 06 Mar 2006 00:39:16 +0000
parents a293c4ba6084
children 484c5493599a
files 3rdparty/p2mods/noice/noice.asm
diffstat 1 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/3rdparty/p2mods/noice/noice.asm	Sun Mar 05 15:11:20 2006 +0000
+++ b/3rdparty/p2mods/noice/noice.asm	Mon Mar 06 00:39:16 2006 +0000
@@ -81,6 +81,7 @@
 callregs       RMB       2
 firsttime      RMB       1
                IFGT      Level-1
+syssp          RMB       2
 ssflag         RMB       1
                ENDC
                IFNE      MPI
@@ -173,6 +174,16 @@
                clra                          we aren't in system state
                bra       dbgcont
 dbgentss       ldx       <D.DbgMem
+
+* Interesting trick here... I cannot see where the kernel stores the stack
+* register when processing a system call in system state.  I observed that
+* the actual value of S was $15 bytes from where S is when entering the
+* system call.  We'll see how this holds up during system state debugging,
+* and whether changes to the kernel will affect this offset.
+               leas      $15,s
+               sts       <syssp,x
+               leas      -$15,s
+               
                lda       #$01
 dbgcont        sta       <ssflag,x
                ENDC
@@ -522,9 +533,15 @@
                ldd       R$PC,y
                exg       a,b
                std       ,x                  PC
-               ldy       <D.Proc             get SP from proc desc
+               IFGT      Level-1
+               tst       <ssflag,u           system state?
+               beq       us@
+               ldd       <syssp,u
+               bra       cmn@
+               ENDC
+us@            ldy       <D.Proc             get SP from proc desc
                ldd       P$SP,y
-               exg       a,b
+cmn@           exg       a,b
                std       combuff+4,u
                lbsr      _sendtohost
                lbra      mainloop
@@ -579,9 +596,15 @@
                std       R$PC,y
                ldd       combuff+4,u
                exg       a,b
-               ldy       <D.Proc
+               IFGT      Level-1
+               tst       <ssflag,u
+               beq       us@
+               std       <syssp,u
+               bra       cmn@
+               ENDC
+us@            ldy       <D.Proc
                std       P$SP,y
-               ldd       #$0100
+cmn@           ldd       #$0100
                std       combuff+1,u
                lbsr      _sendtohost
                lbra      mainloop