OSDN Git Service

Trying to work out trace routines blindly.
authorJoel Matthew Rees <joel.rees@gmail.com>
Tue, 22 Jan 2019 08:03:16 +0000 (17:03 +0900)
committerJoel Matthew Rees <joel.rees@gmail.com>
Tue, 22 Jan 2019 08:03:16 +0000 (17:03 +0900)
fig6800to6809dumb.asm

index b05f5de..23c3403 100644 (file)
@@ -4,7 +4,7 @@
 
 * To do: 
 * 4 IO routines -- OK?
-* adjust ram locations
+* adjust ram locations -- OK?
 * then add trace routines
 * then try in emulator
 
@@ -156,7 +156,8 @@ MEMTOP      EQU     $7FFF   putative absolute end of all ram (32K Coco)
 *      ORG     $E0     variables
        ORG     $1300   variables
 PGBASE EQU     *
-       SETDP   PGBASE/$100
+PGBDP  EQU     PGBASE/$100
+       SETDP   PGBDP
 
 
 N      RMB     10      used as scratch by (FIND),ENCLOSE,CMOVE,EMIT,KEY,
@@ -183,6 +184,13 @@ RP RMB     2       the return stack pointer
 UP     RMB     2       the pointer to base of current user's 'USER' table
 *              ( altered during multi-tasking )
 *
+* For the tracer:
+       RMB 4
+TRASP  RMB 2
+TRAVEC RMB 2
+TRAA   RMB 1
+TRAB   RMB 1
+*
        PAGE
 *      This system is shown with one user, but additional users
 *      may be added by allocating additional user tables:
@@ -339,10 +347,94 @@ NEXT3     STX     W
 * The next instruction could be patched to JMP TRACE              =
 * if a TRACE routine is available:                                =
 *                                                                 =
-       JMP     0,X
+* Or add the TRACE routine in-line, since we are assembling it.
+       TST TRACEM
+       BEQ NEXTGO
+       STX TRAVEC
+       TFR S,X ; Mechanical! Mechanical! (So the funn 6800 stack didn't beach us.)
+       STX TRASP
+       LDA #':'
+       JSR PEMIT
+       LDA #' '
+       JSR PEMIT
+       LDX W
+       LEAX -1,X 
+       LEAX -1,X ; allocation link
+       LEAX -1,X ; last char
+       LDA #31
+NAMTST LEAX -1,X ; length byte?
+       LDB 0,X
+       BMI NAMTDN
+       DECA
+       BNE NAMTST
+NAMTDN ANDB #31 ; It's the length byte whether it wants to be or not.
+NAMSHW LEAX 1,X
+       LDA 0,X
+       JSR PEMIT
+       DECB
+       BNE NAMSHW
+* show the virtual registers
+* TOO MUCH OUTPUT! Have to trim this.
+       LDA #' '
+       JSR PEMIT
+       LDA #'@'
+       LDX #TRAVEC
+       JSR PHEX4F
+       TFR DP,A
+       LDB #(W-PGBASE)
+       TFR D,X
+       LDA #'W'
+       JSR PHEX4F
+       LDA #'I'
+       JSR PHEX4F
+       LDA #'R'
+       JSR PHEX4F
+       LDA #'U'
+       JSR PHEX4F
+       TFR DP,A
+       LDB #(W-TRASP)
+       TFR D,X
+       LDA #'S'
+       BSR PHEX4F
+       LDA #'>'
+       TFR S,X 
+       BSR PHEX4F
+       LDA #' '
+       BSR PHEX4F
+* 
+       JSR PCR
+       LDX TRAVEC
+*
+NEXTGO JMP     0,X
        NOP
 *      JMP     TRACE   ( an alternate for the above )
 *                                                                 =
+*                                                                 =
+*DBG
+PHEX4F JSR PEMIT
+       BSR PHEXX2
+       BSR PHEXX2
+       LDA #' '
+       JSR PEMIT
+       RTS
+PHEXX2 LDA 0,X
+       LSRA
+       LSRA
+       LSRA
+       LSRA
+       JSR PHEXD
+       LDA 0,X
+       JSR PHEXD
+       LEAX 1,X
+       RTS
+PHEXD  ANDA #$0F
+       CMPA #10
+       BLO PHEXDH
+       ADDA #7 ; 'A'-'9'+1
+PHEXDH ADDA #'0'
+       JSR PEMIT
+       RTS
+*DBG
 * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 
 
@@ -2417,7 +2509,7 @@ ABORT     FDB     DOCOL,SPSTOR,DEC,QSTACK,DRZERO,CR,PDOTQ
        FDB     ABORT-8
 COLD   FDB     *+2
 * CENT LDS     #REND-1 top of destination on 6800
-CENT   LDA #PGBASE/$100
+CENT   LDA #PGBDP
        TFR A,DP
        LDS     #REND   top of destination on 6809
        LDX     #ERAM   top of stuff to move