File tree 2 files changed +16
-5
lines changed
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -50,4 +50,16 @@ impl Instruction {
50
50
51
51
Ok ( Instruction { opcode, op0, op1 } )
52
52
}
53
+
54
+ pub fn opcode ( & self ) -> OpCode {
55
+ self . opcode . clone ( )
56
+ }
57
+
58
+ pub fn op0 ( & self ) -> u8 {
59
+ self . op0
60
+ }
61
+
62
+ pub fn op1 ( & self ) -> u8 {
63
+ self . op1
64
+ }
53
65
}
Original file line number Diff line number Diff line change @@ -43,14 +43,13 @@ fn main() -> Result<(), Error> {
43
43
"do-core-1: instruction decoded into {:?}" ,
44
44
decoded_instruction
45
45
) ;
46
- let op0 = decoded_instruction. op0 as usize ;
47
- let op1 = decoded_instruction. op1 as usize ;
46
+ let op0 = decoded_instruction. op0 ( ) as usize ;
47
+ let op1 = decoded_instruction. op1 ( ) as usize ;
48
48
49
- match decoded_instruction. opcode {
49
+ match decoded_instruction. opcode ( ) {
50
50
OpCode :: ADD => registers[ op0] = add ( registers[ op0] , registers[ op1] ) ?,
51
51
OpCode :: XOR => registers[ op0] = xor ( registers[ op0] , registers[ op1] ) ,
52
-
53
- _ => panic ! ( "Unknown opcode {:?}" , decoded_instruction. opcode) ,
52
+ _ => panic ! ( "Unknown opcode {:?}" , decoded_instruction. opcode( ) ) ,
54
53
}
55
54
56
55
dump_cpu_state ( "Final CPU state" , & registers) ;
You can’t perform that action at this time.
0 commit comments