Assembly Syntax

Operands

The following operand syntax types are used in instructions

ShortNameDescription
GPRGPR operandA General Purpose Register
SGPRShifted GPR operandA General Purpose Register Left-shifted by a constant
IORI/O Register operandAn I/O Transfer Register (Map 3)
ANYREGAny RegisterAny Register operand
UIMM16Immediate (unsigned 16-bit)16-bit Immediate operand
SIMM16Immediate (signed 16-bit)16-bit Immediate operand
PCREL16PC Relative Address (16-bit)16-bit offset from IP in bytes
OFF20Jump Offset (signed 20-bit)20-bit jump offset in words
UIMM32Immediate (unsigned 32-bit)32-bit immediate operand
SIMM32Immediate (signed 32-bit)32-bit immediate operand
BITWBit WidthWidth of a value in bits
BYTESZByte SizeSize of a value in bytes
ABSIMM3Immediate (unsigned 3-bit)3-bit absolute (non-relocated) immediate
ABSIMM5Immediate (unsigned 5-bit)5-bit absolute (non-relocated) immediate
ABSIMM6Immediate (unsigned 6-bit)6-bit absolute (non-relocated) immediate
ABSIMM8Immediate (unsigned 8-bit)8-bit absolute (non-relocated) immediate
CCCondition Code NameA condition Code

GPR operands

A GPR operand is written as r followed by the index number of the register.

Shifted GPR

A Shifted GPR operand is written as GPR << ABSIMM5

I/O Register Operand

An I/O Register Operand is written as io followed by the index number of the register.

Any Register

A Register in any map is either a GPR operand, and I/O Register operand, a system configuration register, a system information register, or a coprocessor register.

A system configuration register is written as either sys followed by the index number of the register or the alias name specified in the ISA (for example, the System Control Register may be written as sys0 or sysctl).

A system information register is written as info followed by the index number of the register.

A coprocessor register is written as co followed by the coprocessor number between 0 and 3, followed by r, followed by the register number. If the Assembler is aware of the particular coprocessor expected in a given coprocessor slot, it may use the alias name provided by the Coprocessor's Assembly Supplement. For example, if the Assembler is aware of the presence of a FPU (according to <float-coproc.md>) in slot 0, it may alias f0 as co0r0.

Immediates

Immediate operands take an integer or a symbol. n-bit Unsigned Immediates require an unsigned quantity in [0,2^n). Signed Immediates require a signed quantity in [-2^(n-1), 2^(n-1)).

Other than Absolute Immediates (like ABSIMM6), immediate operands can have symbols. Unless specified with the @pcrel modifier, Immediate operands always treat symbols as absolute address in relocations. The relocation requires that the address fits in the specified size of immediate (a link error occurs if it does not). using the special modifiers HI and LO allows you to instead specify the lower or upper 16-bits of the symbol.

Unless modified, immediate relocations uses (given the appropriate n):

  • R_MICRON_<n>
  • R_MICRON_LO16 (LO <sym>)
  • R_MICRON_HI16 (HI <sym>)

With the @pcrel modifier (or for PCREL16, see below), the relocation uses (given the appropriate n):

  • R_MICRON_PC16
  • R_MICRON_LOPC16 (LO <sym>@pcrel)
  • R_MICRON_HIPC16 (HI <sym>@pcrel)

Offsets

The PCREL16 and OFF15 values are special cases of immediates. PCREL16 is identical to a SIMM16 relocation, except that it defaults to resolving the specified symbol using a pc-relative relocation.

OFF15 is a 15-bit immediate that resolves a 17-bit pc-relative relocation or a 17-bit signed integer offset, and discards the lower two bits to encode the instruction. It has two constraints, in addition to the constraints that would apply to a 22-bit signed immediate:

  • Absolute Expressions must be divisible by 4, and
  • Relocation Expressions must produce a 4-byte aligned quantity. The Assembler may error if a misalignment is reliably detected (for example, a 3-byte offset from a symbol known to be 4-byte aligned).

OFF15 uses R_MICRON_JMPOFF relocation.

Sizes/Widths

A size or width expression is an absolute immediate that encodes a size (in bytes) or a width (in bits).

A BITW operand is a 5-bit unsigned absolute immediate that can take on any value between 1 and 32. 32 is encoded as 0. As a special case, the following synthetic constants are defined for BITW operands with the following values:

  • byte: 8
  • half: 16
  • word: 32.

