Micro-Assembly Language (MAL) Specification

This document is a brief introduction to Micro-Assembly Language (MAL), the language accepted by the mic1 micro-assembler. It describes the lexical, syntactic, and semantic elements of the language, and gives a few pointers on microprogramming with the mic1 micro-assembler.

For a brief introduction to microprogramming and a complete description of the microarchitecture targeted by the mic1 micro-assembler, consult Chapter 4, Tanenbaum, Andrew S.: Structured Computer Organization, 4th Ed. (Prentice-Hall 1999).

Like most assembly languages, the Micro-Assembly Language is a line-oriented language. Each micro-instruction is generally defined on a single line of the program file. Blank lines and lines containing only a comment are ignored. The end-of-line is generally significant.

Also, MAL is case-sensitive. For example, "AND" is a reserved word corresponding to a bitwise operation of the mic1 ALU, while "and" is not reserved and may be used as a label (for an AND instruction which may occur in the ISA-level instruction set, for example).

2.1. Comments

All comments begin with two slash characters ("//") and continue to the end of the line. Blank lines, and lines consisting only of white space and comments are ignored by the micro-assembler.

2.2. Directives

Directives for the micro-assmebler begin with a period character (".") and may contain alphabetic characters.

There are two micro-assembler directives: ".default" and ".label". Directives are used to provide guide the behavior of the micro-assembler, and do not correspond with words in the control store. These are defined more fully below.

2.3. Reserved Words

The names of registers and control lines are reserved, as are the words "if", "else", "goto", "nop", "AND", "OR", and "NOT". For the mic1 architecture, the following words are reserved and may not be used as statement labels:

MAR MDR PC MBR MBRU SP LV CPP TOS OPC H Z N rd wr fetch if else goto nop AND OR NOT

2.4. Decimal Literals

Decimal literals used by are one the following numeric strings: "0", "1", "8". These are used as numeric constants in MAL.

2.5. Hexadecimal Literals

Hexadecimal literals are strings beginning with "0x" and followed by one or more hexadecimal digits ("0"-"9") or letters ("a"-"f" or "A"-"F"). These are used as addresses or address masks in MAL.

2.6. Special Characters

The following characters have special meaning in micro-assembly language:

All characters and tokens which are not specifically described above are disallowed in MAL.

The following grammar describes the language accepted by the mic1 micro assembler. eol , label , and address (hexadecimal numeric literal), are terminal symbols, as are all strings enclosed in double-quotes ("). All other symbols below are non-terminals. "program" is the start symbol.

program ::= line_sequence ; line_sequence ::= line line_sequence | ; line ::= instruction eol | directive eol | eol ; instruction ::= label statement_sequence | statement_sequence | label ; directive ::= ".label" label address | ".default" statement_sequence ; statement_sequence ::= statement ";" statement_sequence | statement ";" | statement ; statement ::= io_statement | control_statement | assignment_statement | nop_statement ; io_statement ::= "rd" | "wr" | "fetch" ; control_statement ::= if_statement | multiway_branch_statement | goto_statement ; if_statement ::= "if" "(" condition ")" "goto" label ";" "else" "goto" label ; condition ::= "N" | "Z" ; multiway_branch_statement ::= "goto" "(" mb_expr ")" ; mb_expr ::= "MBR" "OR" address | "MBR" ; goto_statement ::= "goto" label ; assignment_statement ::= target "=" assignment_statement | expr ; target ::= c_register | "N" | "Z" ; c_register ::= "MAR" | "MDR" | "PC" | "SP" | "LV" | "CPP" | "TOS" | "OPC" | "H" ; expr ::= operation | operation "" ">" "1" ; operation ::= a_term "AND" b_term | b_term "AND" a_term | a_term "OR" b_term | b_term "OR" a_term | "NOT" b_term | "NOT" a_term | b_term "+" a_term | a_term "+" b_term | b_term "+" "1" | a_term "+" "1" | b_term "-" a_term | "-" a_term | b_term "-" "1" | b_term "+" a_term "+" "1" | a_term "+" b_term "+" "1" | b_term | a_term | "-" "1" | "0" | "1" ; b_term ::= "MDR" | "PC" | "MBR" | "MBRU" | "SP" | "LV" | "CPP" | "TOS" | "OPC" ; a_term ::= "H" ; nop_statement ::= "nop" ;

4.1. Directive Semantics

.default

The .default directive allows us to specify a default instruction to place in any unused addresses of the control store. For example:

.default goto err1

This would help "catch" any unintended multiway branches which are not explicitly accounted for in the microcode.

.label

Labeled statements are "anchored" at the specified control store address. Any statement having the label will be located at that specific location in the control store. This directive allows the multiway branch statemnts such as "goto (MBR)" or "goto (MBR OR 0x100)" to dispatch to a known location.

.label nop1 0x00 .label bipush1 0x10

4.2 Statement Semantics

Lines which contain a label, a statement_sequence, or both a label and a statement_sequence are considered to be specifiers for a micro-instruction, that is, for a word in the control store.

If a line begins with a label, its statement may be the target of an explicit goto.

If a statement contains an explicit goto label, there must be a statement having that label as its statement label.

Register names which appear to the left of an equal sign (" +", "-", "", "AND", "OR", "NOT", "0", "1", and "8" which appear without an equal sign (" rd", "wr", and "fetch", cause the appropriate bits to be set in the control store for enabling the corresponding control lines.

"if", "else", and "goto" are used to set the JAMN, JAMZ, and JMPC, bits of the micro-instruction, along with the NEXT_ADDRESS field.

"nop" is a place-holder which allows us to have a do-nothing instruction without a label.

For a complete example of a mic1 micro-program see mic1ijvm.mal which implements an interpreter for a simplified (integer) subset of a Java Virtual Machine.