working on sicxe

This commit is contained in:
Jaka Furlan 2025-11-29 16:12:58 +01:00
parent 1b990e190c
commit d836b3955d
79 changed files with 2011 additions and 917 deletions

View file

@ -51,7 +51,7 @@ let readMem (state : state) (offset : int) : char =
(*beri drugi byte ukaza formata 2 in vrni r1 in r2, kot int njunih vrednosti (reg a -> 1, reg x -> 2 ...)*)
let readFormat2Byte2 (state : state) : (int * int) =
let readR1R2 (state : state) : (int * int) =
let byte2 = Char.code (readMem state 1) in
let highNibble = (byte2 land 0xF0) lsr 4 in (*pridobi prvi nibble*)
let lowNibble = byte2 land 0x0F in (*pridobi drugi nibble*)
@ -69,6 +69,10 @@ let getNIXBPE (state : state) : nixbpe =
e = (byte2 lsr 4) land 1;}
let getAddress (state : state) : int =
42
(*execute format 1*)
let executeFormat1 (state : state) (mnemonic : OpcodeTable.mnemonic) : unit =
match mnemonic with
@ -78,12 +82,13 @@ let executeFormat1 (state : state) (mnemonic : OpcodeTable.mnemonic) : unit =
| NORM -> notImplemented "NORM"
| SIO -> notImplemented "SIO"
| TIO -> notImplemented "TIO"
| _ -> Printf.printf "Mnemonic %s falsely flaged as format 1" (OpcodeTable.string_of_mnemonic mnemonic)
|_ -> failwith ("Mnemonic" ^ (OpcodeTable.string_of_mnemonic mnemonic) ^ "falsely flaged as format 1")
(*execute format 2*)
let executeFormat2 (state: state) (mnemonic : OpcodeTable.mnemonic) : unit =
let (r1, r2) = readFormat2Byte2 state in
let (r1, r2) = readR1R2 state in
match mnemonic with
| ADDR -> notImplemented "ADD" (*when implemented: -> add state r1 r2*)
| CLEAR -> notImplemented "CLEAR"
@ -96,18 +101,117 @@ let executeFormat2 (state: state) (mnemonic : OpcodeTable.mnemonic) : unit =
| SUBR -> notImplemented "F2"
| SVC -> notImplemented "F2"
| TIXR -> notImplemented "F2"
|_ -> Printf.printf "Mnemonic %s falsely flaged as format 1" (OpcodeTable.string_of_mnemonic mnemonic)
|_ -> failwith ("Mnemonic" ^ (OpcodeTable.string_of_mnemonic mnemonic) ^ "falsely flaged as format 2")
let executeFormat3 (state : state) (nixbpe : nixbpe) : unit
(*execute Format 3*)
let executeFormat3 (state : state) (nixbpe : nixbpe) (mnemonic: OpcodeTable.mnemonic): unit =
let address = getAddress state in
match mnemonic with
| ADD -> notImplemented "ADD3"
| ADDF -> notImplemented "ADDF4"
| AND -> notImplemented "AND4"
| COMP -> notImplemented "COMP4"
| COMPF -> notImplemented "COMPF4"
| DIV -> notImplemented "DIV4"
| MUL -> notImplemented "MUL4"
| OR -> notImplemented "OR4"
| SUB -> notImplemented "SUB4"
| SUBF -> notImplemented "SUBF4"
| TD -> notImplemented "TD4"
| WD -> notImplemented "WD4"
(* Jump / subroutine *)
| J -> notImplemented "J4"
| JEQ -> notImplemented "JEQ4"
| JGT -> notImplemented "JGT4"
| JLT -> notImplemented "JLT4"
| JSUB -> notImplemented "JSUB4"
| RSUB -> notImplemented "RSUB4"
(* Load/store *)
| LDA -> notImplemented "LDA4"
| LDB -> notImplemented "LDB4"
| LDCH -> notImplemented "LDCH4"
| LDF -> notImplemented "LDF4"
| LDL -> notImplemented "LDL4"
| LDS -> notImplemented "LDS4"
| LDT -> notImplemented "LDT4"
| LDX -> notImplemented "LDX4"
| LPS -> notImplemented "LPS4"
| STA -> notImplemented "STA4"
| STB -> notImplemented "STB4"
| STCH -> notImplemented "STCH4"
| STF -> notImplemented "STF4"
| STL -> notImplemented "STL4"
| STS -> notImplemented "STS4"
| STSW -> notImplemented "STSW4"
| STT -> notImplemented "STT4"
| STX -> notImplemented "STX4"
(* Control / IO *)
| TIX -> notImplemented "TIX4"
|_ -> failwith ("Mnemonic" ^ (OpcodeTable.string_of_mnemonic mnemonic) ^ "falsely flaged as format 3")
(*execute format 3*)
let executeFormat4 (state : state) (nixbpe : nixbpe) (mnemonic: OpcodeTable.mnemonic): unit =
let address = getAddress state in
match mnemonic with
(*aritmetika*)
| ADD -> notImplemented "ADD4"
| ADDF -> notImplemented "ADDF4"
| AND -> notImplemented "AND4"
| COMP -> notImplemented "COMP4"
| COMPF -> notImplemented "COMPF4"
| DIV -> notImplemented "DIV4"
| MUL -> notImplemented "MUL4"
| OR -> notImplemented "OR4"
| SUB -> notImplemented "SUB4"
| SUBF -> notImplemented "SUBF4"
| TD -> notImplemented "TD4"
| WD -> notImplemented "WD4"
(* Jump / subroutine *)
| J -> notImplemented "J4"
| JEQ -> notImplemented "JEQ4"
| JGT -> notImplemented "JGT4"
| JLT -> notImplemented "JLT4"
| JSUB -> notImplemented "JSUB4"
| RSUB -> notImplemented "RSUB4"
(* Load/store *)
| LDA -> notImplemented "LDA4"
| LDB -> notImplemented "LDB4"
| LDCH -> notImplemented "LDCH4"
| LDF -> notImplemented "LDF4"
| LDL -> notImplemented "LDL4"
| LDS -> notImplemented "LDS4"
| LDT -> notImplemented "LDT4"
| LDX -> notImplemented "LDX4"
| LPS -> notImplemented "LPS4"
| STA -> notImplemented "STA4"
| STB -> notImplemented "STB4"
| STCH -> notImplemented "STCH4"
| STF -> notImplemented "STF4"
| STL -> notImplemented "STL4"
| STS -> notImplemented "STS4"
| STSW -> notImplemented "STSW4"
| STT -> notImplemented "STT4"
| STX -> notImplemented "STX4"
(* Control / IO *)
| TIX -> notImplemented "TIX4"
|_ -> failwith ("Mnemonic" ^ (OpcodeTable.string_of_mnemonic mnemonic) ^ "falsely flaged as format 4")
(*execute format 3_4*)
let executeFormat3_4 (state : state) (mnemonic : OpcodeTable.mnemonic) : unit =
let nixbpe = getNIXBPE state in
match nixbpe.e with
| 0 -> executeFormat3 state
| 1 -> executeFormat4 state
| 0 -> executeFormat3 state nixbpe mnemonic
| 1 -> executeFormat4 state nixbpe mnemonic
| _ -> failwith "invalid computation of nxbpe"