working on ass3, todo pc, nixbpe

This commit is contained in:
Jaka Furlan 2025-12-14 23:31:52 +01:00
parent 6261d9fe37
commit beabcde7db
15 changed files with 412 additions and 194 deletions

View file

@ -2,6 +2,8 @@ open Zbirnik.Parser
open Zbirnik.SemanticAnalyzer
open Zbirnik.PrehodPrvi
open Zbirnik.Simtab
open Zbirnik.DrugiPrehod
open Zbirnik.OpcodeTable
(* Helper functions to print optional values *)
@ -27,14 +29,17 @@ let print_lineSemantic_list (lines : lineSemantic list) : unit =
) lines
let print_intermediate_file_list (lines : lineSemantic list) : unit =
List.iter (fun l ->
Printf.printf "%s | %8s | %6s | %20s | %s\n"
(print_opt_int l.loc)
(print_opt_string l.label)
(string_of_mnemonic l.opcode)
(string_of_mnemonic_type l.mnem)
(print_opt_string l.comment)
) lines
List.iter (fun l ->
Printf.printf "%s | %8s | %6s | %20s | x=%d | n = %d | i = %d | %s\n"
(print_opt_int l.loc)
(print_opt_string l.label)
(string_of_mnemonic l.opcode)
(string_of_mnemonic_type l.mnem)
(if l.x then 1 else 0)
(if l.n then 1 else 0)
(if l.i then 1 else 0)
(print_opt_string l.comment)
) lines
let print_symtab (tab : symtab) : unit =
Printf.printf "\nSYMBOL TABLE\n";
@ -46,6 +51,9 @@ let print_symtab (tab : symtab) : unit =
) tab;
Printf.printf "----------------------\n"
let print_object_code (objectCodeList : string list) : unit =
List.iter (fun s -> print_endline s) objectCodeList
let run () =
let lineSemantic = (checkLineSemanticOfCode (parser "../../ass1/horner.asm") ) in
print_lineSemantic_list lineSemantic;
@ -54,6 +62,9 @@ let run () =
Printf.printf "Program Length je: %d\n" prlen;
print_intermediate_file_list prehod1;
print_symtab simtab;
let opcodeTab = get_opcode_table () in
let objectCodeList = drugiPrehod lineSemantic simtab opcodeTab prlen in
print_object_code objectCodeList;
()