completed assignment 2
This commit is contained in:
parent
7106f34a4e
commit
909ef0f639
18 changed files with 25 additions and 1041 deletions
|
|
@ -171,7 +171,7 @@ let executeFormat3 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
| SUB -> IzvajalnikF3.sub state operand
|
||||
| SUBF -> notImplemented "SUBF3"
|
||||
| TD -> notImplemented "TD3"
|
||||
| WD -> notImplemented "WD3"
|
||||
| WD -> IzvajalnikF3.wd state operand
|
||||
|
||||
(* Jump / subroutine *)
|
||||
| J -> IzvajalnikF3.j state ea
|
||||
|
|
@ -184,7 +184,7 @@ let executeFormat3 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
(* Load/store *)
|
||||
| LDA -> IzvajalnikF3.lda state operand
|
||||
| LDB -> IzvajalnikF3.ldb state operand
|
||||
| LDCH -> notImplemented "LDCH3"
|
||||
| LDCH -> IzvajalnikF3.ldch state operand
|
||||
| LDF -> notImplemented "LDF3"
|
||||
| LDL -> IzvajalnikF3.ldl state operand
|
||||
| LDS -> IzvajalnikF3.lds state operand
|
||||
|
|
@ -193,7 +193,7 @@ let executeFormat3 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
| LPS -> notImplemented "LPS4"
|
||||
| STA -> IzvajalnikF3.sta state operand
|
||||
| STB -> IzvajalnikF3.stb state operand
|
||||
| STCH -> notImplemented "STCH4"
|
||||
| STCH -> IzvajalnikF3.stch state operand
|
||||
| STF -> notImplemented "STF4"
|
||||
| STL -> IzvajalnikF3.stl state ea
|
||||
| STS -> IzvajalnikF3.sts state ea
|
||||
|
|
|
|||
|
|
@ -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