completed assignment 2
This commit is contained in:
parent
7106f34a4e
commit
909ef0f639
18 changed files with 25 additions and 1041 deletions
|
|
@ -39,6 +39,23 @@ let sub (state : Processor.state) (operand : int) : unit =
|
|||
let valA = state.regs.a in
|
||||
state.regs.a <- valA - operand
|
||||
|
||||
(*Device specified by (m) <- (A)[rightmost byte]*)
|
||||
let wd (state : Processor.state) (operand : int) : unit =
|
||||
let charA = char_of_int (state.regs.a land 0xFF) in
|
||||
match operand with
|
||||
| 0 -> failwith "not implemented"
|
||||
| 1 -> Printf.printf "[STDOUT]: %c\n" charA
|
||||
| 2 -> failwith "not implemented"
|
||||
| _ -> failwith "unsupporterd operand"
|
||||
|
||||
(*(A)[rightmost byte] <- Device specified by (m)*)
|
||||
let rd (state : Processor.state) (operand : int) : unit =
|
||||
match operand with
|
||||
| 0 -> let charIn = input_char stdin in state.regs.a <- Char.code charIn
|
||||
| 1 -> failwith "not implemented"
|
||||
| 2 -> failwith "not implemented"
|
||||
| _ -> failwith "unsupporterd operand"
|
||||
|
||||
(*PC <- m*)
|
||||
let j (state : Processor.state) (operand : int) : unit =
|
||||
state.regs.pc <- operand
|
||||
|
|
@ -84,7 +101,7 @@ let ldb (state : Processor.state) (operand : int) : unit =
|
|||
(*A [rightmost byte] ← (m)*)
|
||||
(*TODO*)
|
||||
let ldch (state : Processor.state) (operand : int) : unit =
|
||||
state.regs.a <- operand
|
||||
state.regs.a <- (0xFF land operand)
|
||||
|
||||
(* LDX: X <- (m..m+2) *)
|
||||
let ldx (state : Processor.state) (operand : int) : unit =
|
||||
|
|
@ -137,6 +154,10 @@ let stsw (state : Processor.state) (operand : int) : unit =
|
|||
let valSW = state.regs.s in
|
||||
Processor.writeMemAddr state operand valSW
|
||||
|
||||
let stch (state : Processor.state) (operand : int) : unit =
|
||||
let byte = state.regs.a land 0xFF in
|
||||
Bytes.set state.memory operand (char_of_int byte)
|
||||
|
||||
(* m..m+2 <- T register *)
|
||||
let stt (state : Processor.state) (operand : int) : unit =
|
||||
let valT = state.regs.t in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue