|
| 1 | +### **Changelog: rev 2.0** |
| 2 | + |
| 3 | +This release introduces a critical stability fix for the compiler and expands the supported `amd64` instruction set. The revision is updated from `1.0` to `2.0` to reflect these significant improvements. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +### **Bug Fixes** |
| 8 | + |
| 9 | +* **Compiler: Resolved a critical null reference error during instruction parsing.** |
| 10 | + |
| 11 | + A recurring internal system error that caused an `Unhandled Rejection` has been fixed. This error occurred when the compiler's parser attempted to process instructions that have no operands. |
| 12 | + |
| 13 | + **Symptom:** The compiler would crash with the following error message, preventing the assembly of valid code that included operand-less instructions. |
| 14 | + ``` |
| 15 | + ✘ Unhandled Rejection, Reason: Cannot read properties of undefined (reading 'type') |
| 16 | + ``` |
| 17 | + |
| 18 | + **Root Cause:** The `zcc_build_generic_instruction` method directly accessed `ast[0].type` without first verifying that the `ast[0]` element existed. For instructions without operands, this `ast[0]` was `undefined`, leading to a `TypeError` and a compiler crash. |
| 19 | + |
| 20 | + **Solution:** The code has been patched to use optional chaining (`?.`). The condition is now `ast[0]?.type`, which safely checks for the existence of `ast[0]` and its `type` property before attempting to access it. This ensures that operand-less instructions are handled gracefully by the parser. |
| 21 | + |
| 22 | + **Before:** |
| 23 | + ```javascript |
| 24 | + static zcc_build_generic_instruction(ast) { |
| 25 | + if (ast[0].type == TypeOfAtomicExpression.ARGUMENTS) { // Crashes if ast[0] is undefined |
| 26 | + return ast[0].body.values; |
| 27 | + } |
| 28 | + return ast; |
| 29 | + } |
| 30 | + ``` |
| 31 | + |
| 32 | + **After (Fix Implemented):** |
| 33 | + ```javascript |
| 34 | + static zcc_build_generic_instruction(ast) { |
| 35 | + if (ast[0]?.type && ast[0].type == TypeOfAtomicExpression.ARGUMENTS) { // Safely checks for existence |
| 36 | + return ast[0].body.values; |
| 37 | + } |
| 38 | + return ast; |
| 39 | + } |
| 40 | + ``` |
| 41 | + |
| 42 | +### **New Features** |
| 43 | + |
| 44 | +* **Instruction Set: Added support for common `amd64` instructions without operands.** |
| 45 | + |
| 46 | + To enhance low-level programming capabilities, the instruction set has been updated to include several fundamental `amd64` instructions that do not take any operands. |
| 47 | + |
| 48 | + The following instructions are now fully supported: |
| 49 | + * `nop`: No Operation |
| 50 | + * `fwait`: Check pending unmasked floating-point exceptions |
| 51 | + * `pushf`: Push rFLAGS Register onto the Stack |
| 52 | + * `popf`: Pop Stack into rFLAGS Register |
| 53 | + * `sahf`: Store AH into Flags |
| 54 | + * `lahf`: Load Status Flags into AH Register |
| 55 | + |
| 56 | + **Implementation:** These instructions have been mapped within the compiler's `instructionSet`, allowing the assembler to correctly recognize and encode them. |
| 57 | + |
| 58 | +### **Developer Impact** |
| 59 | + |
| 60 | +Developers can now write code utilizing these common, operand-less instructions without encountering a compiler crash. This fix removes a significant blocker and enables more flexible and direct low-level code generation. |
| 61 | + |
0 commit comments