A BYTESZ operand is a 2-bit immediate with a special encoding of lg(sz) where sz is the real size in bytes. The value must be a power of 2 less than 8. The same synthetic constants are defined above to be 1, 2, and 4 respectively.

Condition Code

Condition Codes appear only in mnemonics, and use the following 1 or 2 character short forms:

Short FormCondition NameNumberCanonical
NVNever0Yes
CCarry1Yes
BBelow1No
ZZero2Yes
EQEqual2No
OOverflow3Yes
CECarry/Equal4Yes
BEBelow or Equal4No
LTLess5Yes
LELess or Equal6Yes
NNegative7Yes
SSigned7No
PPositive8Yes
NSNot Signed8No
GTGreater Than9Yes
NLENot Less or Equal9No
GEGreater or Equal10Yes
NLTNot Less10No
AAbove11Yes
NBENot Below or Equal11No
NCENot Carry or Equal11No
NONot Overflow12Yes
NZNot Zero13Yes
NENot Equal13No
NCNot Carry14Yes
NBNot Below14No
AEAbove or Equal14No
ALAlways15Yes

Instruction Syntax

The following charts describes how assemblers should interpret and assemble given instruction syntax forms and mnemonics.

Each Chart has the following information:

  • Mnemonic: The name of the instruction, which should be interpreted case-insentively. The special variables <c> and <x> may be written here. c is as if defined CC <c> and x is as if defined ABSIMM2 <x>.
  • Operands: A list of operands written as the Short ID followed by a variable in <> (e.g. GPR <d>)
  • Opcode: The Opcode of the instruction. This may reference the special variable x if defined in the Mnemonic.
  • Special Payload Encoding: A list of variable assignments of the form <var>=<val> where var is an encoding variable defined for the opcode in the ISA Spec, and val is either an integer expression or a variable. Implicitly the name of each encoding variable that is defined as a syntax variable in the Mnemonic or the Operands list is assigned to the value of that syntax variable. The special encoding variable P refers to the entire 24-bit payload (where its contents are undefined/ignored)
  • Canonical: Describes whether or not the instruction specification is canonical Canonical Specifications are the primary (or only) way to describe a particular encoding (without a .instr directive). Non-canonical encodings may describe a more efficient way to write or read a particular encoding, or may be useful in niche circumstances. Disassemblers and machine-code generators (such as assembly printing from a compiler) should prefer the canonical specification if it has no context otherwise.

UND

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
UND-0x00P=0Yes

PAUSE

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
PAUSEABSIMM6 <k>0x01N/AYes
NOP-0x01k=0No

MOV

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
MOV<c>GPR <d>, GPR <s>0x02m=0, r=0, l=0Yes
MOV<c>GPR <d>, ANYREG <s>0x02m=MAP(s), r=0, l=0Yes
MOV<c>ANYREG <d>, GPR <s>0x02m=MAP(d), r=1, l=0Yes
MOVGPR <d>, GPR <s>0x02m=0, r=0, l=0, c=15No
MOVGPR <d>, ANYREG <s>0x02m=MAP(s), r=0, l=0, c=15No
MOVANYREG <d>, GPR <s>0x02m=MAP(d), r=1, l=0, c=15No
MOVL<c>GPR <d>, GPR <s>0x02m=0, r=0, l=1Yes
MOVL<c>GPR <d>, ANYREG <s>0x02m=MAP(s), r=0, l=1Yes
MOVL<c>ANYREG <d>, GPR <s>0x02m=MAP(d), r=1, l=1Yes

LD/ST

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
LDGPR <d>, GPR <s>, BYTESZ <w>0x03p=0Yes
STGPR <d>, GPR <s>, BYTESZ <w>0x04p=0Yes
LDGPR <d>, GPR <s>0x03p=0,w=4No
STGPR <d>, GPR <s>0x04p=0,w=4No
PUSHGPR <d>, GPR <s>, BYTESZ <w>0x04p=1Yes
POPGPR <d>, GPR <s>, BYTESZ <w>0x03p=1Yes
PUSHGPR <d>, GPR <s>0x04p=1,w=4No
POPGPR <d>, GPR <s>0x03p=1,w=4No
PUSHGPR <s>0x04p=1,w=4,d=30No
POPGPR <d>0x03p=1,w=4,d=30No

