diff --git a/content/isa-docs/lc-2/imgs/add-dark.drawio.png b/content/isa-docs/lc-2/imgs/add-dark.drawio.png new file mode 100644 index 0000000..47c23d6 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/add-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/add.drawio.png b/content/isa-docs/lc-2/imgs/add.drawio.png new file mode 100644 index 0000000..0bd33c3 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/add.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/and-dark.drawio.png b/content/isa-docs/lc-2/imgs/and-dark.drawio.png new file mode 100644 index 0000000..1e0dc67 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/and-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/and.drawio.png b/content/isa-docs/lc-2/imgs/and.drawio.png new file mode 100644 index 0000000..f23b6bd Binary files /dev/null and b/content/isa-docs/lc-2/imgs/and.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/br-dark.drawio.png b/content/isa-docs/lc-2/imgs/br-dark.drawio.png new file mode 100644 index 0000000..6b9eec0 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/br-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/br.drawio.png b/content/isa-docs/lc-2/imgs/br.drawio.png new file mode 100644 index 0000000..92d1bc1 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/br.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/jmp-jsr-dark.drawio.png b/content/isa-docs/lc-2/imgs/jmp-jsr-dark.drawio.png new file mode 100644 index 0000000..2c6d50f Binary files /dev/null and b/content/isa-docs/lc-2/imgs/jmp-jsr-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/jmp-jsr.drawio.png b/content/isa-docs/lc-2/imgs/jmp-jsr.drawio.png new file mode 100644 index 0000000..1bdfbaa Binary files /dev/null and b/content/isa-docs/lc-2/imgs/jmp-jsr.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/jmpr-jsrr-dark.drawio.png b/content/isa-docs/lc-2/imgs/jmpr-jsrr-dark.drawio.png new file mode 100644 index 0000000..f8f1730 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/jmpr-jsrr-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/jmpr-jsrr.drawio.png b/content/isa-docs/lc-2/imgs/jmpr-jsrr.drawio.png new file mode 100644 index 0000000..590d916 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/jmpr-jsrr.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ld-dark.drawio.png b/content/isa-docs/lc-2/imgs/ld-dark.drawio.png new file mode 100644 index 0000000..570a667 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ld-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ld.drawio.png b/content/isa-docs/lc-2/imgs/ld.drawio.png new file mode 100644 index 0000000..9f3f5cb Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ld.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ldi-dark.drawio.png b/content/isa-docs/lc-2/imgs/ldi-dark.drawio.png new file mode 100644 index 0000000..517ad1d Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ldi-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ldi.drawio.png b/content/isa-docs/lc-2/imgs/ldi.drawio.png new file mode 100644 index 0000000..2dd359a Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ldi.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ldr-dark.drawio.png b/content/isa-docs/lc-2/imgs/ldr-dark.drawio.png new file mode 100644 index 0000000..80b3f40 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ldr-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ldr.drawio.png b/content/isa-docs/lc-2/imgs/ldr.drawio.png new file mode 100644 index 0000000..cf0f453 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ldr.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/lea-dark.drawio.png b/content/isa-docs/lc-2/imgs/lea-dark.drawio.png new file mode 100644 index 0000000..1b05b9d Binary files /dev/null and b/content/isa-docs/lc-2/imgs/lea-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/lea.drawio.png b/content/isa-docs/lc-2/imgs/lea.drawio.png new file mode 100644 index 0000000..bd8fc63 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/lea.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/not-dark.drawio.png b/content/isa-docs/lc-2/imgs/not-dark.drawio.png new file mode 100644 index 0000000..b0eb724 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/not-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/not.drawio.png b/content/isa-docs/lc-2/imgs/not.drawio.png new file mode 100644 index 0000000..aa66091 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/not.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ret-dark.drawio.png b/content/isa-docs/lc-2/imgs/ret-dark.drawio.png new file mode 100644 index 0000000..b35a8d4 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ret-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/ret.drawio.png b/content/isa-docs/lc-2/imgs/ret.drawio.png new file mode 100644 index 0000000..c333202 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/ret.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/rti-dark.drawio.png b/content/isa-docs/lc-2/imgs/rti-dark.drawio.png new file mode 100644 index 0000000..04d216d Binary files /dev/null and b/content/isa-docs/lc-2/imgs/rti-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/rti.drawio.png b/content/isa-docs/lc-2/imgs/rti.drawio.png new file mode 100644 index 0000000..cbe3a34 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/rti.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/st-dark.drawio.png b/content/isa-docs/lc-2/imgs/st-dark.drawio.png new file mode 100644 index 0000000..a00ae44 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/st-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/st.drawio.png b/content/isa-docs/lc-2/imgs/st.drawio.png new file mode 100644 index 0000000..294fc22 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/st.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/sti-dark.drawio.png b/content/isa-docs/lc-2/imgs/sti-dark.drawio.png new file mode 100644 index 0000000..e5a7d91 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/sti-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/sti.drawio.png b/content/isa-docs/lc-2/imgs/sti.drawio.png new file mode 100644 index 0000000..34cde97 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/sti.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/str-dark.drawio.png b/content/isa-docs/lc-2/imgs/str-dark.drawio.png new file mode 100644 index 0000000..63a7ed9 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/str-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/str.drawio.png b/content/isa-docs/lc-2/imgs/str.drawio.png new file mode 100644 index 0000000..3494ac5 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/str.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/trap-dark.drawio.png b/content/isa-docs/lc-2/imgs/trap-dark.drawio.png new file mode 100644 index 0000000..fed7601 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/trap-dark.drawio.png differ diff --git a/content/isa-docs/lc-2/imgs/trap.drawio.png b/content/isa-docs/lc-2/imgs/trap.drawio.png new file mode 100644 index 0000000..5c10221 Binary files /dev/null and b/content/isa-docs/lc-2/imgs/trap.drawio.png differ diff --git a/content/isa-docs/lc-2/instructions.md b/content/isa-docs/lc-2/instructions.md new file mode 100644 index 0000000..cba561c --- /dev/null +++ b/content/isa-docs/lc-2/instructions.md @@ -0,0 +1,390 @@ ++++ +title = "Instructions" +weight = 120 ++++ + +{{% instruction + mnemonic="ADD" + short="Addition" + + formats=`ADD DR, SR1, SR2 +ADD DR, SR1, imm5` + + encoding="../imgs/add.drawio.png" + encoding-dark="../imgs/add-dark.drawio.png" + + operation=`if (bit[5] == 0) { + DR = SR1 + SR2; +} else { + DR = SR1 + SEXT(imm5); +} + +setcc(DR);` + + examples=`ADD R2, R3, R4 ; R2 ← R3 + R4 +ADD R2, R3, #7 ; R2 ← R3 + 7` + +%}} +If bit [5] is 0, the second-source operand is obtained from SR2. If bit [5] is +1, the second-source operand is obtained by sign-extending the imm5 field to 16 +bits. In both cases, the second source operand is added to the contents of SR1, +and the result stored in DR. The condition codes are set, based on whether the +result is negative, zero, or positive. +{{% /instruction %}} + +{{% instruction + mnemonic="AND" + short="Bitwise logical AND" + + formats=`AND DR, SR1, SR2 +AND DR, SR1, imm5` + + encoding="../imgs/and.drawio.png" + encoding-dark="../imgs/and-dark.drawio.png" + + operation=`if (bit[5] == 0) { + DR = SR1 & SR2; +} else { + DR = SR1 & SEXT(imm5); +} + +setcc(DR);` + + examples=`AND R2, R3, R4 ; R2 ← R3 AND R4 +AND R2, R3, #7 ; R2 ← R3 AND 7` + +%}} +If bit [5] is 0, the second-source operand is obtained from SR2. If bit [5] is +1, the second-source operand is obtained by sign-extending the imm5 field to 16 +bits. In either case, the second-source operand and the contents of SR1 are +bitwise ANDed, and the result stored in DR. The condition codes are set, based +on whether the binary value produced, taken as a 2's complement integer, is +negative, zero, or positive. +{{% /instruction %}} + +{{% instruction + mnemonic="BR" + short="Conditional Branch" + + formats=`BR LABEL +BRn LABEL +BRz LABEL +BRp LABEL +BRnz LABEL +BRnp LABEL +BRzp LABEL +BRnzp LABEL` + + encoding="../imgs/br.drawio.png" + encoding-dark="../imgs/br-dark.drawio.png" + + operation=`if ((n && N) || (z && Z) || (p && P)) { + PC = PC[15:9] @ pgoffset9; +}` + + examples=`BRzp LOOP ; Branch to LOOP if the last result was zero or positive.` + +%}} +Test the condition codes specified by the state of bits [11:9]. If bit [11] is +set, test N; if bit [11] is clear, do not test N. If bit [10] is set, test Z, +etc. If any of the condition codes tested is set, branch to the location +specified by pgoffset9 on the same page as the branch instruction, +{{% /instruction %}} + +{{% instruction + mnemonic=`JMP / JSR` + short=`Jump / Jump to Subroutine` + + formats=`JMP LABEL (L = 0) +JSR LABEL (L = 1)` + + encoding="../imgs/jmp-jsr.drawio.png" + encoding-dark="../imgs/jmp-jsr-dark.drawio.png" + + operation=`if (L == 1) { + R7 = PC; +} + +PC = PC[15:9] @ pgoffset9;` + + examples=`JMP FOO ; Jump to FOO. +JSR FOO ; Jump to FOO, put return PC into R7.` + +%}} +Unconditionally jump to the location specified by pgoffset9 on the same page as +the JSR/JMP instruction. If the link bit L is set, the PC is saved in R7, +enabling a subsequent return to the instruction physically following the JSR +instruction. +{{% /instruction %}} + +{{% instruction + mnemonic=`JMPR / JSRR` + short=`Jump, Base + Offset / Jump to Subroutine, Base + Offset` + + formats=`JMPR BaseR, index6 (L = 0) +JSRR BaseR, index6 (L = 1)` + + encoding="../imgs/jmpr-jsrr.drawio.png" + encoding-dark="../imgs/jmpr-jsrr-dark.drawio.png" + + operation=`if (L == 1) { + R7 = PC; +} + +PC = BaseR + ZEXT(index6);` + + examples=`JMPR R2, #10 ; Jump to R2 + #10. +JSRR R2, #10 ; Jump to R2 + #10, put return PC into R7.` + +%}} +Unconditionally jump to the location specified by adding ZEXT(index6) to the +contents of the base register. If the link bit L is set, the PC is saved in R7, +enabling a subsequent return to the instruction physically following the JSRR +instruction. +{{% /instruction %}} + +{{% instruction + mnemonic="LD" + short="Load Direct" + + formats=`LD DR, LABEL` + + encoding="../imgs/ld.drawio.png" + encoding-dark="../imgs/ld-dark.drawio.png" + + operation=`DR = mem[PC[15:9] @ pgoffset9]; + +setcc(DR);` + + examples=`LD R4, COUNT ; R4 ← mem[COUNT].` + +%}} +Load the register specified by DR from the location specified by pgoffset9 on +the same page as the LD instruction. The condition codes are set, based on +whether the value loaded is negative, zero, or positive. +{{% /instruction %}} + +{{% instruction + mnemonic="LDI" + short="Load Indirect" + + formats=`LDI DR, LABEL` + + encoding="../imgs/ldi.drawio.png" + encoding-dark="../imgs/ldi-dark.drawio.png" + + operation=`DR = mem[mem[PC[15:9] @ pgoffset9]]; + +setcc(DR);` + + examples=`LDI R4, POINTER ; R4 ← mem[mem[POINTER]].` + +%}} +Load the register specified by DR as follows: Construct an address by +concatenating the top seven bits of the program counter with the pgoffset9 +field of the LDI instruction. The contents of memory at that address is the +address of the data to be loaded into DR. The condition codes are set, based on +whether the value loaded is negative, zero, or positive. +{{% /instruction %}} + +{{% instruction + mnemonic="LDR" + short="Load Base + Offset" + + formats=`LDR DR, BaseR, index6` + + encoding="../imgs/ldr.drawio.png" + encoding-dark="../imgs/ldr-dark.drawio.png" + + operation=`DR = mem[BaseR + ZEXT(index6)]; + +setcc(DR);` + + examples=`LDR R4, R2, #10 ; R4 ← contents of mem[R2 + #10].` + +%}} +Load the register specified by DR from the location specified by a base +register and index, as follows: The index is zero-extended to 16 bits and added +to the contents of BaseR to form a memory address. The contents of memory at +this address are loaded into DR. The condition codes are set, based on whether +the value loaded is negative, zero, or positive. +{{% /instruction %}} + +{{% instruction + mnemonic="LEA" + short="Load Effective Address" + + formats=`LEA DR, LABEL` + + encoding="../imgs/lea.drawio.png" + encoding-dark="../imgs/lea-dark.drawio.png" + + operation=`DR = PC[15:9] @ pgoffset9; + +setcc(DR);` + + examples=`LEA R4, FOO ; R4 ← address of FOO.` + +%}} +Load the register specified by DR with the address formed by concatenating the +top seven bits of the program counter with the pgoffset9 field of the +instruction. The condition codes are set, based on whether the value loaded is +negative, zero, or positive. +{{% /instruction %}} + +{{% instruction + mnemonic="NOT" + short="Bitwise Complement" + + formats=`NOT DR, SR` + + encoding="../imgs/not.drawio.png" + encoding-dark="../imgs/not-dark.drawio.png" + + operation=`DR = ~SR; + +setcc(DR);` + + examples=`NOT R4, R2 ; R4 ← NOT(R2).` + +%}} +Perform the bitwise complement operation on the contents of SR and place the +result in DR. The condition codes are set. +{{% /instruction %}} + +{{% instruction + mnemonic="RET" + short="Return from Subroutine" + + formats=`RET` + + encoding="../imgs/ret.drawio.png" + encoding-dark="../imgs/ret-dark.drawio.png" + + operation=`PC = R7;` + + examples=`RET ; PC ← R7.` + +%}} +Load the PC with the value in R7. This causes a return from a previous JSR or +JSRR instruction. +{{% /instruction %}} + +{{% instruction + mnemonic="RTI" + short="Return from Interrupt" + + formats=`RTI` + + encoding="../imgs/rti.drawio.png" + encoding-dark="../imgs/rti-dark.drawio.png" + + operation=`NZP = mem[R6]; +R6 = R6 - 1; +PC = mem[R6]; +R6 = R6 - 1;` + + examples=`RTI ; NZP, PC ← top two values popped off stack.` + +%}} +Pop the top two elements off the stack; load them into NZP, PC. + +