Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: whitequark/Boneless-CPU
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ea0e9660dcbb
Choose a base ref
...
head repository: whitequark/Boneless-CPU
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1b74167a2708
Choose a head ref
  • 3 commits
  • 82 files changed
  • 1 contributor

Commits on Dec 29, 2018

  1. Copy the full SHA
    99fe969 View commit details
  2. Reorganize doc/.

    whitequark committed Dec 29, 2018
    Copy the full SHA
    5abdcef View commit details

Commits on Dec 30, 2018

  1. Copy the full SHA
    1b74167 View commit details
Showing with 1,223 additions and 1 deletion.
  1. BIN doc/design.ods
  2. +74 −0 doc/images/logo-notext.svg
  3. 0 doc/{ → images}/logo-parts.svg
  4. 0 doc/{logo.svg → images/logo-text.svg}
  5. 0 doc/{logo2blur.svg → images/logo_toaru-blur.svg}
  6. 0 doc/{logo2.svg → images/logo_toaru.svg}
  7. +5 −0 doc/manual/.gitignore
  8. +5 −0 doc/manual/build.sh
  9. +17 −0 doc/manual/insns/ADC.tex
  10. +21 −0 doc/manual/insns/ADCI.tex
  11. +9 −0 doc/manual/insns/ADD.tex
  12. +13 −0 doc/manual/insns/ADDI.tex
  13. +16 −0 doc/manual/insns/ADJW.1.tex
  14. +18 −0 doc/manual/insns/ADJW.2.tex
  15. +9 −0 doc/manual/insns/AND.tex
  16. +13 −0 doc/manual/insns/ANDI.tex
  17. +10 −0 doc/manual/insns/CMP.tex
  18. +14 −0 doc/manual/insns/CMPI.tex
  19. +13 −0 doc/manual/insns/ENTR.tex
  20. +13 −0 doc/manual/insns/EXTI.tex
  21. +13 −0 doc/manual/insns/J.tex
  22. +16 −0 doc/manual/insns/JAL.tex
  23. +14 −0 doc/manual/insns/JC.tex
  24. +14 −0 doc/manual/insns/JE.tex
  25. +14 −0 doc/manual/insns/JN.tex
  26. +14 −0 doc/manual/insns/JNC.tex
  27. +14 −0 doc/manual/insns/JNE.tex
  28. +13 −0 doc/manual/insns/JNO.tex
  29. +13 −0 doc/manual/insns/JNS.tex
  30. +14 −0 doc/manual/insns/JNZ.tex
  31. +13 −0 doc/manual/insns/JO.tex
  32. +13 −0 doc/manual/insns/JR.tex
  33. +13 −0 doc/manual/insns/JS.tex
  34. +13 −0 doc/manual/insns/JSGE.tex
  35. +13 −0 doc/manual/insns/JSGT.tex
  36. +13 −0 doc/manual/insns/JSLE.tex
  37. +13 −0 doc/manual/insns/JSLT.tex
  38. +14 −0 doc/manual/insns/JUGE.tex
  39. +13 −0 doc/manual/insns/JUGT.tex
  40. +13 −0 doc/manual/insns/JULE.tex
  41. +14 −0 doc/manual/insns/JULT.tex
  42. +14 −0 doc/manual/insns/JZ.tex
  43. +17 −0 doc/manual/insns/LD.tex
  44. +17 −0 doc/manual/insns/LDI.tex
  45. +17 −0 doc/manual/insns/LDX.tex
  46. +16 −0 doc/manual/insns/LDXI.tex
  47. +13 −0 doc/manual/insns/LEAV.tex
  48. +12 −0 doc/manual/insns/MOV.tex
  49. +15 −0 doc/manual/insns/MOVA.tex
  50. +18 −0 doc/manual/insns/MOVI.tex
  51. +9 −0 doc/manual/insns/OR.tex
  52. +13 −0 doc/manual/insns/ORI.tex
  53. +6 −0 doc/manual/insns/ROLI.tex
  54. +15 −0 doc/manual/insns/RORI.tex
  55. +9 −0 doc/manual/insns/ROT.tex
  56. +10 −0 doc/manual/insns/ROTI.tex
  57. +17 −0 doc/manual/insns/SBB.tex
  58. +21 −0 doc/manual/insns/SBBI.tex
  59. +9 −0 doc/manual/insns/SLL.tex
  60. +10 −0 doc/manual/insns/SLLI.tex
  61. +9 −0 doc/manual/insns/SRA.tex
  62. +10 −0 doc/manual/insns/SRAI.tex
  63. +9 −0 doc/manual/insns/SRL.tex
  64. +10 −0 doc/manual/insns/SRLI.tex
  65. +17 −0 doc/manual/insns/ST.tex
  66. +17 −0 doc/manual/insns/STI.tex
  67. +17 −0 doc/manual/insns/STX.tex
  68. +16 −0 doc/manual/insns/STXI.tex
  69. +9 −0 doc/manual/insns/SUB.tex
  70. +13 −0 doc/manual/insns/SUBI.tex
  71. +13 −0 doc/manual/insns/XCHG.tex
  72. +9 −0 doc/manual/insns/XOR.tex
  73. +13 −0 doc/manual/insns/XORI.tex
  74. +196 −0 doc/manual/insns/index.tex
  75. +1 −0 doc/manual/insns/jump-restrictions.tex
  76. +1 −0 doc/manual/insns/mem-restrictions.tex
  77. +1 −0 doc/manual/insns/memi-restrictions.tex
  78. +11 −0 doc/manual/insns/shift-remark.tex
  79. +1 −0 doc/manual/insns/shift-restrictions.tex
  80. BIN doc/manual/manual.pdf
  81. +57 −0 doc/manual/manual.tex
  82. +1 −1 formal/formal.sv
Binary file modified doc/design.ods
Binary file not shown.
74 changes: 74 additions & 0 deletions doc/images/logo-notext.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
5 changes: 5 additions & 0 deletions doc/manual/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.aux
*.log
*.toc
*.out
*.cb*
5 changes: 5 additions & 0 deletions doc/manual/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -ex

cd $(dirname $0)
pdflatex -halt-on-error -interaction batchmode manual.tex
pdflatex -halt-on-error -interaction batchmode manual.tex
17 changes: 17 additions & 0 deletions doc/manual/insns/ADC.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{ADC}{Add Register with Carry}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{01} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To add 16-bit integers in registers, with carry input.}
\restrictions{None.}
\begin{operation}\aluRR{opA + opB + C}\wb\flagZSCV\end{operation}
\begin{remarks}
A 32-bit addition with both operands in registers can be performed as follows:
\begin{alltt}
; Perform (R1|R0) ← (R3|R2) + (R5|R4)
ADD R0, R2, R4
ADC R1, R3, R5
\end{alltt}
\end{remarks}
\end{instruction}
21 changes: 21 additions & 0 deletions doc/manual/insns/ADCI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
\begin{instruction}{ADCI}{Add Immediate with Carry}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{01} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{01} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To add a constant to a 16-bit integer in a register, with carry input.}
\restrictions{None.}
\begin{operation}\aluRI{opA + opB + C}\wb\flagZSCV\end{operation}
\begin{remarks}
A 32-bit addition with a register and an immediate operand can be performed as follows:
\begin{alltt}
; Perform (R1|R0) ← (R3|R2) + 0x40001
ADDI R0, R2, 1
ADCI R1, R3, 4
\end{alltt}
\end{remarks}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/ADD.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{ADD}{Add Register}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{00} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To add 16-bit integers in registers.}
\restrictions{None.}
\begin{operation}\aluRR{opA + opB}\wb\flagZSCV\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/ADDI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{ADDI}{Add Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{00} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{00} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To add a constant to a 16-bit integer in a register.}
\restrictions{None.}
\begin{operation}\aluRI{opA + opB}\wb\flagZSCV\end{operation}
\end{instruction}
16 changes: 16 additions & 0 deletions doc/manual/insns/ADJW.1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\begin{instruction}{ADJW.1}{Adjust Window}
\begin{encoding}
\mnemonic & \op{3}{001} & \op{2}{11} & \bits{3}{000} & \bits{3}{000} & \op{2}{11} & \imm{3} \\
\end{encoding}
\assembly{ADJW size}
\purpose{To adjust the position of register window.}
\restrictions{None.}
\begin{operation}
\K{if} (has\_ext13)
\K{then} imm ← ext13|imm3
\K{else} imm ← sign\_extend(imm3)
W ← W + imm
\end{operation}
\begin{remarks}See also \insnref{LEAV}.\end{remarks}
\begin{notice}The exact encoding of this instruction is not final.\end{notice}
\end{instruction}
18 changes: 18 additions & 0 deletions doc/manual/insns/ADJW.2.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\begin{instruction}{ADJW.2}{Adjust Window, Store Previous Address}
\begin{encoding}
\mnemonic & \op{3}{001} & \op{2}{11} & \reg{d} & \bits{3}{001} & \op{2}{11} & \imm{3} \\
\end{encoding}
\assembly{ADJW Rd, size}
\purpose{To adjust the position of register window and store the previous window position to a register.}
\restrictions{None.}
\begin{operation}
\K{if} (has\_ext13)
\K{then} imm ← ext13|imm3
\K{else} imm ← sign\_extend(imm3)
tmp ← W
W ← W + imm
mem[W|Rd] ← tmp|000
\end{operation}
\begin{remarks}See also \insnref{ENTR}.\end{remarks}
\begin{notice}The exact encoding of this instruction is not final.\end{notice}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/AND.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{AND}{Bitwise AND with Register}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{00} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform bitwise AND between 16-bit integers in registers.}
\restrictions{None.}
\begin{operation}\aluRR{opA \K{and} opB}\wb\flagZS\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/ANDI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{ANDI}{Bitwise AND with Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{00} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{00} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To perform bitwise AND between a constant and a 16-bit integer in a register.}
\restrictions{None.}
\begin{operation}\aluRI{opA \K{and} opB}\wb\flagZS\end{operation}
\end{instruction}
10 changes: 10 additions & 0 deletions doc/manual/insns/CMP.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{instruction}{CMP}{Compare to Register}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{00} & \op{3}{000} & \reg{a} & \op{2}{11} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To compare 16-bit integers in registers.}
\restrictions{None.}
\begin{operation}\aluRR{opA - opB}\flagZSBV\end{operation}
\begin{remarks}This instruction is identical to \texttt{SUB}, with the exception that it discards the computed value.\end{remarks}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/CMPI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{CMPI}{Compare to Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{00} & \op{3}{000} & \reg{a} & \op{2}{11} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{00} & \op{3}{000} & \reg{a} & \op{2}{11} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To compare a constant to a 16-bit integer in a register.}
\restrictions{None.}
\begin{operation}\aluRI{opA - opB}\flagZSBV\end{operation}
\begin{remarks}This instruction is identical to \texttt{SUBI}, with the exception that it discards the computed value.\end{remarks}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/ENTR.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{ENTR}{Enter Frame}
\assembly{\mnemonic{} Rd, size}
\purpose{To set up a working area at an entry to a function.}
\restrictions{None.}
\begin{remarks}
The assembler translates \texttt{\mnemonic} to
\begin{alltt}
ADJW Rd, -size
\end{alltt}

