General

The Wombat4w is an expansion of Dale Skrien's Wombat4 machine. It adds more memory and widens the instructions from two bytes to three bytes to allow for 16 bit addresses. It also widens the values from 16 bits to 32 bits to allow for full Java ints. It adds a separate heap memory and some machine instructions to deal with the heap.

Since the machine is implemented virtually in Dale Skrien's CPUSim, this description is broken down by the components needed to define the machine in CPUSim.

Hardware Components

Registers

The machine uses these individual registers internally to do its computations and manage its state. They are not accessible to the assembly language program directly.

The ir (instruction register) is essentially the memory data register for the Main RAM (instructions).

I'll have to analyze what the frames look like.

RegisterWidthUse
buffer132First operand for ALU computation and data transfer
buffer232Second operand for ALU computation
ir24Instruction register: holds each instruction for decoding
mar16Holds the address of a memory location to be accessed
mdr32Holds data being read from or written to memory
pc16Holds he address of the next instruction to be run
status3Status bits (only bit 0 used as halt bit)
top16Holds the next available word address above the top of the stack

Register arrays

There is one register array called A, with 8 general purpose registers, A0 through A7. Each is 32 bits wide.

Addressed by 3 bits in an instruction.

Condition bits

The only condition bit used is the halt bit (bit 0) of the status register, which the stop instruction sets to true. Arithmetic instructions also use it as their overflow bit, which stops the machine on an arithmetic overflow. Assembly language programs do not deal with this condition bit directly.

RAMs

There are three RAM areas. The sizes are in bytes.

NameSizePurpose
Main65536Holds code
Stack65536Holds the run-time stack
Heap65536Holds allocated objects

All of these have size 65536 bytes, addressable with 16 bits. Since each data word has 4 bytes, the Stack and Heap RAMs can each hold 16384 words. Since each instruction has 3 bytes, the Main RAM can hold 21845 instructions, with one byte left over. This should be enough for our test programs.

Microinstructions

The microinstructions are used to implement the machine instructions. A detailed understanding of them is not necessary to compile programs to the machine language.

EQUs

The CPUSim assembly languge allows the use of name equivalences to represent numeric constants in a more understandable symbolic form. The Wombat4w defines equivalences for the array registers, allowing assemly code to represent them as A0 through A7 instead of 0 through 7.

The assembly language program can also define its own local EQUs, if desired.

Fetch sequence

The fetch sequence uses microinstructions to load and decode (run) the next instruction. The assembly language program is not concerned directly with it.

Machine instructions

NameOpcodeFieldsDescription
stop 00 (0000)5 (19)Set the halt bit to halt the machine
load 015 3 ; 16Load the contents of a fixed memory address in the Main RAM into one of the array registers
store 025 3 ; 16Store the contents of one of the array registers into a fixed memory address in the Main RAM
read 035 19Read from a fixed external channel into one of the array registers
write 045 19Write from one of the array registers to a fixed external channel
add 055 3 ; 16Add the contents of the array register specified by the second operand to the array register specified by the first operand
subtract 065 3 ; 16Subtract the contents of the array register specified by the second operand from the array register specified by the first operand
multiply 075 3 ; 16Multiply the contents of the array register specified by the second operand by the array register specified by the first operand
divide 085 3 ; 16Divide the contents of the array register specified by the second operand into the array register specified by the first operand
jump 095 19Jump unconditionally to the operand address of the instruction
jmpz 0A5 3 ; 16If the array register specified by the first operand is zero, jump to the second operand address of the instruction
jmpn 0B5 3 ; 16If the array register specified by the first operand is negative, jump to the second operand address of the instruction
move 0C5 3 ; 16Move the contents of the array register specified by the first operand to the array register specified by the second operand
push 0D5 19Pushes the value in a specified array register onto the stack
pop 0E5 19Pops the value from the top of the stack into a specified array register
call 0F5 19Save 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)5 (19)Restore the program counter from the top of the stack and continue at that address
load_s 115 3 ; 16Loads the contents of an address at the offset below the stack top that is the contents of the second operand into the array register specified by the first operand
store_s 125 3 ; 16Stores the contents of the array register specified by the first operand at an address the offset below the stack top that is the value of the second operand
load_c 135 3 ; 16Loads the contents of the second operand, sign extended and right justified, into the array register specified by the first operand
inctop 145 19Increment (decrement if negative) the stack top by the operand
alloc 165 3 ; 16Place the current value of the heap pointer into the array register specified by the first operand, then allocate a new object by incrementing the heap pointer by the contents of the array register specified by the second operand
load_h 1E5 3 ; 3 ; 13Loads the contents of the heap at an address offset by the value of the third operand from the contents of the register specified by the second operand into the array register specified by the first operand
store_h 1F5 3 ; 3 ; 13Stores the contents of the array register specified by the first operand in the heap at an address offset by the value of the third operand from the contents of the register specified by the second operand

Corrections

Corrections that need to be made:

  • I need to change the source start bit of mdr->ir since mdr is wider than ir.


Page Information

  • 1 year ago [history]
  • View page source
  • You're not logged in
  • No tags yet learn more

Wiki Information


Update to PBwiki 2.0

An entirely new PBwiki experience, including folders and easier editing.

Convert Now for Free | Learn more