MACHOP SYNTAX

The following is the syntax of a MACHOP in the syntax of SLIC



MACHOP_DECL = '.MACHOP' (ID | '#' ID) 
                 {MACH_ARG $(',' MACH_ARG)
                 {',' '$' MACH_ARG} | '$' MACH_ARG '->'}
                 $MACHOP_LINE {MACH_VECTOR_DEF};

MACH_ARG = ({ '-' -'>' | '+') ID } { '@' ID } { ID | '%' ID }
                    { '(' ID ')' | '[' ID ']'(ID |) };

MACHOP_LINE = (IRP '<' $MACHOP_LINE '>' |
               MORG_ST | ORG_ST | MACH_IF_ST | MACHOP_FIELD);

OP_LINES = '{' %MACHOP_LINE '}' | MACHOP_LINE

MORG_ST = '.MORG' EXPR ':' PC_OUT ';';

ORG_ST =  '.ORG' PC_OUT ';';

MACH_IF_ST = 'if' EXPR 'then' OP_LINES {'else' OP_LINES}

RADIX = ('H' | 'X' | '+H' | '+X' | 'O' | '+O' | 'D' | '+D'
             | 'B' | '+B' | '^' NUMBER |'+^' NUMBER)

PC_OUT = RADIX  '(' EXPR ')' ':' EXPX;

MACHOP_FIELD = RADIX | 'N' | '%N') $MACHOP_SUB_FIELD;

MACHOP_SUB_FIELD = IRP '<' $MACHOP_SUB_FIELD '>' 
                     | '('EXPX')' ':' EXPX ';':

IRP = ('.IRPC' | '.IRP') EXPX ':' ID;

MACH_VECTOR_DEF = '#' VECTOR_TRIPLE $('#' VECTOR_TRIPLE);

VECTOR_TRIPLE = ID NUM_CON { STRING }';';

NUM_CON = HEX_CON | OCT_CON | BIN_CON | STRING | NUMBER;

The function of a MACHOP is twofold in that it defines how operands of a machine instruction are to be combined to produce the binary code, and how the pseudo assembly listing for that instruction should look.

The first thing is to align our bit address pointer to the targets address resolution. The IPX86 is byte addressable modulo 8, while the 68000 instructions must be word aligned modulo 16. The DEC 10 is a 36-bit word machine alignment of modulo 36. In a MACHOP we use the .MORG statement to align our output.

   .MORG modulo : format(size): value;

   .MORG 8:...   align to byte boundry

   .MORG 16: ... align to word boundry

Further the MORG statement outputs the location to the assembly listing. The radix and size, in bits, of the output field is specified as well as an expression that scales the location counter $ for output.

   .MORG 8: +H(16): $/8;

Align to byte boundary, divide the location counter by 8 (bit address to byte address) and output the low 16 result bits in relocatable hex format

   .MORG 16: +H(16): $/8;

The above would be used in instruction on a 68000 target as it is a byte addressable machine but instructions must begin on a word boundary.

Bit fields are output. We may wish to group several output fields together in the pseudo assembly listing. This is done by specifying the radix only the first field output of the group.

      H(2): mod;
       (3): reg;
       (3): R_M;

The above outputs three fields to the object file while the assembly listing would format them as one 8 bit field in hex format. That's not quite true. If mod, reg and R_M can be evaluated to numeric values at compile time they would not be separate fields in the object file.

Return to example page

Return to the main page