See the description of \insnref{ADJW.2}. See also \insnref{LEAV}.
\end{remarks}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/EXTI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{EXTI}{Extend Immediate}
\begin{encoding}
\mnemonic & \op{3}{110} & \imm{13} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To extend the range of immediate in the next executed instruction.}
\restrictions{None.}
\begin{operation}
ext13 ← imm13
has_ext13 ← 1
\end{operation}
\begin{remarks}This instruction is exclusively emitted by the assembler while translating other instructions. As it changes both the meaning of and the constraints placed on the immediate field in the following instruction, the assembler does not accept a mnemonic for \texttt{EXTI}.\end{remarks}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/J.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{J}{Jump}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1111} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1111} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To unconditionally transfer control.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}PC ← PC + 1 + off\end{operation}
\end{instruction}
16 changes: 16 additions & 0 deletions doc/manual/insns/JAL.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\begin{instruction}{JAL}{Jump And Link}
\begin{encoding*}{short}
\mnemonic & \op{3}{100} & \op{2}{10} & \reg{d} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{100} & \op{2}{10} & \reg{d} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control to a subroutine.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}
mem[W|Rd] ← PC + 1
PC ← PC + 1 + off
\end{operation}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JC.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JC}{Jump if Carry}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1010} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1010} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation resulted in unsigned overflow.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{C}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JUGE}.\end{remarks}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JE.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JE}{Jump if Equal}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1000} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1000} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is equal to \texttt{Rb}.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{Z}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JZ}.\end{remarks}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JN.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JN}{Jump Never}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0111} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0111} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To serve as a placeholder for a jump instruction.}
\input{jump-restrictions.tex}
\begin{operation}PC ← PC + 1\end{operation}
\begin{remarks}The \texttt{JN} instruction has no effect. It may be used as a placeholder for a different jump instruction with a predefiend offset when the exact condition is unknown, such as in certain self-modifying code.\end{remarks}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JNC.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JNC}{Jump if Not Carry}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0010} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0010} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation did not result in unsigned overflow.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} C}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JULT}.\end{remarks}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JNE.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JNE}{Jump if Not Equal}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0000} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0000} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is not equal to \texttt{Rb}.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} Z}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JNZ}.\end{remarks}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JNO.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JNO}{Jump if Not Overflow}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0011} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0011} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation did not result in signed overflow.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} V}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JNS.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JNS}{Jump if Not Sign}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0001} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0001} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation produced a non-negative result.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} S}\end{operation}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JNZ.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JNZ}{Jump if Not Zero}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0000} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0000} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation produced a non-zero result.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} Z}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JNE}.\end{remarks}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JO.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JO}{Jump if Overflow}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1011} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1011} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation resulted in signed overflow.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{V}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JR.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JR}{Jump to Register}
\begin{encoding}
\mnemonic & \op{3}{101} & \op{2}{11} & \reg{a} & \bits{8}{00000000} \\
\end{encoding}
\assembly{\mnemonic{} Rd}
\purpose{To transfer control to an absolute address contained in a register.}
\restrictions{None.}
\begin{operation}
addr ← mem[W|Ra]
PC ← addr
\end{operation}
\begin{notice}The exact encoding of this instruction is not final.\end{notice}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JS.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JS}{Jump if Sign}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1001} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1001} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation produced a negative result.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{S}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JSGE.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JSGE}{Jump if Signed Greater or Equal}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0101} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0101} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is greater than or equal to \texttt{Rb} when interpreted as signed integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} (S \K{xor} V)}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JSGT.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JSGT}{Jump if Signed Greater Than}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0110} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0110} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is greater than to \texttt{Rb} when interpreted as signed integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} ((S \K{xor} V) \K{or} Z)}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JSLE.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JSLE}{Jump if Signed Less or Equal}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1110} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1110} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is less than or equal to \texttt{Rb} when interpreted as signed integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{((S \K{xor} V) \K{or} Z)}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JSLT.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JSLT}{Jump if Signed Less Than}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1101} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1101} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is less than \texttt{Rb} when interpreted as signed integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{(S \K{xor} V)}\end{operation}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JUGE.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JUGE}{Jump if Unsigned Greater or Equal}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1010} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1010} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is greater than or equal to \texttt{Rb} when interpreted as unsigned integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{C}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JC}.\end{remarks}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JUGT.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JUGT}{Jump if Unsigned Greater Than}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0110} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0110} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is greater than to \texttt{Rb} when interpreted as unsigned integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} ((\K{not} C) \K{or} V)}\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/JULE.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{JULE}{Jump if Unsigned Less or Equal}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1110} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1110} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is less than or equal to \texttt{Rb} when interpreted as unsigned integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{(\K{not} C) \K{or} V}\end{operation}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JULT.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JULT}{Jump if Unsigned Less Than}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0010} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{0010} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control after a \texttt{\insnref{CMP} Ra, Rb} instruction if \texttt{Ra} is less than \texttt{Rb} when interpreted as unsigned integer.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{\K{not} C}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JNC}.\end{remarks}
\end{instruction}
14 changes: 14 additions & 0 deletions doc/manual/insns/JZ.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{instruction}{JZ}{Jump if Zero}
\begin{encoding*}{short}
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1000} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{101} & \op{1}{1} & \op{4}{1000} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} label}
\purpose{To transfer control if an arithmetic or shift operation produced a zero result.}
\input{jump-restrictions.tex}
\begin{operation}\off{8}\jump{Z}\end{operation}
\begin{remarks}This instruction has the same encoding as \insnref{JE}.\end{remarks}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/LD.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{LD}{Load with Address in Register}
\begin{encoding*}{short}
\mnemonic & \op{3}{010} & \op{2}{00} & \reg{d} & \reg{a} & \off{5} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{010} & \op{2}{00} & \reg{d} & \reg{a} & \off{5} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, off}
\purpose{To load a word from memory at an absolute address contained in a register, with a constant offset.}
\input{mem-restrictions.tex}
\begin{operation}\off{5}
addr ← mem[W|Ra] + off
temp ← mem[addr]
mem[W|Rd] ← temp
\end{operation}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/LDI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{LDI}{Load PC-relative with Immediate Offset}
\begin{encoding*}{short}
\mnemonic & \op{3}{011} & \op{2}{00} & \reg{d} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{011} & \op{2}{00} & \reg{d} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, off}
\purpose{To load a word from memory at an address relative to PC with a constant offset.}
\input{memi-restrictions.tex}
\begin{operation}\off{8}
addr ← PC + off
temp ← mem[addr]
mem[W|Rd] ← temp
\end{operation}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/LDX.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{LDX}{Load External with Address in Register}
\begin{encoding*}{short}
\mnemonic & \op{3}{010} & \op{2}{10} & \reg{d} & \reg{a} & \off{5} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{010} & \op{2}{10} & \reg{d} & \reg{a} & \off{5} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, off}
\purpose{To complete a load cycle on external bus at an absolute address contained in a register, with a constant offset.}
\input{mem-restrictions.tex}
\begin{operation}\off{5}
addr ← mem[W|Ra] + off
temp ← ext[addr]
mem[W|Rd] ← temp
\end{operation}
\end{instruction}
16 changes: 16 additions & 0 deletions doc/manual/insns/LDXI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\begin{instruction}{LDXI}{Load External with Immediate Address}
\begin{encoding*}{short}
\mnemonic & \op{3}{011} & \op{2}{10} & \reg{d} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{011} & \op{2}{10} & \reg{d} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, off}
\purpose{To complete a load cycle on external bus at a constant absolute address.}
\input{memi-restrictions.tex}
\begin{operation}\off{8}
temp ← ext[off]
mem[W|Rd] ← temp
\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/LEAV.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{LEAV}{Leave Frame}
\assembly{\mnemonic{} Rd, size}
\purpose{To tear down a working area at an exit from a function.}
\restrictions{None.}
\begin{remarks}
The assembler translates \texttt{\mnemonic} to
\begin{alltt}
ADJW size
\end{alltt}

See the description of \insnref{ADJW.1}. See also \insnref{ENTR}.
\end{remarks}
\end{instruction}
12 changes: 12 additions & 0 deletions doc/manual/insns/MOV.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\begin{instruction}{MOV}{Move}
\assembly{\mnemonic{} Rd, Rs}
\purpose{To move a value from register to register.}
\restrictions{None.}
\begin{remarks}
The assembler does not translate any instructions for \texttt{\mnemonic} with identical \texttt{Rd} and \texttt{Rs}, and translates \texttt{\mnemonic} with any other register combination to
\begin{alltt}
ANDI Rd, Rs, Rs
\end{alltt}
\end{remarks}
\begin{notice}The exact translation of this mnemonic is not final.\end{notice}
\end{instruction}
15 changes: 15 additions & 0 deletions doc/manual/insns/MOVA.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\begin{instruction}{MOVA}{Move Address PC-relative}
\begin{encoding*}{short}
\mnemonic & \op{3}{100} & \op{2}{00} & \reg{d} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{100} & \op{2}{00} & \reg{d} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, off}
\purpose{To load a register with an address relative to PC with a constant offset..}
\restrictions{If the long form is used, and \texttt{off8[8:3]} are non-zero, the behavior is \unpredictable.}
\begin{operation}\off{8}
mem[W|Rd] ← PC + 1 + off
\end{operation}
\end{instruction}
18 changes: 18 additions & 0 deletions doc/manual/insns/MOVI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\begin{instruction}{MOVI}{Move Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{100} & \op{2}{01} & \reg{d} & \imm{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{100} & \op{2}{01} & \reg{d} & \imm{8} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, imm}
\purpose{To load a register with a constant.}
\restrictions{If the long form is used, and \texttt{off8[8:3]} are non-zero, the behavior is \unpredictable.}
\begin{operation}
\K{if} (has\_ext13)
\K{then} imm ← ext13|imm8[3:0]
\K{else} imm ← sign\_extend(imm8)
mem[W|Rd] ← imm
\end{operation}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/OR.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{OR}{Bitwise OR with Register}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{01} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform bitwise OR between 16-bit integers in registers.}
\restrictions{None.}
\begin{operation}\aluRR{opA \K{or} opB}\wb\flagZS\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/ORI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{ORI}{Bitwise OR with Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{01} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{01} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To perform bitwise OR between a constant and a 16-bit integer in a register.}
\restrictions{None.}
\begin{operation}\aluRI{opA \K{or} opB}\wb\flagZS\end{operation}
\end{instruction}
6 changes: 6 additions & 0 deletions doc/manual/insns/ROLI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{instruction}{ROLI}{Rotate Left Immediate}
\assembly{\mnemonic{} Rd, Ra, amount}
\purpose{To perform a left rotate of a 16-bit integer in a register by a constant bit amount.}
\restrictions{The \texttt{amount} may be between 0 and 15, inclusive.}
\begin{remarks}This instruction is an alias for \insnref{ROTI}.\end{remarks}
\end{instruction}
15 changes: 15 additions & 0 deletions doc/manual/insns/RORI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\begin{instruction}{RORI}{Rotate Right Immediate}
\assembly{\mnemonic{} Rd, Ra, amount}
\purpose{To perform a right rotate of a 16-bit integer in a register by a constant bit amount.}
\restrictions{The \texttt{amount} may be between 0 and 15, inclusive.}
\begin{remarks}
The assembler translates \texttt{\mnemonic} with \texttt{amount} of 0 to
\begin{alltt}
MOV Rd, Ra
\end{alltt}
and \texttt{\mnemonic} with any other \texttt{amount} to
\begin{alltt}
ROTI Rd, Rd, (15 - amount)
\end{alltt}
\end{remarks}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/ROT.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{ROT}{Rotate}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{01} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform a left rotate of a 16-bit integer in a register by a variable bit amount.}
\input{shift-restrictions.tex}
\begin{operation}\aluRR{opA[16-opB:0]|opA[16:16-opB]}\wb\flagZS\end{operation}
\end{instruction}
10 changes: 10 additions & 0 deletions doc/manual/insns/ROTI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{instruction}{ROTI}{Rotate Immediate}
\begin{encoding}
\mnemonic & \op{3}{001} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{01} & \imm{3} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, amount}
\purpose{To perform a left rotate of a 16-bit integer in a register by a constant bit amount.}
\restrictions{The \texttt{amount} may be between 0 and 15, inclusive.}
\begin{operation}\aluR{opA[15-imm3:0]|opA[16:15-imm3]}\wb\flagZS\end{operation}
\input{shift-remark.tex}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/SBB.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{SBB}{Subtract Register with Borrow}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{11} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To subtract 16-bit integers in registers, with borrow input.}
\restrictions{None.}
\begin{operation}\aluRR{opA - opB - \K{not} C}\wb\flagZSBV\end{operation}
\begin{remarks}
A 32-bit subtraction with both operands in registers can be performed as follows:
\begin{alltt}
; Perform (R1|R0) ← (R3|R2) - (R5|R4)
SUB R0, R2, R4
SBB R1, R3, R5
\end{alltt}
\end{remarks}
\end{instruction}
21 changes: 21 additions & 0 deletions doc/manual/insns/SBBI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
\begin{instruction}{SBBI}{Subtract Immediate with Borrow}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{11} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{11} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To subtract a constant from a 16-bit integer in a register, with borrow input.}
\restrictions{None.}
\begin{operation}\aluRI{opA - opB - \K{not} C}\wb\flagZSBV\end{operation}
\begin{remarks}
A 32-bit subtraction with a register and an immediate operand can be performed as follows:
\begin{alltt}
; Perform (R1|R0) ← (R3|R2) - 0x40001
SUBI R0, R2, 1
SBBI R1, R3, 4
\end{alltt}
\end{remarks}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/SLL.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{SLL}{Shift Left Logical}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{00} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform a left logical shift of a 16-bit integer in a register by a variable bit amount.}
\input{shift-restrictions.tex}
\begin{operation}\aluRR{opA[16-opB:0]|0\string{opB\string}}\wb\flagZS\end{operation}
\end{instruction}
10 changes: 10 additions & 0 deletions doc/manual/insns/SLLI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{instruction}{SLLI}{Shift Left Logical Immediate}
\begin{encoding}
\mnemonic & \op{3}{001} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{00} & \imm{3} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, amount}
\purpose{To perform a left logical shift of a 16-bit integer in a register by a constant bit amount.}
\restrictions{The \texttt{amount} may be between 0 and 15, inclusive.}
\begin{operation}\aluR{opA[15-imm3:0]|0\string{imm3+1\string}}\wb\flagZS\end{operation}
\input{shift-remark.tex}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/SRA.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{SRA}{Shift Right Arithmetical}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{11} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform a right arithmetical shift of a 16-bit integer in a register by a variable bit amount.}
\input{shift-restrictions.tex}
\begin{operation}\aluRR{opA[15]\string{opB\string}|opA[16:16-opB]}\wb\flagZS\end{operation}
\end{instruction}
10 changes: 10 additions & 0 deletions doc/manual/insns/SRAI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{instruction}{SRAI}{Shift Right Arithmetical Immediate}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{11} & \imm{3} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, amount}
\purpose{To perform a right arithmetical shift of a 16-bit integer in a register by a constant bit amount.}
\restrictions{The \texttt{amount} may be between 0 and 15, inclusive.}
\begin{operation}\aluRR{opA[15]\string{imm3+1\string}|opA[16:15-imm3]}\wb\flagZS\end{operation}
\input{shift-remark.tex}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/SRL.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{SRL}{Shift Right Logical}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{10} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform a right logical shift of a 16-bit integer in a register by a variable bit amount.}
\input{shift-restrictions.tex}
\begin{operation}\aluRR{0\string{opB\string}|opA[16:16-opB]}\wb\flagZS\end{operation}
\end{instruction}
10 changes: 10 additions & 0 deletions doc/manual/insns/SRLI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{instruction}{SRLI}{Shift Right Logical Immediate}
\begin{encoding}
\mnemonic & \op{3}{001} & \op{2}{10} & \reg{d} & \reg{a} & \op{2}{10} & \imm{3} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, amount}
\purpose{To perform a right logical shift of a 16-bit integer in a register by a constant bit amount.}
\restrictions{The \texttt{amount} may be between 0 and 15, inclusive.}
\begin{operation}\aluR{0\string{imm3+1\string}|opA[16:15-imm3]}\wb\flagZS\end{operation}
\input{shift-remark.tex}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/ST.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{ST}{Store with Address in Register}
\begin{encoding*}{short}
\mnemonic & \op{3}{010} & \op{2}{01} & \reg{s} & \reg{a} & \off{5} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{010} & \op{2}{01} & \reg{s} & \reg{a} & \off{5} \\
\end{encoding*}
\assembly{\mnemonic{} Rs, Ra, off}
\purpose{To store a word to memory at an absolute address contained in a register, with a constant offset.}
\input{mem-restrictions.tex}
\begin{operation}\off{5}
addr ← mem[W|Ra] + off
temp ← mem[W|Rs]
mem[addr] ← temp
\end{operation}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/STI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{STI}{Store PC-relative with Immediate Offset}
\begin{encoding*}{short}
\mnemonic & \op{3}{011} & \op{2}{01} & \reg{s} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{011} & \op{2}{01} & \reg{s} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} Rs, off}
\purpose{To store a word to memory at an address relative to PC with a constant offset.}
\input{memi-restrictions.tex}
\begin{operation}\off{8}
addr ← PC + off
temp ← mem[W|Rs]
mem[addr] ← temp
\end{operation}
\end{instruction}
17 changes: 17 additions & 0 deletions doc/manual/insns/STX.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\begin{instruction}{STX}{Store External with Address in Register}
\begin{encoding*}{short}
\mnemonic & \op{3}{010} & \op{2}{11} & \reg{s} & \reg{a} & \off{5} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{010} & \op{2}{11} & \reg{s} & \reg{a} & \off{5} \\
\end{encoding*}
\assembly{\mnemonic{} Rs, Ra, off}
\purpose{To complete a store cycle on external bus at an absolute address contained in a register, with a constant offset.}
\input{mem-restrictions.tex}
\begin{operation}\off{5}
addr ← mem[W|Ra] + off
temp ← mem[W|Rs]
ext[addr] ← temp
\end{operation}
\end{instruction}
16 changes: 16 additions & 0 deletions doc/manual/insns/STXI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\begin{instruction}{STXI}{Store External with Immediate Address}
\begin{encoding*}{short}
\mnemonic & \op{3}{011} & \op{2}{11} & \reg{s} & \off{8} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{011} & \op{2}{11} & \reg{s} & \off{8} \\
\end{encoding*}
\assembly{\mnemonic{} Rs, off}
\purpose{To complete a store cycle on external bus at a constant absolute address.}
\input{mem-restrictions.tex}
\begin{operation}\off{8}
temp ← mem[W|Rs]
ext[off] ← temp
\end{operation}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/SUB.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{SUB}{Subtract Register}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{10} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To subtract 16-bit integers in registers.}
\restrictions{None.}
\begin{operation}\aluRR{opA - opB}\wb\flagZSBV\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/SUBI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{SUBI}{Subtract Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{10} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{01} & \reg{d} & \reg{a} & \op{2}{10} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To subtract a constant from a 16-bit integer in a register.}
\restrictions{None.}
\begin{operation}\aluRI{opA - opB}\wb\flagZSBV\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/XCHG.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{XCHG}{Exchange Registers}
\assembly{\mnemonic{} Ra, Rb}
\purpose{To exchange the values of two registers.}
\restrictions{None.}
\begin{remarks}
The assembler does not translate any instructions for \texttt{\mnemonic} with identical \texttt{Ra} and \texttt{Rb}, and translates \texttt{\mnemonic} with any other register combination to
\begin{alltt}
XOR Ra, Ra, Rb
XOR Rb, Rb, Ra
XOR Ra, Ra, Rb
\end{alltt}
\end{remarks}
\end{instruction}
9 changes: 9 additions & 0 deletions doc/manual/insns/XOR.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{instruction}{XOR}{Bitwise XOR with Register}
\begin{encoding}
\mnemonic & \op{3}{000} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{10} & \reg{b} \\
\end{encoding}
\assembly{\mnemonic{} Rd, Ra, Rb}
\purpose{To perform bitwise XOR between 16-bit integers in registers.}
\restrictions{None.}
\begin{operation}\aluRR{opA \K{xor} opB}\wb\flagZS\end{operation}
\end{instruction}
13 changes: 13 additions & 0 deletions doc/manual/insns/XORI.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{instruction}{XORI}{Bitwise XOR with Immediate}
\begin{encoding*}{short}
\mnemonic & \op{3}{001} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{10} & \imm{3} \\
\end{encoding*}
\begin{encoding*}{long}
\exti
\mnemonic & \op{3}{001} & \op{2}{00} & \reg{d} & \reg{a} & \op{2}{10} & \imm{3} \\
\end{encoding*}
\assembly{\mnemonic{} Rd, Ra, imm}
\purpose{To perform bitwise XOR between a constant and a 16-bit integer in a register.}
\restrictions{None.}
\begin{operation}\aluRI{opA \K{xor} opB}\wb\flagZS\end{operation}
\end{instruction}
196 changes: 196 additions & 0 deletions doc/manual/insns/index.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
\def←{$\leftarrow$}

