Wombat1
A simple single accumulator machine. No stack or procedure calls.
Hardware
The accumulator, instruction register, and memory data register are 16 bits wide. The memory address register (mar) is 12 bits wide. This is because memory addresses are 12 bits wide, but data values are 16 bits wide. The program counter is 12 bits wide, also because it holds an address. The status register is 3 bits wide, though only one of them is used.
Machine instructions
It has instructions to stop the machine, load and store values from memory to the accumulator, instructions to read and write the accumulator to external channels, add, subtract, multiply, and divide a value in memory to the accumulator, and jump unconditionally or based on whether the accumulator is zero or negative.
All of the machine instructions are 16 bits (2 bytes) wide, with 4 bits used for the opcode and the remaining 12 bits for the address. This allows 16 instructions and 4096 words of memory. This also explains incrementing the program counter by 2, since instructions are two bytes wide.
All the arithmetic instructions leave their results in the accumulator.
| stop 0 (0000) | Set the halt bit to halt the machine |
| load 1 | Load the contents of a fixed memory address into the accumulator |
| store 2 | Store the contents of the accumulator into a fixed memory address |
| read 3 (3000) | Read from a fixed external channel into the accumulator |
| write 4 (4000) | Write from the accumulator to a fixed external channel |
| add 5 | Add the contents of a fixed memory address to the accumulator |
| subtract 6 | Subtract the contents of a fixed memory address from the accumulator |
| multiply 7 | Multiply the contents of a fixed memory address by the accumulator |
| divide 8 | Divide the contents of a fixed memory address into the accumulator |
| jump 9 | Jump unconditionally to the operand address of the instruction |
| jumpz A | If the accumulator is zero, jump to the operand address of the instruction |
| jumpn B | If the accumulator is negative, jump to the operand address of the instruction |
There are twelve instructions in all, out of a possible 16. Note that the opcodes for the stop, read, and write instructions take the whole two bytes.
Wombat2
Replaces the accumulator with a register array of four registers, and adds an instruction to move data between array registers. Has two buffer registers for arithmetic calculations.
Hardware
The buffer registers, instruction register, and memory data register are 16 bits wide. The memory address register (mar) is 12 bits wide. This is because memory addresses are 12 bits wide, but data values are 16 bits wide. The program counter is 12 bits wide, also because it holds an address. The status register is 3 bits wide, though only one of them is used. All of the array registers are 16 bits wide.
Assembly language
It adds EQUs for A0 through A3 as 0 through 3. This allows the user to write more mnemonic instructions like load A3 foo instead of load 3 foo.
Machine instructions
All of the machine instructions are 16 bits (2 bytes) wide. Most have 5 bits for the opcode (instead of 4), 2 bits for a subscript to specify one of the 4 registers in the register and the remaining 9 bits for the address. This allows 32 instructions, though there are only 13, 4 registers, and 512 words of memory. This also explains incrementing the program counter by 2, since instructions are two bytes wide.
All the arithmetic instructions leave their results in the array register specified by the first operand.
The instructions that copy an address into an address register must clear the address register, since the addresses that they copy from parts of instructions are now less than 12 bits wide.
| stop 00 (0000) | Set the halt bit to halt the machine |
| load 01 | Load the contents of a fixed memory address into one of the array registers |
| store 02 | Store the contents of one of the array registers into a fixed memory address |
| read 03 | Read from a fixed external channel into one of the array registers |
| write 04 | Write from one of the array registers to a fixed external channel |
| add 05 | Add the contents of the array register specified by the second operand to the array register specified by the first operand |
| subtract 06 | Subtract the contents of the array register specified by the second operand from the array register specified by the first operand |
| multiply 07 | Multiply the contents of the array register specified by the second operand by the array register specified by the first operand |
| divide 08 | Divide the contents of the array register specified by the second operand into the array register specified by the first operand |
| jump 09 | Jump unconditionally to the operand address of the instruction |
| jumpz 0A | If the array register specified by the first operand is zero, jump to the second operand address of the instruction |
| jumpn 0B | If the array register specified by the first operand is negative, jump to the second operand address of the instruction |
| move 0C | Move the contents of the array register specified by the first operand to the array register specified by the second operand |
There are 13 instructions in all, out of a possible 32, since we have added move. Note that now most opcode widths are 5 bits, so opcodes can run from 00 through 1F. Also, only stop has an opcode that takes all bits of the instruction.
Wombat3
Adds a stack in a separate RAM, a top register, new microinstructions to deal with the stack and top register, and new machine instructions to push and pop the stack.
Hardware
It has the same registers as the Wombat2, except that it adds a top register of width 12. This is intended to hold the address of the top of the stack. It always points two bytes beyond the top of the stack to the first available position to push something onto the stack.
It has the same register array of 4 registers of width 16, and the same condition bits. It has the Main RAM, and adds a Stack RAM, also of size 128.
Microcode
It adds microinstructions to increment and decrement the top register by 2 (size of one word). It has no shift, logical, or branch instructions, and the same arithmetic instructions as the Wombat2. It has the same TransferRtoR, TransferRtoA, TransferAtoR, Decode, Set Condition Bit, and IO instructions as Wombat2. It adds Memory Access instructions to move the value at the top of the stack to and from the mdr (memory data register).
It has the same fetch sequence as the Wombat2.
Assembly language
It has the same EQUs and no fields.
Machine instructions
It has the same machine instructions as Wombat2 with two additions.
| push 0D | Pushes the value in a specified array register onto the stack |
| pop 0E | Pops the value from the top of the stack into a specified array register |
There are now 15 instructions in all, out of a possible 32.
Wombat4
Adds procedure calls and stack relative addressing. This may be enough to compile to.
Hardware
It has the same registers, register arrays, condition bits and RAMs as Wombat3.
Microcode
It adds a clear-mdr Set instruction that clears the entire mdr. It has the same Test and Increment instructions and no Shift or Logical instructions. It adds Arithmetic instructions to add the mar to, and subtract it from, the top register. It has no Branch instructions. It adds TransferRtoR instructions to copy the rightmost 12 bits of the mdr to the pc, to copy the pc to the rightmost 12 bits of the mdr, and to copy the top register to the mar. The first two appear to be for saving the program counter on the stack and restoring it. It has the same TransferRtoA, TransferAtoR, Decode, Set Condition Bit, IO, and Memory Access instructions as the Wombat3.
It has the same Fetch Sequence as the Wombat3.
Assembly language
It has the same EQUs and fields (none) as the Wombat3.
Machine instructions
It has all the machine instructions of the Wombat3, with these additions.
| call 0F | Save the program counter on top of the stack, then load the address in the instruction operand (9 bits) into the program counter to jump to it |
| return 10 (8000) | Restore the program counter from the top of the stack and continue at that address |
| load_s 11 | Loads the contents of an address at a specified offset below the stack top into a specified array register |
| store_s 12 | Stores the contents of a specified array register at an address a specified offset below the stack top |
There are now 19 instructions in all, out of a possible 32. Let us compare binary opcodes of these instructions.
| divide 08 | 0010 0XXX XXXX XXXX |
| call 0F | 0111 1XXX XXXX XXXX |
| return 10 (8000) | 0100 0000 0000 0000 |
| load_s 11 | 1000 1XXX XXXX XXXX |
| store_s 12 | 1001 0XXX XXXX XXXX |
Thus the divide and return instructions have different patterns. The display represents return as 8000, though in the 5 bit opcode scheme, the opcode is really 10.
Wombat5
Adds load_c, load_i, store_i, and copytop instructions to facilitate call by reference (call by address). I should not need this. It might be useful if I include a frame pointer, so that I can do addressing on the stack relative to it.
Hardware
It has the same registers, register arrays, and condition bits as Wombat4. It increases the size of the Stack RAM to 256 from 128.
Microcode
It has the same Set instructions, Test instructions, and Increment instructions as the Wombat4. It adds a Shift instruction to do an arithmetic shift right by 7 of buffer1. It has the same Logical instructions (none), Arithmetic instructions, and Branch instructions (none) as the Wombat4.
It adds two TransferRtoR instructions. One moves bits 7-15 (9 bits) of the instruction register (current instruction) to buffer1, left justified. Combining this with the shft right would move it, sign extended, to the right end of buffer1. The other new instruction moves the 9 bits of the top register into the rightmost 9 bits (4-12) of buffer1.
It has the same two TransferRtoA instructions as the Wombat4.
It adds a new TransferAtoR instruction. A[ir(14-15)]->mar moves the rightmost 12 bits of the array register specified in the instruction operand to the mar.
It has the same Decode, Set Condition Bit, and I/O instructions as the Wombat4.
It adds two Memory Access instructions. Stack[mar]->mdr allows loading the contents of any location in Stack memory, addressed by the mar, into the mdr. mdr->Stack[mar] allows storing the contents of the mdr into any location in Stack Memory, addressed by the mar. Previously, the use of the top register enforced a stack discipline.
It has the same Fetch Sequence as the Wombat4.
Assembly language
It has the same EQUs and fields (none) as the Wombat4.
Machine instructions
The Wombat5 adds four new machine instructions. copytop loads the stack pointer into an array register for address calculations. store_i stores the contents of an array register at a location on the stack specified by another register. This is an indexed store and breaks the stack discipline. load_i loads the contents of a location on the stack specified by one register into another register. load_c does an immediate load of a constant specified in the instruction into a register.
These are indexed load and store instructions. They allow address arithmetic to calculate an address on the stack to access. For example, use copytop to load the stack pointer into a register. Then do arithmetic on that register to calculate an offset from the stack pointer. Then use load_i or store_i to access the location calculated.
| load_c 13 | Load the 9 bits of the instruction's second operand, right justified by shifting right with arithmetic extension, into the array register specified by the instruction's first operand |
| load_i 14 | Load the contents of the location in Stack memory whose address is the rightmost 12 bits of the array register specified by the instruction's second operand into the array register specified by the instruction's first operand |
| store_i 15 | Store the contents of the array register specified by the instruction's first operand into the location in Stack memory whose address is the rightmost 12 bits of the array register specified by the instruction's second operand |
| copytop 16 | Loads the 12 bits of the top register into the rightmost 12 bits of the array register specified by the instruction's operand |
There are now 23 instructions in all, out of a possible 32.
Examples
copytop A3 ;; Place value of top register in A3
store_i A2 A3 ;; Store value in A2 into Stack location addressed by A3
load_i A1 A3 ;; Load value in Stack location addressed by A3 into A2
Wombat6
Adds shifta, shiftl, shiftc, and, xor, not, or instructions. I don't think that I need this.
Wombat6 appears to go all the way back to Wombat2 and make changes.
Hardware
It has the same registers as the Wombat2. It does not have a top register. It changes the number of A array registers from 4 to 8. It has the same condition bits as the Wombat2. It has Main and Stack RAMs of size 128, as do Wombat3 and Wombat4. Wombat5 has a Stack RAM size of 256.
Wombat6 increases the number of array registers from 4 to 8, requiring three bits of the instruction register to be used to specify an array register. It uses 5 bits for the opcode, leaving 11 bits for the operands. This requires decreasing the size of the second operand from 9 bits to 8, meaning that only 256 bytes can be addressed by such an operand.
Microcode
Set instructions
Wombat2 and Wombat3 have only clear-mar and clear-pc. Wombat4 and Wombat5 add clear-mdr. Wombat6 keeps all three and adds buf2=-1 to set buffer2 to -1.
Test instructions
Wombat2 through Wombat5 have two test instructions: to skip over two microcode instructions (the ones that place the jump address in the pc) if buffer1 is non-zero or positive. These are used in the jumpz and jumpn machine instructions.
Wombat6 adds two test instructions: to skip 6 microcode instructions if buffer2 is negative, and to skip 3 microcode instructions if buffer2 is positive.
Increment instructions
Wombat2 has only one increment instruction, to increment the pc by 2 to get to the next instruction.
Wombat3 through Wombat5 add two instructions to increment and decrement top by 2.
Wombat6 does not use top. It keeps the Inc2-pc instruction from Wombat2, and adds four new Increment instructions. Inc1-buf2 and dec1-buf2 increment and decrement buffer2 by 1. Inc2-A[7] and dec2-A[7] increment and decrement register A7 by 2. Apparently register A7 has become the top of stack register.
Shift instructions
Wombat2 through Wombat4 have no Shift instructions. Wombat5 adds one to arithmetic shift buffer1 right by 7 bits, to right justify a 9 bit constant value.
Wombat6 does not keep the instruction from Wombat5. It has 8 entirely new Shift instructions. Six of these do left and right arithmetic, cyclic, and logical, shifts of buffer1. One arithmetic shifts buffer1 right by 8 bits (one byte). The other arithmetic shifts buffer2 right by 11 bits. This has the effect of placing the number represented by the top 5 bits right justified, with sign extension.
Logical instructions
Wombat2 through Wombat5 have no Logical instructions.
Wombat6 has four logical instructions. One logically negates buffer1. The other three perform the standard logical operations, AND, OR, and XOR, on buffer1 and buffer2, placing the result in buffer1. These will be used to implement bitwise machine instructions.
Arithmetic instructions
Wombat2 and Wombat3 have four Arithmetic instructions, to perform the four standard arithmetic operations on buffer1 and buffer2, leaving the result in buffer1.
Wombat4 and Wombat5 keep these, and add two new Arithmetic instructions to increment and decrement top by the contents of mar.
Wombat6 keeps the four basic instructions from Wombat2 and Wombat3. It replaces the two additional instructions from Wombat4 and Wombat5 by comparable instructions that increment and decrement register A7 by the contents of mar.
Branch instructions
Wombat2 through Wombat5 have no Branch instructions.
Wombat6 adds a branch instruction to branch backwards 4 microcode instructions. This could be used to implement a loop.
TransferRtoR instructions
Wombat2 and Wombat3 have six identical TransferRtoR instructions. These can move between buffer1 and mdr; move bits 7-15 (9 bits) from the current instruction, right justified, to the mar or the pc; load the mdr to the ir (used in the fetch sequence); and copy the pc to the mar.
Wombat4 adds adds three TransferRtoR instructions: to copy the rightmost 12 bits of the mdr to the pc, to copy the pc to the rightmost 12 bits of the mdr, and to copy the top register to the mar. The first two appear to be for saving the program counter on the stack and restoring it.
Wombat5 adds two TransferRtoR instructions. One moves bits 7-15 (9 bits) of the instruction register (current instruction) to buffer1, left justified. Combining this with the shft right would move it, sign extended, to the right end of buffer1. The other new instruction moves the 9 bits of the top register into the rightmost 9 bits (4-12) of buffer1.
Wombat6 has a rather different set of TransferRtoR instructions. It keeps these instructions from Wombat5:
buffer1->mdr buffer1 0 mdr 0 16 1
mdr->buffer1 mdr 0 buffer1 0 16 1
mdr->ir mdr 0 ir 0 16 1
mdr->pc mdr 4 pc 0 12 1
pc->mar pc 0 mar 0 12 1
pc->mdr pc 0 mdr 4 12 1
It drops these Wombat5 instructions:
ir(7-15)->buffer1 ir 7 buffer1 0 9 1
ir(7-15)->mar ir 7 mar 3 9 1
ir(7-15)->pc ir 7 pc 3 9 1
top->buffer1 top 0 buffer1 4 12 1
top->mar top 0 mar 0 12 1
It adds these new instructions:
buffer1->mar buffer1 4 mar 0 12 1
ir(11-15)->buf2(0-4) ir 11 buffer2 0 5 1
ir(8-15)->buf1(0-7) ir 8 buffer1 0 8 1
ir(8-15)->mar ir 8 mar 4 8 1
ir(8-15)->pc ir 8 pc 4 8 1
This apparently cuts the addresses stored in instructions to 8 bits from 9, which means that they can represent only 256 bytes instead of 512.
TransferRtoA instructions
Wombat2 through Wombat5 have the same two instructions that move buffer1 to an array register specified by a two-bit version (5-6 or 14-15) of one of the operands of the machine instruction.
Wombat6 keeps the same basic instructions, but modifies them to use three bits of the instruction register (5-7 and 13-15) to refer to one of the array registers.
TransferAtoR instructions
Wombat2 through Wombat4 have the same three instructions. These can move an array register specified by either operand into buffer1 or an array register specified by the second operand into buffer2.
Wombat5 keeps these instructions and adds one that moves the rightmost 12 bits of an array register specified by the second operand into the mar.
Wombat6 drops the extra instruction added by Wombat5. It keeps the three basic instructions from Wombat2 through Wombat4, but modifies them to use three bits (5-7 and 13-15) from the instruction register instead of two (5-6 and 14-15) to identify the register to move. It also adds one new one that moves the contents of an array register specified by bits 8-10 of the instruction register to buffer1. This allows for a three-argument machine instruction.
Decode instructions
Wombat6 has the same Decode-ir instruction as all the others.
Set Condition Bit instructions
Wombat6 has the same set-halt-bit instruction as all the others.
IO instructions
Wombat6 has the same two I/O instructions to read and write an integer in buffer1 as all the others.
Memory Access instructions
Wombat2 has two instructions to move data from a location in the Main memory to and from mdr.
Wombat3 and Wombat4 add two instructions to move data between the top of the Stack and mdr.
Wombat5 adds two instructions to move data between any location in Stack memory (using mar) and mdr.
Wombat6 keeps the same instructions as Wombat5, but uses A7 to access the top of the stack instead of top (which it does not have).
Fetch Sequence
Wombat6 has the same fetch sequence as all the rest.
Assembly language
Wombat6 defines EQUs for A0 through A7, and has no fields.
Machine instructions
Wombat6 adds instructions. It also has most of the same instructions as before, though modified in how wide their operand fields are. All instructions are 16 bits wide. Most of the opcodes are 5 bits. Those with one operand use the remaining 11 bits for it. Those with two operands use 3 bits for the first and 8 for the second. Those with three operands use 3 bits, 3 bits, and 5 bits.
Note that the call instruction now has only an 8 bit jump address to load, even though its operand field can hold 11 bits.
It keeps instructions 00 through 15, with minor name changes: storei, loadi, loadc, stores, and loads. It drops instruction 16, copytop, since there is no top register. This machine does not use opcode 16.
It adds these instructions.
| shifta 17 | Arithmetic shift the value in the array register specified by the instruction's second operand left or right by the amount of the instruction's third operand, according as the instruction's third operand is positive or negative, and store the result in the array register specified by the instruction's first operand |
| shiftl 18 | Logical shift the value in the array register specified by the instruction's second operand left or right by the amount of the instruction's third operand, according as the instruction's third operand is positive or negative, and store the result in the array register specified by the instruction's first operand |
| shiftc 19 | Cyclic shift the value in the array register specified by the instruction's second operand left or right by the amount of the instruction's third operand, according as the instruction's third operand is positive or negative, and store the result in the array register specified by the instruction's first operand |
| and 1A | Performs a bitwise AND of the values in array registers specified by the instruction's operands, leaving the result in the array register specified by the function's first operand |
| xor 1B | Performs a bitwise XOR (eXclusive OR) of the values in array registers specified by the instruction's operands, leaving the result in the array register specified by the function's first operand |
| or 1C | Performs a bitwise OR of the values in array registers specified by the instruction's operands, leaving the result in the array register specified by the function's first operand |
| not 1D | Bitwise negates the value in the array register specified by the instruction's second operand, and stores the result in the array register specified by the instruction's first operand |
There are now 29 instructions in all, out of a possible 32. Opcodes 16, 1E, and 1F are not used.
Comments (0)
You don't have permission to comment on this page.