diff --git a/hbbytecode/src/lib.rs b/hbbytecode/src/lib.rs index a4f09b45..78298bb1 100644 --- a/hbbytecode/src/lib.rs +++ b/hbbytecode/src/lib.rs @@ -35,40 +35,40 @@ constmod!(pub opcode(u8) { NEG = 13, "BB; #0 ← ~#1"; NOT = 14, "BB; #0 ← !#1"; - ADDI = 18, "BBD; #0 ← #1 + imm #2"; - MULI = 19, "BBD; #0 ← #1 × imm #2"; - ANDI = 20, "BBD; #0 ← #1 & imm #2"; - ORI = 21, "BBD; #0 ← #1 | imm #2"; - XORI = 22, "BBD; #0 ← #1 ^ imm #2"; - SLI = 23, "BBD; #0 ← #1 « imm #2"; - SRI = 24, "BBD; #0 ← #1 » imm #2"; - SRSI = 25, "BBD; #0 ← #1 » imm #2 (signed)"; - CMPI = 26, "BBD; #0 ← #1 <=> imm #2"; - CMPUI = 27, "BBD; #0 ← #1 <=> imm #2 (unsigned)"; + ADDI = 15, "BBD; #0 ← #1 + imm #2"; + MULI = 16, "BBD; #0 ← #1 × imm #2"; + ANDI = 17, "BBD; #0 ← #1 & imm #2"; + ORI = 18, "BBD; #0 ← #1 | imm #2"; + XORI = 19, "BBD; #0 ← #1 ^ imm #2"; + SLI = 20, "BBD; #0 ← #1 « imm #2"; + SRI = 21, "BBD; #0 ← #1 » imm #2"; + SRSI = 22, "BBD; #0 ← #1 » imm #2 (signed)"; + CMPI = 23, "BBD; #0 ← #1 <=> imm #2"; + CMPUI = 24, "BBD; #0 ← #1 <=> imm #2 (unsigned)"; - CP = 28, "BB; Copy #0 ← #1"; - SWA = 29, "BB; Swap #0 and #1"; - LI = 30, "BD; #0 ← imm #1"; - LD = 31, "BBDB; #0 ← [#1 + imm #3], imm #4 bytes, overflowing"; - ST = 32, "BBDB; [#1 + imm #3] ← #0, imm #4 bytes, overflowing"; - BMC = 33, "BBD; [#0] ← [#1], imm #2 bytes"; - BRC = 34, "BBB; #0 ← #1, imm #2 registers"; + CP = 25, "BB; Copy #0 ← #1"; + SWA = 26, "BB; Swap #0 and #1"; + LI = 27, "BD; #0 ← imm #1"; + LD = 28, "BBDB; #0 ← [#1 + imm #3], imm #4 bytes, overflowing"; + ST = 29, "BBDB; [#1 + imm #3] ← #0, imm #4 bytes, overflowing"; + BMC = 30, "BBD; [#0] ← [#1], imm #2 bytes"; + BRC = 31, "BBB; #0 ← #1, imm #2 registers"; - JMP = 35, "BD; Unconditional jump [#0 + imm #1]"; - JEQ = 36, "BBD; if #0 = #1 → jump imm #2"; - JNE = 37, "BBD; if #0 ≠ #1 → jump imm #2"; - JLT = 38, "BBD; if #0 < #1 → jump imm #2"; - JGT = 39, "BBD; if #0 > #1 → jump imm #2"; - JLTU = 40, "BBD; if #0 < #1 → jump imm #2 (unsigned)"; - JGTU = 41, "BBD; if #0 > #1 → jump imm #2 (unsigned)"; - ECALL = 42, "N; Issue system call"; + JMP = 32, "BD; Unconditional jump [#0 + imm #1]"; + JEQ = 33, "BBD; if #0 = #1 → jump imm #2"; + JNE = 34, "BBD; if #0 ≠ #1 → jump imm #2"; + JLT = 35, "BBD; if #0 < #1 → jump imm #2"; + JGT = 36, "BBD; if #0 > #1 → jump imm #2"; + JLTU = 37, "BBD; if #0 < #1 → jump imm #2 (unsigned)"; + JGTU = 38, "BBD; if #0 > #1 → jump imm #2 (unsigned)"; + ECALL = 39, "N; Issue system call"; - ADDF = 43, "BBB; #0 ← #1 +. #2"; - MULF = 44, "BBB; #0 ← #1 +. #2"; - DIRF = 45, "BBBB; #0 ← #2 / #3, #1 ← #2 % #3"; + ADDF = 40, "BBB; #0 ← #1 +. #2"; + MULF = 41, "BBB; #0 ← #1 +. #2"; + DIRF = 42, "BBBB; #0 ← #2 / #3, #1 ← #2 % #3"; - ADDFI = 46, "BBD; #0 ← #1 +. imm #2"; - MULFI = 47, "BBD; #0 ← #1 *. imm #2"; + ADDFI = 43, "BBD; #0 ← #1 +. imm #2"; + MULFI = 44, "BBD; #0 ← #1 *. imm #2"; }); #[repr(packed)] diff --git a/spec.md b/spec.md index b8d73138..3d9ff087 100644 --- a/spec.md +++ b/spec.md @@ -93,22 +93,22 @@ | Opcode | Name | Action | |:------:|:----:|:-----------------------:| -| 18 | ADDI | Wrapping addition | -| 19 | MULI | Wrapping subtraction | -| 20 | ANDI | Bitand | -| 21 | ORI | Bitor | -| 22 | XORI | Bitxor | -| 23 | SLI | Unsigned left bitshift | -| 24 | SRI | Unsigned right bitshift | -| 25 | SRSI | Signed right bitshift | +| 15 | ADDI | Wrapping addition | +| 16 | MULI | Wrapping subtraction | +| 17 | ANDI | Bitand | +| 18 | ORI | Bitor | +| 19 | XORI | Bitxor | +| 20 | SLI | Unsigned left bitshift | +| 21 | SRI | Unsigned right bitshift | +| 22 | SRSI | Signed right bitshift | ### Comparsion - Comparsion is the same as when RRR type | Opcode | Name | Action | |:------:|:-----:|:-------------------:| -| 26 | CMPI | Signed comparsion | -| 27 | CMPUI | Unsigned comparsion | +| 23 | CMPI | Signed comparsion | +| 24 | CMPUI | Unsigned comparsion | ## Register value set / copy @@ -118,7 +118,7 @@ | Opcode | Name | Action | |:------:|:----:|:------:| -| 28 | CP | Copy | +| 25 | CP | Copy | ### Swap - Type BB @@ -126,7 +126,7 @@ | Opcode | Name | Action | |:------:|:----:|:------:| -| 29 | SWA | Swap | +| 26 | SWA | Swap | ### Load immediate - Type BD @@ -134,7 +134,7 @@ | Opcode | Name | Action | |:------:|:----:|:--------------:| -| 30 | LI | Load immediate | +| 27 | LI | Load immediate | ## Memory operations - Type BBDH @@ -143,8 +143,8 @@ ### Load / Store | Opcode | Name | Action | |:------:|:----:|:---------------------------------------:| -| 31 | LD | `#0 ← [#1 + imm #3], copy imm #4 bytes` | -| 32 | ST | `[#1 + imm #3] ← #0, copy imm #4 bytes` | +| 28 | LD | `#0 ← [#1 + imm #3], copy imm #4 bytes` | +| 29 | ST | `[#1 + imm #3] ← #0, copy imm #4 bytes` | ## Block copy - Block copy source and target can overlap @@ -154,7 +154,7 @@ | Opcode | Name | Action | |:------:|:----:|:--------------------------------:| -| 33 | BMC | `[#0] ← [#1], copy imm #2 bytes` | +| 30 | BMC | `[#0] ← [#1], copy imm #2 bytes` | ### Register copy - Type BBB @@ -162,7 +162,7 @@ | Opcode | Name | Action | |:------:|:----:|:--------------------------------:| -| 34 | BRC | `#0 ← #1, copy imm #2 registers` | +| 31 | BRC | `#0 ← #1, copy imm #2 registers` | ## Control flow @@ -171,7 +171,7 @@ | Opcode | Name | Action | |:------:|:----:|:---------------------:| -| 35 | JMP | Jump at `#0 + imm #1` | +| 32 | JMP | Jump at `#0 + imm #1` | ### Conditional jumps - Type BBD @@ -179,19 +179,19 @@ | Opcode | Name | Comparsion | |:------:|:----:|:------------:| -| 36 | JEQ | = | -| 37 | JNE | ≠ | -| 38 | JLT | < (signed) | -| 39 | JGT | > (signed) | -| 40 | JLTU | < (unsigned) | -| 41 | JGTU | > (unsigned) | +| 33 | JEQ | = | +| 34 | JNE | ≠ | +| 35 | JLT | < (signed) | +| 36 | JGT | > (signed) | +| 37 | JLTU | < (unsigned) | +| 38 | JGTU | > (unsigned) | ### Environment call - Type N | Opcode | Name | Action | |:------:|:-----:|:-------------------------------------:| -| 42 | ECALL | Cause an trap to the host environment | +| 39 | ECALL | Cause an trap to the host environment | ## Floating point operations - Type BBB @@ -199,15 +199,15 @@ | Opcode | Name | Action | |:------:|:----:|:--------------:| -| 43 | ADDF | Addition | -| 44 | MULF | Multiplication | +| 40 | ADDF | Addition | +| 41 | MULF | Multiplication | ### Division-remainder - Type BBBB | Opcode | Name | Action | |:------:|:----:|:--------------------------------------:| -| 45 | DIRF | Same flow applies as for integer `DIR` | +| 42 | DIRF | Same flow applies as for integer `DIR` | ## Floating point immediate operations - Type BBD @@ -215,8 +215,8 @@ | Opcode | Name | Action | |:------:|:-----:|:--------------:| -| 46 | ADDFI | Addition | -| 47 | MULFI | Multiplication | +| 43 | ADDFI | Addition | +| 44 | MULFI | Multiplication | # Registers - There is 255 registers + one zero register (with index 0)