Show Memory and Registers

Code to show contents of memory

M show memory DSPLYM-MP1 711C
M shows 8 bytes of memory, address (all four bytes) to be typed in, and set the current address for : modify command.

R show registers DSPLYR-MP1 7114
R Show Program counter and registers, a special case of show memory, address from PCL PCH and only 5 bytes from the register save location on zeropage (FLGS and up)
PC PS A X Y SP

 *  7052 B0 00 FF 00 FF
.M  0200 00 00 00 00 00 00 00 00
.R  7052 B0 00 FF 00 FF
0537   729A             ;  WRITE ADR FROM TMP0 STORES
0538   729A             ;
0539   729A A2 01       WROA   LDX #1
0540   729C D0 0A              BNE WROA1
0541   729E A2 05       WROA4  LDX #5
0542   72A0 D0 06              BNE WROA1
0543   72A2 A2 07       WROA6  LDX #7
0544   72A4 D0 02              BNE WROA1
0545   72A6 A2 09       WRPC   LDX #9
0546   72A8 B5 ED       WROA1  LDA TMP0-1,X
0547   72AA 48                 PHA
0548   72AB B5 EE              LDA TMP0,X
0549   72AD 20 B1 72           JSR WROB
0550   72B0 68                 PLA

What is happening here?
From the workspace TMP0, depending on X as offset the address is printed with WROB

0112   0000             ACMD   =236   $EC
0113   0000             TMP0   =238   $EE
0114   0000             TMP2   =240   $F0
0115   0000             TMP4   =242   $F2
0116   0000             TMP6   =244   $F4
0117   0000             PCL    =246   $F6
0118   0000             PCH    =247   $F7
0119   0000             FLGS   =248   $F8
0120   0000             ACC    =249   $F9
0121   0000             XR     =250   $FA
0122   0000             YR     =251   $FD
0123   0000             SP     =252   $FE
0124   0000             SAVX   =253   $FD
0125   0000             TMPC   =254   $FE
0126   0000             TMPC2  =255   $FF
0127   0000             RCNT   =TMPC  $FE
0128   0000             LCNT   =TMPC2 $FF
0302   70FB A9 F8       SETR   LDA #FLGS         ; SET TO ACCESS REGS
0303   70FD 85 EE              STA TMP0
0304   70FF A9 00              LDA #0
0305   7101 85 EF              STA TMP0+1
0306   7103 A9 05              LDA #5
0307   7105 60                 RTS

0328   7114             ;  DISPLAY REG CMD - A,P,X,Y, AND SP
0329   7114             ;
0330   7114 20 A6 72    DSPLYR JSR WRPC          ; WRITE PC
0331   7117 20 FB 70           JSR SETR
0332   711A D0 07              BNE M0            ; USE DSPLYM
0333   711C             ;

What is happening here?

SETR

  • The address of the saved registers is loaded in TMP0, TMP0+1
  • A is loaded with 5, to let DSPLYM show the registers SP A X Y Z

DSPLYR
Display the saved registers

  • show the current Program counter via(330)
  • load the address of the registers FLGS in TMP0 (331)
  • jump to DSPLYM to show the 5 registers from FLGS (332 to 337-345)
0334   711C 20 A4 73    DSPLYM JSR RDOA          ; READ MEM ADR INTO TMPC
0335   711F 90 16              BCC ERRS1         ; ERR IF NO ADDR
0336   7121 A9 08              LDA #8
0337   7123 85 FE       M0     STA TMPC
0338   7125 A0 00              LDY #0
0339   7127 20 77 73    M1     JSR SPACE         ; TYPE 8 BYTES OF MEM
0340   712A B1 EE              LDA (TMP0),Y      ; (TMP0) PRESERVED FOR POSS ALTER
0341   712C 20 B1 72           JSR WROB
0342   712F C8                 INY               ; INCR INDEX
0343   7130 C6 FE              DEC TMPC
0344   7132 D0 F3              BNE M1
0345   7134 4C 86 70    BEQS1  JMP START

What is happening here?

  • read the address to store bytes (334)
  • error of not a valid address (335)
  • A = 8 (or 5 if display registers) as count of the 8 bytes to show (336-337)
  • loop A count data bytes
    • type space (339)
    • load byte from memory[TMP0+Y]
    • print byte
    • increment Y, decrement A count (342-343)
    • until all eight printed (344)
  • back to START (345)