Epiphanic Networks' Wikka : SAPCompiler

Home :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

SAP Compiler


Last edited by KogAdmin:
hardware specs, instruction set commenting
Thu, 13 Apr 2006 16:57 PDT [diff]


Compiler for "Simple As Possible" instruction set, as taught to me by The Evergreen State College comp sci classes. The point is to teach myself to build a compiler using an arbitrary language, and to document it for anyone curious.

Status
Still building... just got started

Instruction Set


SAP1

SAP2 Additions

Lines are terminated with EOL.

Sample source file (test.sap)
LDA 5
SUB 1
ADD 4
OUT
HALT


Hardware Information

The original SAP is rather old, ~30 years if I recall. The design is rather simple - you have an accumulator (register), program memory (16x8bit) and some way of displaying the output (LEDs). Originally we'd switch in the data to the memory locations using the opcodes, and tell the program to run. We'd sit back and see what the SAP spit out.

The machine itself is simple: you end up with a memory stack of X slots of 8 bits (yay for 1 byte!). I believe the bus is 8 bits, with half of the fetched data being an instruction, half of it being the data. You throw it through a MUX, you pass on the address to the address register and the instruction buffer gets the instruction. Then you execute - it's a 6 T state machine (with some fluctuations of course).

If we were truly emulating the hardware, you'd have 16 slots of storage for program and memory (it's not really Von Neumann in it's memory structure), but we're just going to be executing calculations. To that end, you're going to want merely an accumulator register for SAP1, but you're going to want to think about the 16 slots for the SAP2 since you can now store and jump. Input checking should be done on all literals and addresses - addresses should obviously be 4 bits (1->16, you don't want to zero index your memory...), but literals are open to some fudging since we're not really constrained with 4 bits of bus space. I'd say for ease and authenticity let's pretend it's 4 bits.

Step 1: Scanning/Parsing




This page is CategoryResearch

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.1301 seconds