\newcommand{\insnref}[1]{\hyperref[insn:#1]{\texttt{#1}}}

\newenvironment{instruction}[2]{
\subsection[#1 (#2)]{#1 \hfill #2}
\label{insn:#1}
\vspace{0.5cm}

\newcommand{\mnemonic}{#1}

\newcommand{\field}[1]{\par\textbf{##1:}\par}
\newcommand{\fieldindent}[2]{\field{##1}\begin{adjustwidth}{10pt}{0pt}##2\end{adjustwidth}}

\newenvironment{encoding}[1][Encoding]{
\newcommand{\bits}[2]{\multicolumn{####1}{c|}{####2}}
\newcommand{\op}[2]{\bits{####1}{\texttt{####2}}}
\newcommand{\reg}[1]{\bits{3}{R####1}}
\newcommand{\imm}[1]{\bits{####1}{imm####1}}
\newcommand{\off}[1]{\bits{####1}{off####1}}
\newcommand{\exti}{EXTI & \op{3}{110} & \bits{13}{ext13} \\ \cline{2-17}}

\field{##1}
\begin{adjustwidth}{10pt}{0pt}
\begin{tabular}{R{2cm}|*{16}{c|}}
\cline{2-17}
& F & E & D & C & B & A & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\
\cline{2-17}
}{
\cline{2-17}
\end{tabular}
\end{adjustwidth}
}
\newenvironment{encoding*}[1]{
\begin{encoding}[Encoding (##1 form)]
}{
\end{encoding}
}

\newcommand{\assembly}[1]{\fieldindent{Assembly}{\texttt{##1}}}

\newcommand{\purpose}[1]{\fieldindent{Purpose}{##1}}

% Restrictions often include \unpredictable, which tends to mess with line break algorithm,
% so we turn off hyphenation for these paragraphs with \raggedright.
\newcommand{\restrictions}[1]{\fieldindent{Restrictions}{\raggedright##1}}

\newenvironment{operation}{
\newcommand{\K}[1]{\textbf{####1}}

\newcommand{\aluR}[1]{\begin{alltt}
opA ← mem[W|Ra]\\
res ← ####1
\end{alltt}}

\newcommand{\aluRR}[1]{\begin{alltt}
opA ← mem[W|Ra]\\
opB ← mem[W|Rb]\\
res ← ####1
\end{alltt}}

\newcommand{\aluRI}[1]{
\begin{alltt}
opA ← mem[W|Ra]\\
\K{if} (has\_ext13)\\
\K{then} opB ← ext13|imm3\\
\K{else} opB ← decode\_immediate(imm3)\\
res ← ####1
\end{alltt}}

\newcommand{\wb}{mem[W|Rd] ← res}

\newcommand{\flagZS}{\begin{alltt}
Z ← res = 0\\
S ← res[15]\\
C ← \undefined\\
V ← \undefined
\end{alltt}}

\newcommand{\flagZSCV}{\begin{alltt}
Z ← res = 0\\
S ← res[15]\\
C ← res[16]\\
V ← (opA[15] = opB[15]) \K{and} (opA[15] <> res[15])
\end{alltt}}

\newcommand{\flagZSBV}{\begin{alltt}
Z ← res = 0\\
S ← res[15]\\
C ← \K{not} res[16]\\
V ← (opA[15] = \K{not} opB[15]) \K{and} (opA[15] <> res[15])
\end{alltt}}

\newcommand{\off}[1]{\begin{alltt}
\K{if} (has\_ext13)\\
\K{then} off ← ext13|off{####1}[3:0]\\
\K{else} off ← sign\_extend(off{####1})
\end{alltt}}

\newcommand{\jump}[1]{\begin{alltt}
\K{if} (####1)\\
\K{then} PC ← PC + 1 + off\\
\K{else} PC ← PC + 1
\end{alltt}}

\field{Operation}
\begin{adjustwidth}{10pt}{0pt}
\begin{alltt}%
}{%
\end{alltt}
\end{adjustwidth}
}

\newenvironment{remarks}{
\field{Remarks}
\begin{adjustwidth}{10pt}{0pt}
}{
\end{adjustwidth}
}

\newenvironment{notice}{
\cbcolor{red}
\par\textbf{Notice:}\cbstart\par
}{
\cbend
}
}{
\pagebreak
}

\input{ADC.tex}
\input{ADCI.tex}
\input{ADD.tex}
\input{ADDI.tex}
\input{ADJW.1.tex}
\input{ADJW.2.tex}
\input{AND.tex}
\input{ANDI.tex}
\input{CMP.tex}
\input{CMPI.tex}
\input{ENTR.tex} % pseudo
\input{EXTI.tex}
\input{J.tex}
\input{JAL.tex}
\input{JC.tex}
\input{JE.tex} % pseudo
\input{JN.tex}
\input{JNC.tex}
\input{JNE.tex} % pseudo
\input{JNO.tex}
\input{JNS.tex}
\input{JNZ.tex}
\input{JO.tex}
\input{JR.tex}
\input{JS.tex}
\input{JSGE.tex}
\input{JSGT.tex}
\input{JSLE.tex}
\input{JSLT.tex}
\input{JUGE.tex} % pseudo
\input{JUGT.tex}
\input{JULE.tex}
\input{JULT.tex} % pseudo
\input{JZ.tex}
\input{LD.tex}
\input{LDI.tex}
\input{LDX.tex}
\input{LDXI.tex}
\input{LEAV.tex} % pseudo
\input{MOV.tex} % pseudo
\input{MOVA.tex}
\input{MOVI.tex}
\input{OR.tex}
\input{ORI.tex}
\input{ROLI.tex} % pseudo
\input{RORI.tex} % pseudo
\input{ROT.tex}
\input{ROTI.tex}
\input{SBB.tex}
\input{SBBI.tex}
\input{SLL.tex}
\input{SLLI.tex}
\input{SRA.tex}
\input{SRAI.tex}
\input{SRL.tex}
\input{SRLI.tex}
\input{ST.tex}
\input{STI.tex}
\input{STX.tex}
\input{STXI.tex}
\input{SUB.tex}
\input{SUBI.tex}
% \input{SWPW.tex}
\input{XCHG.tex} % pseudo
\input{XOR.tex}
\input{XORI.tex}
1 change: 1 addition & 0 deletions doc/manual/insns/jump-restrictions.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\restrictions{If the long form is used, and \texttt{off8[8:3]} are non-zero, the behavior is \unpredictable.}
1 change: 1 addition & 0 deletions doc/manual/insns/mem-restrictions.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\restrictions{If the long form is used, and \texttt{off5[5:3]} are non-zero, the behavior is \unpredictable.}
1 change: 1 addition & 0 deletions doc/manual/insns/memi-restrictions.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\restrictions{If the long form is used, and \texttt{off8[8:3]} are non-zero, the behavior is \unpredictable.}
11 changes: 11 additions & 0 deletions doc/manual/insns/shift-remark.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\begin{remarks}
The instruction encoding allows directly representing any \texttt{amount} between 1 and 8, inclusive. The assembler translates \texttt{\mnemonic} with \texttt{amount} of 0 to
\begin{alltt}
MOV Rd, Ra
\end{alltt}
and \texttt{\mnemonic} with \texttt{amount} greater than 8 to
\begin{alltt}
\mnemonic Rd, Ra, 8
\mnemonic Rd, Rd, (amount - 8)
\end{alltt}
\end{remarks}
1 change: 1 addition & 0 deletions doc/manual/insns/shift-restrictions.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\restrictions{If \texttt{Rb} contains a value greater than 15, the behavior is \unpredictable.}
Binary file added doc/manual/manual.pdf
Binary file not shown.
57 changes: 57 additions & 0 deletions doc/manual/manual.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
\documentclass[12pt,a4paper]{article}
\usepackage[hmargin=3cm,vmargin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{import}
\usepackage{parskip}
\usepackage{color}
\usepackage[color,leftbars]{changebar}
\usepackage{ragged2e}
\usepackage{changepage}
\usepackage{alltt}
\renewcommand{\ttdefault}{txtt}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
pdfstartview=Fit,
pdfpagemode=UseOutlines,
}

\newcommand{\undefined}{\textbf{UNDEFINED}}
\newcommand{\unpredictable}{\textbf{UNPREDICTABLE}}
\uchyph=0

\begin{document}

\begin{titlepage}
\centering
\vspace*{6cm}
\par{\Huge Boneless-III}
\vspace{1cm}
\par{\Huge Architecture Reference Manual}
\end{titlepage}

\tableofcontents
\addcontentsline{toc}{section}{Table of Contents}
\pagebreak

\setcounter{tocdepth}{2}

\section{Guide to Instruction Set}
TBD
\pagebreak

\section{List of Instructions}

The following pages provide a detailed description of instructions, arranged in alphabetical order.

Executing any instruction with an encoding not present on the following pages has \unpredictable{} behavior.
\pagebreak

\import{insns/}{index.tex}

\end{document}
2 changes: 1 addition & 1 deletion formal/formal.sv
Original file line number Diff line number Diff line change
@@ -246,7 +246,7 @@ module boneless_formal(
assert (fi_mem_w_data == (mem[a_regY] << i_shift));
OPCODE_SHIFT_L, OPTYPE_ROT:
assert (fi_mem_w_data == (mem[a_regY] << i_shift) |
(mem[a_regY] >> (16 - i_shift)));
(mem[a_regY] >> (16 - i_shift)));
OPCODE_SHIFT_R, OPTYPE_SRL:
assert (fi_mem_w_data == (mem[a_regY] >> i_shift));
OPCODE_SHIFT_R, OPTYPE_SRA: