Thursday, September 1, 2016

Playing with the Maxitronix MX-909 CPU

Investigating the Maxitronix MX-909 CPU.

The Maxitronix CPU is quite interesting. It looks like a "simplified" processor that runs an interpreted machine language.

It has 6 registers, A through F, each a single byte.

Line numbers are used for addresses.

There's a limit of 64 instructions (or lines) in a program.
So you get to enter instructions from line 00 to line 3F.

There's 32 keys in the keyboard, arranged in 2 groups of 16 keys (4 keys by 4 keys).


The opcodes are:

MOV move data
IN read data from input port - 4 bits
OUT write data to output port - 8 bits
CMP compare data
JMP jump to an address
JC/JNC jump carry/no carry
JZ/JNZ jump zero/non zero
SEC/CLC set/clear carry
ROR/ROL rotate
INC/DEC increment/decrement
ADD
SUB
OR
AND
XOR
NOT
TM1/TM2 TM1=delay by param*10ms TM2=delay by param*1sec
HEX makes a data table entry of a single byte
BON/BOFF BON sets up a buzzer at a specific frequency on output pin 8, BOFF turns it off, used with TM1/TM2 to make a specific duration
STP stop
NOP no op

I count 28 different instructions.


The addressing modes are pretty simple too:

for the move instruction:

MOV reg,#n8 (the n8 means an 8 bit number), reg is A-F
MOV reg,reg
MOV A,@reg read from memory (indirection by register)

Interestingly, you can move from memory to the A register with register indirection (read from memory), but you can't store to memory.


so a sample program would be

00 MOV c,#80
01 MOV a,c
02 INC a
03 JMP 02

For some reason, they call registers "mem" in the manual, which seems a bit confusing, as I would normally interpret mem to mean memory.

It does look very much like machine language programming, and essentially it is.

It's pretty clever.

The debugger leaves something to be desired.
Once you put the CPU into debug mode, you choose a register to watch (b-f) or 0 (will show you the zero and carry flags in the digits displayed).

So you get a display that shows you the current contents of A and another register of your choosing.

for example:

line A reg B-F reg
00 A 00 C 00

and pressing RUN gets:

01 A 00 C 80

and pressing RUN again gets:

02 A 80 C 80



You can single step through by pressing RUN, but here's the annoying thing: you can't change the register displayed. So once you've chosen to show register B, you get register B until you've exited the program.


STACKED INSTRUCTIONS:

There's some advanced stuff here too like what they call "stacked instructions" in the manual.

If you have multiple identical immediate MOVs in a row, only the first one will be executed.

So if you have

20 MOV C,#20
21 MOV C,#21
22 MOV C,#22
23 MOV C,#23

and you execute a JMP 21, only the first MOV C will be executed, and the following ones will not be executed. So JMP 21 will give you the value #21H in register C by the time the program counter hits 24.

The BON instruction can be "stacked" too.

10 BON #01H
11 BON #03H
12 BON #05H

has the same behavior. Here JMP 11 will execute BON #03H and will skip any sequential following BON instructions.

So what happens when the CPU hits an empty instruction? Execution stops and you get ILL on the screen.

Data entry of programs is fairly straightforward, but there are some interface annoyances. For instance, once you lock in a specific opcode, you have to enter the parameters fully before you're allowed to go back and change the opcode. So if you choose MOV _,#__ as your opcode, you have to provide the register and the immediate value before you can do anything else. You should be able to press left arrow and change it immediately but you're not allowed to do that.

Another is that you have to press the down arrow to "lock in" the instruction even after you've entered all the parameters. Failure to do so makes the instruction disappear when you type ESC to change the cpu mode from Program to Debug.

There's no saving or loading your creations so when the power is off, your program disappears. It's only intended for small programs anyway, so this isn't a huge drawback.

It'd be really neat to have a full dot matrix LCD with being able to PRINT things to the display, but the focus is on interfacing with external components in the kit, like the LEDs and the 7 segment display.


If you want to see a sample of the manual, here's a sample (and shows project #470 and #484).

http://www.elenco.com/admin_data/pdffiles/MX909.pdf

2 comments: