done?
This commit is contained in:
parent
61bb14b9e3
commit
ad8728bdf4
19 changed files with 335 additions and 47 deletions
|
|
@ -1,37 +1,19 @@
|
|||
(* test_execute.ml *)
|
||||
|
||||
open Processor (* assuming your state, regs, and execute are defined here *)
|
||||
let regs = Processor.{a = 0; x = 0; l = 0; b = 0; s = 0; t = 0; f = 0.0; pc = 0; sw = 0}
|
||||
let memSize = 1 lsl 20 (*2^20*)
|
||||
let memory = Bytes.make memSize '\x00' (*mutbale kos pomnilnika velikosti memSize*)
|
||||
let state = Processor.{regs; memory}
|
||||
|
||||
(* Test function *)
|
||||
let test_execute () =
|
||||
(* Create a dummy state *)
|
||||
let mem_size = 1024 in
|
||||
let memory = Bytes.make mem_size '\000' in
|
||||
let regs = {
|
||||
a = 0; b = 0; x = 0; l = 0; s = 0; t = 0; f = 0.0;
|
||||
pc = 0; sw = 0
|
||||
} in
|
||||
let state = { memory; regs } in
|
||||
let test_runner () =
|
||||
let khz = 0.001 in
|
||||
Processor.print_memory state 50;
|
||||
Loader.load_object_file state "/mnt/c/Programiranje/SPO/ass1/horner.obj";
|
||||
Processor.print_memory state 50;
|
||||
Printf.printf "\n\n---Starting execution!---\n\n";
|
||||
Pogajalnik.run state khz
|
||||
|
||||
(* Example: Write a LDA instruction at address 0*)
|
||||
Processor.write_instruction3 state 0 '\x01' '\x00' '\x23';
|
||||
|
||||
(* Write the operand value at 0x010 *)
|
||||
Processor.writeMemAddr state 0x010 0x123456;
|
||||
|
||||
(* Set PC to 0 *)
|
||||
state.regs.pc <- 0;
|
||||
|
||||
Printf.printf "Before execution:\n";
|
||||
Processor.print_regs state;
|
||||
Processor.print_memory state 15;
|
||||
|
||||
(* Execute instruction *)
|
||||
Izvajalnik.execute state;
|
||||
|
||||
Printf.printf "After execution:\n";
|
||||
Processor.print_regs state;
|
||||
Processor.print_memory state 15
|
||||
|
||||
(* Run the test *)
|
||||
let () = test_execute ()
|
||||
let () = test_runner ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue