## Architecture 32 bit instruction width/word size ## Instruction Types: Type Sizes: - u16: [16 bits] - u6: [6 bits] - Reg: [5 bits] - Opcode: [6 bits] Instruction Types: - R: [Opcode] [Reg] [Reg] [Reg] [Reg] [u6] - I: [Opcode] [Reg] [Reg] [u16 ] ## Instruction Set // move mov [ unused ] cmov // load ldb ldbs ldh ldhs ldw // store stb sth stw // immediate lli [unused] lui [unused] // comparison ieq [unused] ine [unused] igt [unused] ige [unused] ilt [unused] ile [unused] // Jump jmp [ unused ] // unconditional jez // conditional on cmp == 0 jnz jic [ unused ] // conditional on carry jnc [ unused ] // Bitwise and [unused] // and nnd [unused] // nand or [unused] // or nor [unused] // nor xor [unused] // xor xnr [unused] // xnor not [ unused ] [unused] // not // Arithmetic add sub shl // left shift of rshamt+ishamt shr // right shift // Immediate Arithmetic addi subi // Misc nop (zero/do nothing) int irt hlt // Atomic // Atomic Compare and Swap - compares src and dst, if src acs ## Assembler Pseudoinstructions Definitions: Label - named address, a function or global ``` lwi // loads the literal value of Label|Imm into dest // if src is a Label, take literal value of Label => lli $src, $dest => lui $src, $dest lli // loads the lower 16 bits of the literal value of Label into dest ... -> similarly defined for lui ldw // loads the word at the address of Label into dest ... => similarly defined for ldb, ldbs, ldh, ldhs // load the label value of src into dest with lui/lli => lli $src, $dest => lui $src, $dest => ldw $dest, $dest stw // stores the word in src using the address/label that is dest. // load the literal value of dest into the accumulator with lui/lli => lli $dest, acc => lui $dest, acc => stw $src, acc jmp CASE dest > u16::MAX: => lli $dest, acc => lui $dest, acc => jmp $dest, 0 CASE dest < u16::MAX: // assembler inserts the literal value of dest => jmp $dest, 0 jmp CASE lbl > u16::MAX: AssemblerError! CASE lbl < u16::MAX: => jmp $dest, lbl call => subi spr, 4, spr => stw pcx, spr, 0 => jmp $addr func // push bpr => subi spr, 4, spr => stw bpr, spr, 0 // replace bpr with spr => mov spr, bpr return => mov bpr, spr // pop bpr => addi spr, 4, spr => ldw spr, bpr, 0 // load return addr => ldw spr, ret, 0 => addi, spr, 4, spr => jmp ret, 4 ```