Skip to content
Textmode edited this page Mar 1, 2011 · 1 revision

Note: This specification is not presently complete. In particular, there are few details on opcodes

Contents

  1. Overview
  2. Registers
  3. Memory
  4. Operation
  5. Faults and Signals

Overview

TMVM defines a simple 8-bit register-based machine, thus the basic "word" size is one (1) byte. All opcodes are one byte in length with zero or more parameter bytes, whose meaning differs between opcodes.

Registers

Currently there are seven registers, which are the Instruction Pointer, the SEGment pointer, A, B, the ACCumulator, RETurn or result register, and the SIGnal register (which is where fault-codes are placed).
It is likely we'll add an eighth register, C. but otherwise we expect this set to remain stable.

Memory

Memory consists of 256 (two-hundred, fifty-six) pages or segments, each containing 256 addressable bytes of storage. The currently active segment is stored in the SEG register (and changing this register will change the current segment).

Note: At this time, only one segment (seg 0) is actually implemented. expect this to change soon.

Operation

Note: Obviously this section is detailing "general" operation. a specific host enviroment could alter many aspects of this sequence to their liking. this is never the less the "reference base operation"

Before the first execution cycle all registers will be cleared (set to zero) and the machine will attempt to populate segment 0 with initial data (generally either a BIOS, Loader segment, or the only program the machine will ever run).
Its worth noting that all other memory pages, and possibly the addresses not stored in the initialisation segment, are not specifically cleared and should be assumed to contain arbitrary values.

After this, the standard execution cycle begins. The CPU will read the value at the address stored in the IP, from the current segment (Stored in SEG). If this is a valid opcode then it is executed, and finally the IP is incremented by a number of bytes appropriate to the opcode. Then the cycle begins anew.
Nominally, the machine runs at a rate of 1MHz (1,000,000 cycles per second). The machine will continue executing cycles until the machine has been halted, powered down, destroyed, or committed suicide.

Faults and Signals

Various instructions may during their run may indicate a fault by raising a signal. On the first signal the SIG register is simply set to a value indicating the specific fault that occurred. The loaded code may simply check this register at any time to determine if a signal has been raised, and of what kind. It may handle to signal in a way of its choosing and clear the signal by either raising the signal NONE, or simply clearing the SIG register.

Should a signal be raised before an existing signal has been cleared, A Double Fault is triggered, and signal is processed instead. A double-fault causes the SEG and IP registers to be cleared, thus returning execution to the first address of the first segment, the SIG register will indicate a double-fault, all other registers and storage locations will be unaffected. Finally, should a further fault be signalled before a Double-Fault has been cleared. the machine machine will simply halt.

Clone this wiki locally