Skip to main content

Posts

Emulator: System Calls

This post will cover some basic I/O system calls, enough to implement a game or two, other than sound support or holotape support. The holotape calls required a little more explanation, and the sound system data is more complex than for the calls covered here. Prerequisites Hopefully you've read the post on running code in the emulator. It describes the easiest, fastest way to get your code running. Console Calls In the Clear The CLEAR system call will remove all text and attributes from the screen, and set the cursor to top-left (0,0).  Character I/O The only console input system call is GETCH. It takes a byte off the stack as the blocking mode (=0 no blocking, != 0 blocking), grabs a key from the input queue and returns a 16-bit value indicating which character was pressed. If the MSB is 0 then the LSB contains the ASCII value. There are two output calls, SETCH and PRINT. They both increment the cursor to the next character after their output is printed to screen at the current
Recent posts

Emulator Basics - Running Code

Now that I've covered the instruction set, it's time to talk about the assembler and running your assembly programs. The assembler is available as a standalone tool, but is also bundled into the emulator, allowing you to go directly from assembly to running your code in one step. Previous Posts The following posts cover the instruction set for the emulator. They can serve as a good resource once you decide to start writing code of your own. Instruction Set Part 1 Instruction Set Part 2 Instruction Set Part 3 Instruction Set Part 4 Setup If you haven't already, clone https://github.com/skwirl42/robco-processor into the directory of your choice. At the moment only the macOS port is fully maintained, so the instructions will be focused on using the project on macOS. Linux I have yet to port it to linux, but that is planned. If you would like to work on it, there's a task available on the repository. Ideally, this should be straightforward. If you plan to work on the linu

Emulator Deep Dive - The Instruction Set: Part 4

This is the fourth part in this series, and will cover flow control instructions. You can find the first post here , the second here , and the third here . Prerequisites None of the flow control operations use the data stack, and only two make use of the return address stack, so knowing about stacks is less important in this post than in the others. Knowledge of other assembly language variants would definitely be an asset, as these follow the same patterns found in other processors. Last Time The last post covered arithmetic and logic unit (ALU) instructions, which modify the condition code (CC) register. Many of the flow control instructions make use of the CC flags to determine whether or not to move execution flow elsewhere. Jumps Jump ( jmp , jsr , rts ) instructions change the program counter (PC) to an absolute address in memory. They are all unconditional, that is, the change in the PC happens regardless of the system's state. jmp changes the PC to an address specified as

Emulator Deep Dive - The Instruction Set Part 3

This is the third post in this series and will cover arithmetic and logic unit (ALU) instructions. The operations are pretty straightforward, and there are few caveats, if any. You can find a table of these instructions at the end of the post. You can find the first post here , the second here . Prerequisites There are a couple of prerequisites to fully understanding this series of posts. It will assume you know what a stack is and that you have some knowledge of assembly language. But the content could still be interesting even without that knowledge. I'll leave it to you to decide. Last Time In the last post I covered stack and memory manipulation instructions. Those instructions allowed for manipulation of the values on the stack; shuffling items around, adding items, and removing them. They can be combined with ALU instructions to produce a number of effects. ALU instructions These instructions apply mathematical operators to values from the stack. ALU operations operate exclus

Emulator Deep Dive - The Instruction Set: Part 2

This is the second post in this series, and will cover stack manipulation instructions. You can find a table of all the stack instructions at the end of this post. You can find the first post here . Prerequisites There are a couple of prerequisites to fully understanding this post. It will assume you know what a stack is (but I've included a refresher) and that you have some knowledge of assembly language. But the content could still be interesting even without that knowledge. I'll leave it to you to decide. Notation The table at the end of this post uses a stack effect notation typically used by Forth . These effect notations are enclosed in parentheses, and consist of a before state and an after state, separated by two dashes. For instance, the swap instruction exchanges the top two items on the stack. This would be noted as (a b -- b a) , showing that before the instruction is executed, b is at the top of the stack, and a is one below the top of the stack. After t