ADDI

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
ADDIGPR <d>, SIMM16 <i>0x08s=1,c=0,h=0Yes
ADDIUGPR <d>, UIMM16 <i>0x08s=0,c=0,h=0Yes
ADDIHGPR <d>, UIMM16 <i>0x08s=0,c=0,h=1Yes
ADDIHGPR <d>, SIMM16 <i>0x08s=0,c=0,h=1No
ADDINCGPR <d>, SIMM16 <i>0x08s=1,c=1,h=0Yes
ADDIUNCGPR <d>, UIMM16 <i>0x08s=0,c=1,h=0Yes
ADDIHNCGPR <d>, UIMM16 <i>0x08s=0,c=1,h=1Yes
ADDIHNCGPR <d>, SIMM16 <i>0x08s=0,c=1,h=1No
INCGPR <d>0x08s=0,c=0,h=0,i=1No
DECGPR <d>0x08s=1,c=0,h=0,i=0xFFFFNo

ALU Ops

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
ADDGPR <d>, SGPR <a> << <s>, GPR <b>0x09c=0,p=0Yes
ADDGPR <d>, GPR <a>, SGPR <b> << <s>0x09c=0,p=1Yes
ADDGPR <d>, GPR <a>, GPR <b>0x09c=0,p=0,s=0No
ADDNCGPR <d>, SGPR <a> << <s>, GPR <b>0x09c=1,p=0Yes
ADDNCGPR <d>, GPR <a>, SGPR <b> << <s>0x09c=1,p=1Yes
ADDNCGPR <d>, GPR <a>, GPR <b>0x09c=1,p=0,s=0No
SUBGPR <d>, SGPR <a> << <s>, GPR <b>0x0Ac=0,p=0Yes
SUBGPR <d>, GPR <a>, SGPR <b> << <s>0x0Ac=0,p=1Yes
SUBGPR <d>, GPR <a>, GPR <b>0x0Ac=0,p=0,s=0No
SUBNCGPR <d>, SGPR <a> << <s>, GPR <b>0x0Ac=1,p=0Yes
SUBNCGPR <d>, GPR <a>, SGPR <b> << <s>0x0Ac=1,p=1Yes
SUBNCGPR <d>, GPR <a>, GPR <b>0x0Ac=1,p=0,s=0No
ANDGPR <d>, SGPR <a> << <s>, GPR <b>0x0Bc=0,p=0Yes
ANDGPR <d>, GPR <a>, SGPR <b> << <s>0x0Bc=0,p=1Yes
ANDGPR <d>, GPR <a>, GPR <b>0x0Bc=0,p=0,s=0No
ANDNCGPR <d>, SGPR <a> << <s>, GPR <b>0x0Bc=1,p=0Yes
ANDNCGPR <d>, GPR <a>, SGPR <b> << <s>0x0Bc=1,p=1Yes
ANDNCGPR <d>, GPR <a>, GPR <b>0x0Bc=1,p=0,s=0No
ORGPR <d>, SGPR <a> << <s>, GPR <b>0x0Cc=0,p=0Yes
ORGPR <d>, GPR <a>, SGPR <b> << <s>0x0Cc=0,p=1Yes
ORGPR <d>, GPR <a>, GPR <b>0x0Cc=0,p=0,s=0No
ORNCGPR <d>, SGPR <a> << <s>, GPR <b>0x0Cc=1,p=0Yes
ORNCGPR <d>, GPR <a>, SGPR <b> << <s>0x0Cc=1,p=1Yes
ORNCGPR <d>, GPR <a>, GPR <b>0x0Cc=1,p=0,s=0No
XORGPR <d>, SGPR <a> << <s>, GPR <b>0x0Dc=0,p=0Yes
XORGPR <d>, GPR <a>, SGPR <b> << <s>0x0Dc=0,p=1Yes
XORGPR <d>, GPR <a>, GPR <b>0x0Dc=0,p=0,s=0No
XORNCGPR <d>, SGPR <a> << <s>, GPR <b>0x0Dc=1,p=0Yes
XORNCGPR <d>, GPR <a>, SGPR <b> << <s>0x0Dc=1,p=1Yes
XORNCGPR <d>, GPR <a>, GPR <b>0x0Dc=1,p=0,s=0No
CMPSGPR <a><< <s<, GPR <b>0x0Ac=0,p=0,d=0No
CMPGPR <a>, SGPR <b> << <s>0x0Ac=0,p=1,d=0No
CMPGPR <a>, GPR <b>0x0Ac=0,p=0,s=0,d=0No
TESTSGPR <a><< <s<, GPR <b>0x0Bc=0,p=0,d=0No
TESTGPR <a>, SGPR <b> << <s>0x0Bc=0,p=1,d=0No
TESTGPR <a>, GPR <b>0x0Bc=0,p=0,s=0,d=0No
SHLGPR <d>, GPR <a>, ABSIMM5 <s>0x09c=0,p=0,b=0No
SHLNCGPR <d>, GPR <a>, ABSIMM5 <s>0x09c=1,p=0,b=0No

