Implement print functionality
This commit is contained in:
parent
15aa810564
commit
1fb0530a13
10
src/main.rs
10
src/main.rs
|
@ -26,8 +26,14 @@ impl Program {
|
||||||
fn run(&mut self) {
|
fn run(&mut self) {
|
||||||
println!("{}", self);
|
println!("{}", self);
|
||||||
while self.pc < self.data.len() {
|
while self.pc < self.data.len() {
|
||||||
println!("PC is {}", self.pc);
|
let instruction = &self.data[self.pc];
|
||||||
let opcode = &self.data[self.pc];
|
let instruction_vec: Vec<char> = instruction.chars().collect();
|
||||||
|
let opcode = instruction_vec[0];
|
||||||
|
|
||||||
|
match opcode {
|
||||||
|
'p' => print!("{}", instruction_vec[1]),
|
||||||
|
_ => panic!("SyntaxError at opcode {}!", self.pc)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
self.pc = self.pc + 1;
|
self.pc = self.pc + 1;
|
||||||
|
|
Loading…
Reference in New Issue