Define Mpm Object file format V2
With Z380 CPU code generation support, new expression types are necessary to support 8/16/24 bit PC-relative expressions, and overall 16, 24bit and 32bit signed expressions, all these in LSB formats.
First of all, refactor all core object file functionality into separate objfile.c source code, for easier API structure and overview. Update makefiles and various include files accordingly.
For future CPU compatibility, also implement all current expression types for (new) MSB format. NB: The object file only defines the expression type - the actual (result) constant is written by Mpm internally to memory (and as binary stream to object file) according to expression type.
For backward compatibility with Mpm V1 format, preserve existing expression types. By convention, all Least Significant Byte (LSB) format types are in Upper Case. All Most Significant Byte (MSB)-format types will use the lower-case equivalent, so it is easy to identify the core expression type.
Extend the object file format validation in ObjFileOpen() to accept both V1 and V2 as valid watermarks (V2 is able to read V1 object file format by default).
The following table contains v1.x and V2.0 expression types definitions:
| Mpm Version | Expression Type ID | Comments |
|---|---|---|
| 1.x | 'U' | Expression returns an 8bit constant in allowed range [-128; 255] ('U' = "Unsigned") |
| 2.x | 'J' | Expression returns a signed 8bit PC-relative constant in allowed range [-126; 129] ('J' = "Jump relative") |
| 1.x | 'S' | Expression returns a signed 8bit constant in allowed range [-128; 127] ('S' = "Signed") |
| 1.x | 'C' | Expression returns a 16bit LSB-format constant in allowed range [-32768; 65535] ('C' = "Constant") |
| 2.x | 'c' | Expression returns a 16bit MSB-format constant in allowed range [-32768; 65535] ('c' = "Constant") |
| 2.x | 'P' | Expression returns a signed 16bit LSB-format PC-relative constant in allowed range [–32765; 32770] ('P' = "PC relative") |
| 2.x | 'p' | Expression returns a signed 16bit MSB-format PC-relative constant in allowed range [–32765; 32770] ('P' = "PC relative") |
| 2.x | 'W' | Expression returns a signed 16bit LSB-format constant in allowed range [–32768; 32767] ('W' = "Word") |
| 2.x | 'w' | Expression returns a signed 16bit MSB-format constant in allowed range [–32768; 32767] |
| 2.x | 'Q' | Expression returns a signed 24bit LSB-format PC-relative constant in allowed range [–8388604; +8388611] ('Q' is related to 'P') |
| 2.x | 'q' | Expression returns a signed 24bit MSB-format PC-relative constant in allowed range [–8388604; +8388611] |
| 2.x | 'I' | Expression returns a signed 24bit LSB-format constant in allowed range [−8388608; +8388607] ('I' = "Integer") |
| 2.x | 'i' | Expression returns a signed 24bit MSB-format constant in allowed range [−8388608; +8388607] |
| 1.x | 'L' | Expression returns a unsigned 32bit LSB-format constant in allowed range [0; 4294967295] ('L' = "Long") |
| 2.x | 'l' | Expression returns a unsigned 32bit MSB-format constant in allowed range [0; 4294967295] ('l' = "Long") |
| 2.x | 'u' | Expression returns a signed 32bit LSB-format constant in allowed range [-2147483648; 2147483647] |
| 2.x | 'v' | Expression returns a signed 32bit MSB-format constant in allowed range [-2147483648; 2147483647] |