finally add the RET instruction
A Chip-8 program that does something with the display (that is skipped) which i'm using to test now actually causes a stack overflow!
This commit is contained in:
parent
348b764f08
commit
ba22aa482c
3 changed files with 7 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,4 +4,4 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "celc8"
|
name = "celc8"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "celc8"
|
name = "celc8"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -246,7 +246,11 @@ fn execute(opcode: u16, instruction: Instruction, mut cpu: Cpu) -> Cpu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if instruction.name == "JP_ADDR" { cpu.setpc(args[0] as u16); }
|
if instruction.name == "RET" {
|
||||||
|
let returnaddress = cpu.stackpop();
|
||||||
|
cpu.setpc(returnaddress);
|
||||||
|
}
|
||||||
|
else if instruction.name == "JP_ADDR" { cpu.setpc(args[0] as u16); }
|
||||||
else if instruction.name == "CALL_ADDR" {
|
else if instruction.name == "CALL_ADDR" {
|
||||||
cpu.incrementsp();
|
cpu.incrementsp();
|
||||||
cpu.stackpush();
|
cpu.stackpush();
|
||||||
|
|
Reference in a new issue