two pass encoding and resizing references #22

Merged
omicron merged 6 commits from encoding_start into main 2025-04-24 13:05:47 +00:00

6 Commits

Author SHA1 Message Date
7cefc3564d Implement one immediate label reference operand
All checks were successful
Validate the build / validate-build (push) Successful in 43s
Also adds opcode data for jmp and call
2025-04-24 14:45:57 +02:00
c848995ad6 Implement two pass encoding
First pass:
 - collect information for numbers, registers and which instructions
   contain label references
 - encode all instructions that don't contain label references
 - Set (temporary) addresses for each instruction

Second pass:
 - Collect information about label references (address, offset, size)
 - encode all instructions that contain label references
 - Update (if necessary) addresses for each instruction

 The second pass is iterated 10 times or until no instructions change
 size, whichever comes first.
2025-04-24 14:45:46 +02:00
5272fdb227 Add more values to the ast to facilitate encoding
- Add a instruction value that contains the encoding, the address and a
  flag to indicate if this instruction contains label references
- Add label value that contains an address
- Add reference value that contains offset, an absolute address and an
  operand size
- define types for all value options in the union
- define accessor functions for all the values in the union
2025-04-23 15:57:04 +02:00
0acc3f27f3 Update symbols tests for new API 2025-04-23 15:56:46 +02:00
9c6b69e187 Symbol table now keeps track of label statements
Before it kept track of a more specific node that referenced the symbol
in some way. Now it will only keep track of the actual label defining
statements. This is done to facilitate encoding. The encoder can now go
from a symbol name to the statement that defines the symbol.

Restructure the encoder to deal with this and pass the correct statement
to the symbol update function.
2025-04-18 14:00:08 +02:00
530e3fb423 Fix parse_memory_expression to use parse_label_reference
All checks were successful
Validate the build / validate-build (push) Successful in 37s
2025-04-17 23:28:44 +02:00