Skip to content

Commit

Permalink
add instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Sep 5, 2024
1 parent 6495bca commit d0b3604
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
A RISC-V emulator made in Rust.

Work in progress.

Extensions implemented:

- RV32I
- RV64I
- Ziscr
- Zicntr
- Zicond
18 changes: 18 additions & 0 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ impl Cpu {
debug!("SLTU");
self.regs[rd] = (self.regs[rs1] < self.regs[rs2]) as u64
}
(0x5, 0x7) => {
debug!("CZERO.EQZ");

if self.regs[rs2] == 0 {
self.regs[rd] = 0;
} else {
self.regs[rd] = self.regs[rs1];
}
}
(0x7, 0x7) => {
debug!("CZERO.NEZ");

if self.regs[rs2] != 0 {
self.regs[rd] = 0;
} else {
self.regs[rd] = self.regs[rs1];
}
}
_ => Err(())?,
}
}
Expand Down

0 comments on commit d0b3604

Please sign in to comment.