working...1
This commit is contained in:
parent
bc78a83838
commit
61bb14b9e3
21 changed files with 1054 additions and 12 deletions
|
|
@ -39,7 +39,7 @@ let readR1R2 (state : Processor.state) : (int * int) =
|
|||
(highNibble, lowNibble)
|
||||
|
||||
(*preberi byta 1 in 2 in dobi nixbpe bite*)
|
||||
let getNIXBPE (state : Processor.state) : nixbpe =
|
||||
let readNIXBPE (state : Processor.state) : nixbpe =
|
||||
let byte1 = Char.code (Processor.readMem state 0) in
|
||||
let byte2 = Char.code (Processor.readMem state 1) in
|
||||
{n = (byte1 lsr 1) land 1;
|
||||
|
|
@ -52,7 +52,7 @@ let getNIXBPE (state : Processor.state) : nixbpe =
|
|||
|
||||
(*dobi disp iz tipa ukaza 3*)
|
||||
(*TODO pretvori v negativno število glede na nxibpe*)
|
||||
let getDisp (state : Processor.state) : int =
|
||||
let readDisp (state : Processor.state) : int =
|
||||
let byte2 = Char.code (Processor.readMem state 1) in
|
||||
let byte3 = Char.code (Processor.readMem state 2) in
|
||||
let disp_high = byte2 land 0x0F in
|
||||
|
|
@ -61,7 +61,7 @@ let getDisp (state : Processor.state) : int =
|
|||
|
||||
(*dobi address iz tip ukaza 4*)
|
||||
(*TODO preveri ali mores paziti negativnost*)
|
||||
let getAddress (state : Processor.state) : int =
|
||||
let readAddress (state : Processor.state) : int =
|
||||
let byte2 = Char.code (Processor.readMem state 1) in
|
||||
let byte3 = Char.code (Processor.readMem state 2) in
|
||||
let byte4 = Char.code (Processor.readMem state 3) in
|
||||
|
|
@ -71,7 +71,8 @@ let getAddress (state : Processor.state) : int =
|
|||
let address = (addr_high lsl 8) lor byte4 in
|
||||
address
|
||||
|
||||
let getOperand (state : Processor.state) (nixbpe : nixbpe) (disp : int) : int =
|
||||
(*pridobi operand*)
|
||||
let getOperand (state : Processor.state) (nixbpe : nixbpe) (disp : int) : int =
|
||||
let ea =
|
||||
if nixbpe.b = 1 && nixbpe.p = 0 then state.regs.b + disp (*B relativno*)
|
||||
else if nixbpe.p = 1 && nixbpe.b = 0 then state.regs.pc + disp (*PC relativno*)
|
||||
|
|
@ -131,7 +132,7 @@ let executeFormat2 (state: Processor.state) (mnemonic : OpcodeTable.mnemonic) :
|
|||
|
||||
(*execute Format 3*)
|
||||
let executeFormat3 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: OpcodeTable.mnemonic): unit =
|
||||
let disp = getDisp state in
|
||||
let disp = readDisp state in
|
||||
let operand = getOperand state nixbpe disp in
|
||||
(*debugging*)
|
||||
Printf.printf "[Izvajalnik/executeFormat3] Mnemonic: %s, nixbpe: %s, operand: %d = 0x%02X\n"
|
||||
|
|
@ -158,7 +159,7 @@ let executeFormat3 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
| JGT -> IzvajalnikF3.jgt state operand
|
||||
| JLT -> IzvajalnikF3.jlt state operand
|
||||
| JSUB -> IzvajalnikF3.jsub state operand
|
||||
| RSUB -> IzvajalnikF3.rsub state operand
|
||||
| RSUB -> IzvajalnikF3.rsub state
|
||||
|
||||
(* Load/store *)
|
||||
| LDA -> IzvajalnikF3.lda state operand
|
||||
|
|
@ -186,7 +187,7 @@ let executeFormat3 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
|
||||
|
||||
let executeFormat4 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: OpcodeTable.mnemonic): unit =
|
||||
let address = getAddress state in
|
||||
let address = readAddress state in
|
||||
let operand = getOperand state nixbpe address in
|
||||
(*debugging*)
|
||||
Printf.printf "[Izvajalnik/executeFormat4] Mnemonic: %s, nixbpe: %s, operand: %d = 0x%02X\n"
|
||||
|
|
@ -213,7 +214,7 @@ let executeFormat4 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
| JGT -> IzvajalnikF4.jgt state operand
|
||||
| JLT -> IzvajalnikF4.jlt state operand
|
||||
| JSUB -> IzvajalnikF4.jsub state operand
|
||||
| RSUB -> IzvajalnikF4.rsub state operand
|
||||
| RSUB -> IzvajalnikF4.rsub state
|
||||
|
||||
(* Load/store *)
|
||||
| LDA -> IzvajalnikF4.lda state operand
|
||||
|
|
@ -243,7 +244,7 @@ let executeFormat4 (state : Processor.state) (nixbpe : nixbpe) (mnemonic: Opcode
|
|||
|
||||
(*execute format 3_4*)
|
||||
let executeFormat3_4 (state : Processor.state) (mnemonic : OpcodeTable.mnemonic) : unit =
|
||||
let nixbpe = getNIXBPE state in
|
||||
let nixbpe = readNIXBPE state in
|
||||
(*debugging*)
|
||||
Printf.printf "[Izvajalnik/executeFormat3_4]n=%d,i=%d,x=%d,b=%d,p=%d,e=%d\n" nixbpe.n nixbpe.i nixbpe.x nixbpe.b nixbpe.p nixbpe.e;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue