The rain in spain (a simple program for my CPU)

This is a test of an emulator for the CPU, which im using to develop the instruction set. As I build the CPU in Logisim, I will update the instruction set here so I can test the practicality of the actual CPU.

Logisim on Sourceforge
Logisim file with my prototype CPU so far (30k file size)

The purpose of the program is to read from the input buffer, and pass each character to the output buffer. If a character is an upper case letter, it is turned into lower case. The input is "ThE RaIN In SPAiN", so the output should be "the rain in spain".

The assembler has three basic high level features; 1) labels, allowing a JZ (jump if zero) command to use a human readable label. This is translated into a program location. 2) variable declarations, allowing you to use a named variable rather than having to memorise memory locations 3) it gives names to all of the instructions, so you can type "STOR some_variable" It also ignores whitespace, such as indentation, so any length of whitespace is equivilant to 1 space.

Input code

Translated Assembly

Machine Code

Input Buffer Starting Contents:

Output Buffer:

Interpret as ascii
	

This is the instruction set:

PUT : 0,    // put the lowest 8 bits of the address directly into the ACCUM

// bitwise arithmetic - results of each instruction override the previous accumilator value
AND : 1,    // bitwise and is performed between given address and accumilator
NOT : 2,    // bitwise not is performed between given address and accumilator
OR  : 3,    // bitwise OR is performed between given address and accumilator
ADD : 4,    // the given register is added to the accumilator
CMP : 5,    // is the accumilator equal to the RHS? it becomes 255 if it is, and 0 if not
LT  : 6,    // is the accumilator less than teh RHS? it becomes 255 if it is and 0 if not

// memory operations
STOR  : 8,   // store the accumilator at the given address

// control flow
JZ    : 9,  // if the accumilator is zero, jump to the given address in the program space

// IO commands
INPUT : 7,   // read from input bus to ACCUM, AND'ed against the given constant - e.g., if the input buffer contains 0x66 and the constant given is 0xF0, the ACCUM will be 0x60
OUTPUT : 11  // write ACCUM to output bus, AND'ed against the given constant - e.g. if the accum contains 0x66 and the constant given is 0xF0, the output will be 0x60