Mal Syntax
MIC-1 Syntax is so simple and becomes best explained in "Architettura dei Computer" by Andrew S. Tanembaum.
But we must indicate information about the MAL translator for this emulator.
Every instruction can have inside some, all or none of the following fields:
1)Label
2)Assignment and eventual operation
3)Shift
4)read and write of the memory
5)Branch
6)Comment
EVERY FIELD,excluding the label field and the shifts, HAS TO BE DIVIDED FROM OTHERS USING A " ; ".
1)Labels
Labels can contain any alphanumeric value.
Label HAVE TO be separed from the rest of the instruction using the following character " : ".
2)Assignments doesn't have particular restrictions, they seek the Tanembaum's specifics.
You can do multiple assignments.
Bit-to-Bit of register is obtainable writing, for example: TOS=not(TOS).
The OR of H register with another register is obtainable writing for example TOS=H OR TOS (commutative property is available), AND is obtainable writing TOS=TOS AND H;
3)Shifts needs to be indicated only and only after an assignment, without ";" . You can choose beetween shift left 8 position (<<8) and right shift 1 position (>>1)
Shifts HAVE TO be made by as the following:
H=1 <<8
TOS=1 >>1
TOS=1 >>1
4)rd,wr,fetch fields HAVE TO be separed by a " ; ", are permitted contemporary rd,wr,fetch on the same instruction.
5)Conditional Branches HAVE TO be made by as the following:
TOS=H; if(N) goto et1; else goto et2;
Conditional Branches doesn't have particular restrictions except that you can't do a branch without an assignment first.
Unconditional branch does't have particular restrinctions.
Multi-directional branches can be : goto(MBR) or goto(MBR or 0xXYZ).
6)You can insert comments using "//"
Example:
et1: TOS=TOS+1; if(N) goto et1; else goto et2;
et2: TOS=0; goto (MBR);//THIS IS A COMMENT
H=1 <<8;wr;fetch;
H=0;rd;goto et1;
et2: TOS=0; goto (MBR);//THIS IS A COMMENT
H=1 <<8;wr;fetch;
H=0;rd;goto et1;
Note: If microprogram calls an instruction that was not initialized first, the controlStore will return an empty instruction, a sequence of 36 bits with value 0.
This sequence of instructions, or similars, has ambiguous value
MAR=1;rd;
MDR=1;
H=MDR;
priority given to the value coming from the memory