JMP → JAL + spec fix
This commit is contained in:
parent
ad9868c1c0
commit
a9e4aaba0e
|
@ -21,11 +21,11 @@ macros::impl_both!(
|
||||||
=> [LD, ST],
|
=> [LD, ST],
|
||||||
bbd(p0: R, p1: R, p2: I)
|
bbd(p0: R, p1: R, p2: I)
|
||||||
=> [ADDI, MULI, ANDI, ORI, XORI, SLI, SRI, SRSI, CMPI, CMPUI,
|
=> [ADDI, MULI, ANDI, ORI, XORI, SLI, SRI, SRSI, CMPI, CMPUI,
|
||||||
BMC, JEQ, JNE, JLT, JGT, JLTU, JGTU, ADDFI, MULFI],
|
BMC, JAL, JEQ, JNE, JLT, JGT, JLTU, JGTU, ADDFI, MULFI],
|
||||||
bb(p0: R, p1: R)
|
bb(p0: R, p1: R)
|
||||||
=> [NEG, NOT, CP, SWA, NEGF, ITF, FTI],
|
=> [NEG, NOT, CP, SWA, NEGF, ITF, FTI],
|
||||||
bd(p0: R, p1: I)
|
bd(p0: R, p1: I)
|
||||||
=> [LI, JMP],
|
=> [LI],
|
||||||
n()
|
n()
|
||||||
=> [NOP, ECALL],
|
=> [NOP, ECALL],
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,7 +54,7 @@ constmod!(pub opcode(u8) {
|
||||||
BMC = 30, "BBD; [#0] ← [#1], imm #2 bytes";
|
BMC = 30, "BBD; [#0] ← [#1], imm #2 bytes";
|
||||||
BRC = 31, "BBB; #0 ← #1, imm #2 registers";
|
BRC = 31, "BBB; #0 ← #1, imm #2 registers";
|
||||||
|
|
||||||
JMP = 32, "BD; Unconditional jump [#0 + imm #1]";
|
JAL = 32, "BD; Copy PC to #0 and unconditional jump [#1 + imm #2]";
|
||||||
JEQ = 33, "BBD; if #0 = #1 → jump imm #2";
|
JEQ = 33, "BBD; if #0 = #1 → jump imm #2";
|
||||||
JNE = 34, "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";
|
JLT = 35, "BBD; if #0 < #1 → jump imm #2";
|
||||||
|
|
|
@ -50,8 +50,8 @@ pub fn validate(mut program: &[u8]) -> Result<(), Error> {
|
||||||
| [DIR | DIRF, _, _, _, _, rest @ ..]
|
| [DIR | DIRF, _, _, _, _, rest @ ..]
|
||||||
| [ADD..=CMPU | BRC | ADDF..=MULF, _, _, _, rest @ ..]
|
| [ADD..=CMPU | BRC | ADDF..=MULF, _, _, _, rest @ ..]
|
||||||
| [NEG..=NOT | CP..=SWA | NEGF..=FTI, _, _, rest @ ..]
|
| [NEG..=NOT | CP..=SWA | NEGF..=FTI, _, _, rest @ ..]
|
||||||
| [LI | JMP, _, _, _, _, _, _, _, _, _, rest @ ..]
|
| [LI, _, _, _, _, _, _, _, _, _, rest @ ..]
|
||||||
| [ADDI..=CMPUI | BMC | JEQ..=JGTU | ADDFI..=MULFI, _, _, _, _, _, _, _, _, _, _, rest @ ..]
|
| [ADDI..=CMPUI | BMC | JAL..=JGTU | ADDFI..=MULFI, _, _, _, _, _, _, _, _, _, _, rest @ ..]
|
||||||
| [LD..=ST, _, _, _, _, _, _, _, _, _, _, _, _, rest @ ..] => rest,
|
| [LD..=ST, _, _, _, _, _, _, _, _, _, _, _, _, rest @ ..] => rest,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
|
|
|
@ -259,8 +259,9 @@ impl<'a, PfHandler: HandlePageFault, const TIMER_QUOTIENT: usize>
|
||||||
usize::from(count * 8),
|
usize::from(count * 8),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
JMP => {
|
JAL => {
|
||||||
let ParamBD(reg, offset) = param!(self, ParamBD);
|
let ParamBBD(save, reg, offset) = param!(self, ParamBBD);
|
||||||
|
self.write_reg(save, self.pc as u64);
|
||||||
self.pc = (self.read_reg(reg).as_u64() + offset) as usize;
|
self.pc = (self.read_reg(reg).as_u64() + offset) as usize;
|
||||||
}
|
}
|
||||||
JEQ => cond_jump!(self, int, Equal),
|
JEQ => cond_jump!(self, int, Equal),
|
||||||
|
|
12
spec.md
12
spec.md
|
@ -153,7 +153,7 @@
|
||||||
|
|
||||||
| Opcode | Name | Action |
|
| Opcode | Name | Action |
|
||||||
|:------:|:----:|:--------------------------------:|
|
|:------:|:----:|:--------------------------------:|
|
||||||
| 30 | BMC | `[#0] ← [#1], copy imm #2 bytes` |
|
| 30 | BMC | `[#1] ← [#0], copy imm #2 bytes` |
|
||||||
|
|
||||||
### Register copy
|
### Register copy
|
||||||
- Type BBB
|
- Type BBB
|
||||||
|
@ -161,16 +161,16 @@
|
||||||
|
|
||||||
| Opcode | Name | Action |
|
| Opcode | Name | Action |
|
||||||
|:------:|:----:|:--------------------------------:|
|
|:------:|:----:|:--------------------------------:|
|
||||||
| 31 | BRC | `#0 ← #1, copy imm #2 registers` |
|
| 31 | BRC | `#1 ← #0, copy imm #2 registers` |
|
||||||
|
|
||||||
## Control flow
|
## Control flow
|
||||||
|
|
||||||
### Unconditional jump
|
### Unconditional jump
|
||||||
- Type BD
|
- Type BBD
|
||||||
|
|
||||||
| Opcode | Name | Action |
|
| Opcode | Name | Action |
|
||||||
|:------:|:----:|:---------------------:|
|
|:------:|:----:|:-------------------------------------------------:|
|
||||||
| 32 | JMP | Jump at `#0 + imm #1` |
|
| 32 | JAL | Save current PC to `#0` and jump at `#1 + imm #2` |
|
||||||
|
|
||||||
### Conditional jumps
|
### Conditional jumps
|
||||||
- Type BBD
|
- Type BBD
|
||||||
|
|
Loading…
Reference in a new issue