Asmj 8008 syntax

Last revised: 23-Nov-2003
  • Syntax of 8008 machine instructions

    Unless otherwise indicated, all words of all instructions (patterns whose names end in "_instr") must be separated by one or more spaces. We omit those from the syntax expressions for brevity. In other patterns, there are no such omissions; spaces are needed as explicitly specified.

    1. Inherent

      Inherent instructions do not need any information to tell where to find the data to operate on; it is implicitly specified as part of the instruction itself. For instance, the "rlc" instruction always rotates the contents of accumulator A; it cannot rotate anything else. Syntactically, these are the simplest possible instructions.

      	inherent_op ::= "rlc"|"rrc"|"ral"|"rar"
      	               |"rc"|"rnc"|"rz"|"rnz"
      	               |"rp"|"rm"|"rpe"|"rpo"
      	               |"ret"|"hlt"
      	inherent_instr ::= [label] <inherent_op> [<comment>]
      

    2. One operand

      Some instructions find one operand either in memory or in a register. They either operate on this operand alone, or with another that is implicitly specified by the instruction (often accumulator A). If the operand is in memory, its address is formed by the contents of the H and L registers. The syntax of these instructions is as follows:

      	reg1_op ::= "add"|"adc"|"sub"|"sbb"
      	           |"ana"|"xra"|"ora"|"cmp"
      	           |"inr"|"dcr"
      	reg1_arg1 ::= ("a"|"b"|"c"|"d"|"e"|"h"|"l"|"m")
      	reg1_instr ::= [label] <reg1_op> <reg1_arg1> [<comment>]
      

    3. Two operands

      Both forms of the move instruction use two operands. Each operand of the 'mov' instruction can be in memory or in a register. (But both cannot be in memory). Likewise, the first operand (the destination) of the 'mvi' instruction can be memory or register; but its second operand must be a constant. If an operand is in memory, its address is formed by the contents of the H and L registers. The syntax of these instructions is as follows:

      	reg2_op ::= "mov"|"mvi"
      	reg2_arg ::= <arg1> "," <arg1>
      	reg2_instr ::= [label] <reg2_op> <reg2_arg> [<comment>]
      

    4. Immediate

      The operand is the byte (or word) in memory immediately following the opcode. The operand is a numeric expression. For purposes of syntax, we can treat branch and call instructions as immediate - the operand is just a numeric expression that follows the opcode. Similarly, the "rst", "in", "out", "lda", "sta", "lhld", and "shld" instructions can be thought of as immediate for purposes of syntax.

      	imm_op ::= "adi"|"aci"|"sui"|"sbi"|"ani"|"xri"|"ori"|"cpi"
      	          |"jmp"|"jc"|"jnc"|"jz"|"jnz"|"jp"|"jm"|"jpe"|"jpo"
      	          |"call"|"cc"|"cnc"|"cz"|"cnz"|"cp"|"cn"|"cpe"|"cpo"
      	          |"ret"|"rc"|"rnc"|"rz"|"rnz"|"rp"|"rm"|"rpe"|"rpo"
      	          |"rst"|"in"|"out"
      	immediate_instr ::= [label] <imm_op> <numeric_expression>