Skip to content

Commit

Permalink
Add int instruction, bump version to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ry755 committed Aug 9, 2022
1 parent ad6f402 commit 4b506f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[package]
name = "fox32"
version = "0.1.0"
version = "0.2.0"
authors = ["ry"]
edition = "2021"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
image = "0.24"
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion docs/encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If the instruction doesn't allow variable sizes or a size was not specified, set
| :-: | ---- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | -------------- | ---- | ----- | -------------- | --- | --- | --- | --- | --- |
| 0- | NOP | ADD[.8,16,32] | MUL[.8,16,32] | AND[.8,16,32] | SLA[.8,16,32] | SRA[.8,16,32] | BSE[.8,16,32] | CMP[.8,16,32] | JMP | RJMP | PUSH[.8,16,32] | IN | ISE | | | |
| 1- | HALT | INC[.8,16,32] | | OR[.8,16,32] | | SRL[.8,16,32] | BCL[.8,16,32] | MOV[.8,16,32] | CALL | RCALL | POP[.8,16,32] | OUT | ICL | | | |
| 2- | BRK | SUB[.8,16,32] | DIV[.8,16,32] | XOR[.8,16,32] | ROL[.8,16,32] | ROR[.8,16,32] | BTS[.8,16,32] | MOVZ[.8,16,32] | LOOP | RLOOP | RET | | | | | |
| 2- | BRK | SUB[.8,16,32] | DIV[.8,16,32] | XOR[.8,16,32] | ROL[.8,16,32] | ROR[.8,16,32] | BTS[.8,16,32] | MOVZ[.8,16,32] | LOOP | RLOOP | RET | | INT | | | |
| 3- | | DEC[.8,16,32] | REM[.8,16,32] | NOT[.8,16,32] | | | | | | RTA | RETI | | | | | |

# Condition table
Expand Down
13 changes: 13 additions & 0 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,17 @@ impl Cpu {
}
self.instruction_pointer + instruction_pointer_offset
}
Instruction::Int(condition, source) => {
let (source_value, instruction_pointer_offset) = self.read_source(source);
let should_run = self.check_condition(condition);
if should_run {
self.instruction_pointer += instruction_pointer_offset;
self.handle_interrupt(source_value as u16);
self.instruction_pointer
} else {
self.instruction_pointer + instruction_pointer_offset
}
}
}
}
}
Expand Down Expand Up @@ -2660,6 +2671,7 @@ enum Instruction {

Ise(Condition),
Icl(Condition),
Int(Condition, Operand),
}

impl Instruction {
Expand Down Expand Up @@ -2754,6 +2766,7 @@ impl Instruction {

0x0C => Some(Instruction::Ise(condition)),
0x1C => Some(Instruction::Icl(condition)),
0x2C => Some(Instruction::Int(condition, source)),

_ => None,
}
Expand Down

0 comments on commit 4b506f3

Please sign in to comment.