(*tukaj je vse povezano s prvim prehodom zbirnika*)
open SemanticAnalyzer

let startAddr = ref 0
let locctr = ref 0

let prviPrehod (code : lineSemantic list) =
  let prviUkaz, ostaliUkazi = 
    match code with
    | [] -> failwith "empty code"
    | x :: xs -> x, xs
  in

  (*if Opcode == start then*)
  if prviUkaz.opcode = START then
    let stAdr = get_string_from_mnemType prviUkaz.mnem in
    let stAdr = match stAdr with | Some s -> s | None -> "0" in
    startAddr := (int_of_string stAdr);
    locctr := !startAddr;
    (*TODO write line to intermediate file*)
  else 
    (*initialize locctr to 0*)
    locctr := 0
  (*while opcode != END loop*)
  let rec loop ostaliUkazi = 
    match ostaliUkazi with
    | [] -> () (*smo konec*)
    | x :: _s when x.opcode = END -> () (*konec while loopa*)
    | x :: xs -> match x.opcode with
      | COMMENT -> loop xs (*if this is a comment line*)
      | _ ->
        (*if there is a symmbol in label field*)
        match x.label with
        | None -> ()
        | Some s -> () (*search simtab for s ...*)
        ;
        (*search opcode -> smo ze naredili v semanticni analizi, tu bomo le ustrezno povečali locctr*)
        locctr := !locctr + x.len  
