Old Software
Home ] Up ] New Stuff ] Minix Port ] Magic-2? ] Overview ] Photo Gallery ] Construction ] Technical Info ] My Other Projects ] Links ]

Source Code

[NOTE: Everything on this page is at least a year out of date.  Simulator rewrite in progress as of 5/11/2003]]

This web site is the working storage for the project, and as it progresses the build mechanism will treat this as the official sources.   Here's where I'll be placing descriptions of the software I'm doing, as well at source snapshots of the build.

ANSI C Compiler

I've retargeted lcc 4.1 to Magic-1.  The changes involved writing a new machine description file, magic1.md, and making some trivial changes to the makefile and bind.c.  To build Magic-1 lcc, grab the official 4.1 source package and apply my changes [TODO - add link].

Microcode

The heart of the system is the microcode.  Here's the listing.  

PROM Data

I'll be using a 5  512x8 74S472 blown-fuse PROMs, and have written a simple utility program to extract the actual bits from the microcode web page and then create seven data files describing the bits in Intel hex format.  That's what we'll be feeding to the PROM programmer (whilst keeping my fingers crossed that it will actually program the 74S472's that I've located.

Microcode-level Simulator

The purpose of this simulator is to validate my microcode and also to provide a guide and sanity check in constructing the control signals.  I only intend it to operate a few instructions at a time (the output is very verbose).  It is organized as a loop over an array of unit handlers, with trips into each handler for each trailing and leading edge of the system clock, with control signal generation in between.  In other words, it's not a speed-burner.  My eventual plans are to construct a separate functional simulator which is automatically generated from the instruction descriptions in a yet-to-be-written Instruction Set Architecture manual, but who knows whether I'll get around to that.

Here's some sample output - it's one of the earliest traces, showing a call, enter, leave, return and halt:

Assembler

I'm looking forward to writing an assembler - however the one I want to do will have to wait until I can devote more time to it.  I think I really discovered the fun of programming with the old Microsoft Macro-80 assembler (one of the few Microsoft products I consider top-notch).  The assembler I have in mind will be modeled after Macro-80, and will be a significant project in its own right.  However, I need some sort of assembler now in order to speed testing of the microcode.  So, we'll start off with a quick-and-dirty assembler called "qas".  My first thoughts on how to put it together quickest was to do a pattern-match off of the opcode text strings gleaned from the microcode web page.  However, I decided that this was a really good opportunity to play with lex and yacc. 

Qas will support standard directives:

bulletglobal   <label>        // Export a symbol
bulletextern   <label>        // Import a symbol
bulletequ      <label>        // Define a constant
bulletcseg                    // Switch to code segment
bulletdseg                    // Switch to data segment
bulletorg      address        // Define current segment load address
bulletdefb     value[,value]* // Dump a byte value
bulletdefw     value[,vlaue]* // Dump a word value
bulletdefbr    value,count    // Repeat the same byte count times
bulletdefwr    value,count    // Repeat the same word count times
bulletend      [<label>]      // End assembly and optionally define start address

Labels will be colon-terminated, and comments may be either ";" or "//".  Further, we'll allows high byte and low byte functions, as well as standard arithmetic expressions.  Labels are case-sensitive, but all else is case insensitive.  Here's an example of what things will look like:


    global start
    cseg
    org 0x0000

; Defines here
one equ 0x1
two equ 0x2
three equ 3

start:                // Start here
    ld.16 a,one
    sub.8 a,(three - 1)
    cmpb.eq.8 a,high(0x0ff0),start

    end start