This commit is contained in:
Jaka Furlan 2025-12-10 16:21:03 +01:00
parent 1bbc80de29
commit 858db4dc0e
4 changed files with 109 additions and 29 deletions

View file

@ -277,13 +277,45 @@ let getMnemType (opcode : mnemonic) (ext : bool) (operand : string list) : mnemo
| _, _ -> failwith (Printf.sprintf "Invalid operands for opcode %s: %d operands"
(string_of_mnemonic opcode) (List.length operand))
let getLen (mnem : mnemonic) (ext : bool) (mnemType : mnemonic_type) : int =
42 (*TODO*)
let getLen (mnemType : mnemonic_type) (mnem : mnemonic) : int =
match mnemType with
(* ----------- directives with no memory ----------- *)
| MnemonicD
| MnemonicDn _
| COMMENT -> 0
(* ----------- instruction formats ----------- *)
| MnemonicF1 -> 1
| MnemonicF2n _
| MnemonicF2r _
| MnemonicF2rn _
| MnemonicF2rr _ -> 2
| MnemonicF3
| MnemonicF3m _ -> 3
| MnemonicF4m _ -> 4
(* ----------- storage directives ----------- *)
| MnemonicSn n ->
begin
match mnem with
| RESB -> n
| RESW -> 3*n
| _ -> failwith "Narobe mnemonic glede na mnemType" (* RESB *)
end
| MnemonicSd _ ->
begin
match mnem with
| BYTE -> 1
| WORD -> 3
| _ -> failwith "Narobe mnemoic glede na mnemType"
end
let checkLineSemantic (line : line) : lineSemantic =
let mnem, ext = getMnem line.opcode in
let mnemType = getMnemType mnem ext line.operand in
let dolzina = getLen mnem ext mnemType in
let dolzina = getLen mnemType mnem in
{line_no = line.line_no; label = line.label; ext = ext; opcode = mnem; mnem = mnemType; comment = line.comment; len = dolzina; loc = line.loc}
let checkLineSemanticOfCode (code : line list) : lineSemantic list =