Mime.mesa
Carl Hauser, May 7, 1987 3:00:07 pm PDT
DIRECTORY
Rope USING [ROPE];
Mime: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE = Rope.ROPE;
AssembleOneInstruction: PROC [r: ROPE] RETURNS [bytes: ROPE];
Hand it a rope generated by the grammar below and it will hand you back a rope containing the bytes representing that instruction for Dragon. For Example
"JB -2" as input yields "097H, 0FEH -- JB -2" as output.
END.
Assembler Syntax
Note: where expressions are required below, the current assembler accepts Decimal, Octal and Hex constants and their negations. i.e. 1, 0FH, -0FH, 17B. Note that hex constants must begin with a decimal digit. For similar reasons, the output bytes are supplied with a leading 0 digit.
Goal Symbol: SingleInstruction => I | LC | LR | LB | LH | LW | LBD | RRR | QR | RD | XO | XRO
I => I—Instruction
I—Instruction => I-format instructions from the Dragon Instruction Set summary plus the J1, J2, J3, and J5 instructions which the assembly coder should consider to be I-format and less the LCm instructions (use LC).
LC => LC m: an expression this is actually a macro instruction: it will choose the appropriate instruction LCm, LIB, LIDB, or LIQB depending on the value of the expression
ConstantRegisterIndex => an expression in [0..12) | -1 | -2 | 80000000H -1, -2, and FIRST[INT] are translated to the appropriate constant register index.
LR => LR—Instruction n: AuxOrLocalRegisterIndex
LR—Instruction => LRn | SRn
AuxOrLocalRegisterIndex => an expression IN [0..16)
LB => LB—Instruction Byte
LB—Instruction => LB-format instructions from the Dragon Instruction Set summary.
Byte => an expression IN [-128..256)
LH => LH—Instruction Halfword
LH—Instruction => LH-format instructions from the Dragon Instruction Set summary.
Halfword => an expression IN [-32768..65535)
LW => LW—Instruction Word
LW—Instruction => LW-format instructions from the Dragon Instruction Set summary.
Word => an expression
LBD => LBD—Instruction comparand: Byte , displacement: Byte
LBD—Instruction => LBD-format instructions from the Dragon Instruction Set summary.
RRR => RRR—Instruction c: DestinationReg , a: SourceReg , b: SourceReg
RRR—Instruction => RRR-format instructions from the Dragon Instruction Set summary.
DestinationReg => GeneralReg | Push
SourceReg => GeneralReg | PopTop | PopUnder
GeneralReg =>
AUX AuxOrLocalRegisterIndex |
LOCAL AuxOrLocalRegisterIndex |
CONSTANT ConstantRegisterIndex |
Top | Under
QR => QR—Instruction ca: CASpec , b: SourceReg
QR—Instruction => QR-format instructions from the Dragon Instruction Set summary.
CASpec => TopATop | PushATop | PushA0 | PushA1
RD => RD—Instruction s: ShortSourceReg , b: SourceReg , displacement: Byte
RD—Instruction => RD-format instructions from the Dragon Instruction Set summary.
ShortSourceReg => Constant0 | Constant1 | Top | PopTop
XO => XO—Instruction n: AuxOrLocalRegisterIndex , offset: Byte
XO—Instruction => LRIn | SRIn
XRO => XRO—Instruction a: SourceReg , b: SourceReg , offset: Byte
XRO—Instruction => XRO-format instructions from the Dragon Instruction Set summary.