Shifts

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
BSLGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=0, x=0,c=0Yes
BSLWGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=1, x=0, c=0Yes
BSLNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=0,x=0,c=1Yes
BSLWNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=1,x=0,c=1Yes
XBSLGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=0, x=1,c=0Yes
XBSLWGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=1, x=1, c=0Yes
XBSLNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=0,x=1,c=1Yes
XBSLWNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Ew=1,x=1,c=1Yes
SHLGPR <d>, GPR <v>, GPR <q>0x0Ew=0,x=0,c=0,r=0No
SHLWGPR <d>, GPR <v>, GPR <q>0x0Ew=1,x=0,c=0,r=0No
SHLNCGPR <d>, GPR <v>, GPR <q>0x0Ew=0,x=0,c=1,r=0No
SHLWNCGPR <d>, GPR <v>, GPR <q>0x0Ew=1,x=0,c=1,r=0No
ROLGPR <d>, GPR <v>, GPR <q>0x0Ew=1,x=0,c=0,r=vNo
ROLNCGPR <d>, GPR <v>, GPR <q>0x0Ew=1,x=0,c=1,r=vNo
BSRGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=0, x=0,c=0Yes
BSRWGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=1, x=0, c=0Yes
BSRNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=0,x=0,c=1Yes
BSRWNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=1,x=0,c=1Yes
XBSRGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=0, x=1,c=0Yes
XBSRWGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=1, x=1, c=0Yes
XBSRNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=0,x=1,c=1Yes
XBSRWNCGPR <d>, GPR <v>, GPR <q>, GPR <r>0x0Fw=1,x=1,c=1Yes
SHRGPR <d>, GPR <v>, GPR <q>0x0Fw=0,x=0,c=0,r=0No
SHRWGPR <d>, GPR <v>, GPR <q>0x0Fw=1,x=0,c=0,r=0No
SHRNCGPR <d>, GPR <v>, GPR <q>0x0Fw=0,x=0,c=1,r=0No
SHRWNCGPR <d>, GPR <v>, GPR <q>0x0Fw=1,x=0,c=1,r=0No
RORGPR <d>, GPR <v>, GPR <q>0x0Fw=1,x=0,c=0,r=vNo
ROLRCGPR <d>, GPR <v>, GPR <q>0x0Fw=1,x=0,c=1,r=vNo
SARGPR <d>, GPR <v>, GPR <q>0x0Fw=0,x=1,c=0,r=0No
SARWGPR <d>, GPR <v>, GPR <q>0x0Fw=1,x=1,c=0,r=0No
SARNCGPR <d>, GPR <v>, GPR <q>0x0Fw=0,x=1,c=1,r=0No
SARWNCGPR <d>, GPR <v>, GPR <q>0x0Fw=1,x=1,c=1,r=0No

Branches

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
JL<c>GPR <l>, OFF15 <o>0x10-Yes
JLR<c>GPR <l>, GPR <r>0x11-Yes
JMP<c>OFF15 <o>0x10l=0No
JMPR<c>GPR <r>0x11l=0No
JMPOFF15 <o>0x10l=0,c=15No
JMPRGPR <r>0x11l=0,c=15No
CALLGPR <l>, OFF16 <o>0x10c=15No
CALLRGPR <l>, GPR <r>0x11c=15No
CALLOFF16 <o>0x10l=31,c=15No
CALLRGPR <r>0x11l=31,c=15No

I/O Transfers

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
INIOR <d>, ABSIMM8 <p>, BITW <w>0x14-Yes
OUTIOR <s>, ABSIMM8 <p>, BITW <w>0x15-Yes

Coprocessor Invocations

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
CPI<x>ABSIMM4 <f>, VPAYLOAD20 <p>0x20+x-Yes
CPI<x>EFABSIMM6 <f>, VPAYLOAD18 <p>0x28+x-Yes
NCPI<x>ABSIMM4 <f>, VPAYLOAD20 <p>0x30+x-Yes
NCPI<x>EFABSIMM6 <f>, VPAYLOAD20 <p>0x38+x-Yes

Stop/Halt

MnemonicOperandsOpcodeSpecial Payload EncodingCanonical
HLT-0x40-Yes
STP-0x41-Yes