CPU FUN ZONE TUTORIALS

Basic Operations

There are several sections to the CPU Fun Zone:

  • RAM Grid, to the left. Each cell of this grid shows the current value of one byte of RAM. The top number in the cell is the address, e.g. 1234. The middle number is the current value. The label on the bottom is the assembly instruction mnemonic that tells you what it's going to do when it runs.
  • Registers and Control Panel to the right. There are six registers with the last one, C (also known as the program counter) being the address of the next instruction to be executed. The Control Panel allows you to run code from RAM at the current program counter (C) address or pause the current run. You can click on a RAM cell to jump the program counter to that address.
  • There is also the User Command text input below the Control Panel. This can be used to execute individual commands entered as assembly code. If the "assemble" checkbox is checked, the assembly commands will instead be assembled into RAM as machine code. The assembly will start from the current program counter address, so you can click on the RAM cell you want to assemble code to, and then submit the assembly code via the User Command input.

Display a Custom Message

Here is how to display a custom message.

  • Go to the Fun Zone (monitor)
  • Click "PROG A" on the control panel
  • This is the String Scroller demo. It uses the characters defined starting at address $d000. If you scroll down, you can see the first four characters in memory. The rest are out of the current view.
  • Download the K9B assembly source for String Scroller here: str_scroll.asm
  • Open the file in your text editor or IDE of choice - treat it like a text file if you don't have a default set for ASM files.
  • Find the message: label at line 37. On line 38 below, you should see: .text "hello woof "
  • Edit that to .text "hullo test " or any other lowercase text of the same length (11 characters including spaces).
  • Copy all of the assembly code and paste it into the user command text box in the Fun Zone monitor.
  • Click on the RAM cell at the start of the current program at address $0080 to set the program counter there.
  • Under the user command box, check the "assemble" checkbox and click the submit button. This will assemble our program into RAM starting at $0080! Don't click run yet though!
  • Click on RAM cell address $00ab to set the program counter to the start of our newly assembled program, which happens to be address $00ab rather than $0080. Don't worry about that for now, just click on $00ab!
  • Click on run to see our test message scroll across the RAM grid in the "display" area of $0000-$007f!
  • You can repeat the edit, paste and assemble process for any other message you want. Just make sure that you update the "define strlen" value as well if you change the length! Otherwise you won't see the whole thing.
  • Back to what's in address $0080, that's a memory clearing utility! Jump there and run to clear all of the RAM except for the memclear code. This is handy if you want space to run new programs! And you can always restore the preset programs with the PROG buttons.
  • BONUS: While running String Scroller, click on address $00e6, a "jsr" instruction, to glitch it out while it's running! You can press "PROG A" to restore it any time. Try clicking on other jsr and jump instructions if you can find them!

WYRM Source

If you want to check out some more sample code, you can find the K9B assembly source for WYRM (PROG B) here: wyrm.asm