Close

10/1/23 Update

A project log for 1802 MemberChip Card

A retro-microcomputer in a micro-package. Learn from the ground up, just like the pioneers. Has monitor editor assembler BASIC FORTH LISP...

lee-hartLee Hart 10/02/2023 at 03:550 Comments

Made numerous small changes to the MC20ANSA ROM, and uploaded an updated image to the Hackaday.io page.

Changes include improved operation at high baud rates, clearer HELP messages, and the addition of a CALL option to the Monitor so you can CALL a user program, make use of the monitor's I/O routines, and RETURN to it when it exits.

The MCSMP20 monitor in the ROM actually has two separate "run" commands:

The RUN command

The monitor's RUN command is like a hardware CLEAR; it sets X=0 and P=0, so R0 becomes the program counter. If you don't provide an address (just R<cr>), then program execution begins at 0000; just like a hardware reset.

If you *do* provide an address (Raaaa<cr>), the RUN command sets R0 to that address. Thus, that's where your program will begin executing.

The other registers are set to the values saved in RAM when the monitor started, as shown by the VIEW command. If you like, you can *change* the corresponding value in RAM, and it will be restored by the RUN command.

For example, R8 is saved in RAM at FFECh and FFEDh. If you use the WRITE command to set these bytes to some value (for example, WFFEC 12 34<cr>), then RUN sets R8=1234h and then starts execution at R0.

The CALL command

The other RUN command could more properly be named CALL. Although 1802 register assignments are arbitrary, most 1802 software typically uses them as follows. If you want your programs to work with other people's programs, use these assignments:

      R0 = DMA pointer (and the PC on power-up or clear)
      R1 = Interrupt handler
      R2 = Stack pointer
      R3 = Program counter
      R4 = CALL subroutine
      R5 = RETURN from subroutine
      R6 = used to pass parameters to or from a subroutine

CALL is an initialization routine to set up all these registers for you. It is in ROM at address 1680h. The R1680<cr> command will:

      - change the program counter from R0 to R3
      - set P=3
      - initialize the stack
      - set X=2 to make it the stack pointer
      - point R4 to SCRT CALL routine
      - point R5 to SCRT RETURN routine
      - push R6 onto the stack
      - use R6 to get the current baud rate constant
      - save the current baud rate constant in RE
      - restore R6 from the stack
      - and jump to 8000h (the start of RAM, where your user program should be)

Happy hacking!

Lee Hart

Discussions