forked from AbleOS/holey-bytes
relative JAL
This commit is contained in:
parent
0e701e31b5
commit
a944a145ed
|
@ -82,8 +82,8 @@
|
||||||
0x51, BMC, RRH, "Copy block of memory" ;
|
0x51, BMC, RRH, "Copy block of memory" ;
|
||||||
0x52, BRC, RRB, "Copy register block" ;
|
0x52, BRC, RRB, "Copy register block" ;
|
||||||
0x53, JMP, O, "Relative jump" ;
|
0x53, JMP, O, "Relative jump" ;
|
||||||
0x54, JAL, RRA, "Linking absolute jump" ;
|
0x54, JAL, RRO, "Linking relative jump" ;
|
||||||
0x55, JALR, RRO, "Linking relative jump" ;
|
0x55, JALA, RRA, "Linking absolute jump" ;
|
||||||
0x56, JEQ, RRP, "Branch on equal" ;
|
0x56, JEQ, RRP, "Branch on equal" ;
|
||||||
0x57, JNE, RRP, "Branch on nonequal" ;
|
0x57, JNE, RRP, "Branch on nonequal" ;
|
||||||
0x58, JLT, RRP, "Branch on lesser-than (signed)" ;
|
0x58, JLT, RRP, "Branch on lesser-than (signed)" ;
|
||||||
|
|
|
@ -280,7 +280,16 @@ where
|
||||||
JMP => handler!(self, |OpsO(off)| self.pc = self.pc.wrapping_add(off)),
|
JMP => handler!(self, |OpsO(off)| self.pc = self.pc.wrapping_add(off)),
|
||||||
JAL => handler!(self, |OpsRRW(save, reg, offset)| {
|
JAL => handler!(self, |OpsRRW(save, reg, offset)| {
|
||||||
// Jump and link. Save PC after this instruction to
|
// Jump and link. Save PC after this instruction to
|
||||||
// specified register and jump to reg + offset.
|
// specified register and jump to reg + relative offset.
|
||||||
|
self.write_reg(save, self.pc.get());
|
||||||
|
self.pc = self
|
||||||
|
.pc
|
||||||
|
.wrapping_add(self.read_reg(reg).cast::<u64>())
|
||||||
|
.wrapping_add(offset);
|
||||||
|
}),
|
||||||
|
JALA => handler!(self, |OpsRRW(save, reg, offset)| {
|
||||||
|
// Jump and link. Save PC after this instruction to
|
||||||
|
// specified register and jump to reg
|
||||||
self.write_reg(save, self.pc.get());
|
self.write_reg(save, self.pc.get());
|
||||||
self.pc = Address::new(
|
self.pc = Address::new(
|
||||||
self.read_reg(reg).cast::<u64>().wrapping_add(offset.into()),
|
self.read_reg(reg).cast::<u64>().wrapping_add(offset.into()),
|
||||||
|
@ -400,7 +409,9 @@ where
|
||||||
/// Bump instruction pointer
|
/// Bump instruction pointer
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn bump_pc<T: Copy, const PAST_OP: bool>(&mut self) {
|
fn bump_pc<T: Copy, const PAST_OP: bool>(&mut self) {
|
||||||
self.pc = self.pc.wrapping_add(core::mem::size_of::<T>() + PAST_OP as usize);
|
self.pc = self
|
||||||
|
.pc
|
||||||
|
.wrapping_add(core::mem::size_of::<T>() + PAST_OP as usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode instruction operands
|
/// Decode instruction operands
|
||||||
|
|
Loading…
Reference in a new issue