diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index dcec5c5..f308218 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -24,9 +24,10 @@

{{ site.description | escape }}

diff --git a/docs/building.md b/docs/building.md index 4b8f78d..c632cdb 100644 --- a/docs/building.md +++ b/docs/building.md @@ -49,7 +49,7 @@ The build fails if any sample fails. Generated sample executables go to compiled without launching them, so MessageBox samples require no interaction. The validator supplies the repository's `include` directory to the managed compiler with `-I`. Tests copy the shared headers beside their compiler output. -See [Using included files](Zero-Assembly-Include-Files.md) for syntax and search order. +See [Using included files](zasm/ZASM-Include-Files.md) for syntax and search order. After building the solution, run the validator separately with: diff --git a/docs/designs/ZSRC-v0.3-POC-Console.md b/docs/designs/ZSRC-v0.3-POC-Console.md index a933868..0de6340 100644 --- a/docs/designs/ZSRC-v0.3-POC-Console.md +++ b/docs/designs/ZSRC-v0.3-POC-Console.md @@ -2,7 +2,7 @@ > **Coming Soon: higher-level Zero.** This page explores proposed `.zsrc`, `.zero` > syntax; it is not a runnable example for the current compiler. -> See the [documentation home](../index.md) and [working ZASM examples](../zasm-examples.md). +> See the [documentation home](../index.md) and [working ZASM examples](../zasm/ZASM-Examples.md). In the next generation of Zero, we are re-aligning with the original design specifications and proof-of-concept. diff --git a/docs/index.md b/docs/index.md index 9f3a6f7..f4b9d77 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,15 +8,46 @@ title: Zero Compiler Zero is a compiler project for the Zero programming language and **Zero Assembly (ZASM)**. ZASM is the working assembly language today: write x86 instructions, define data, share headers, call Windows DLL functions, or use Linux syscalls. -The higher-level Zero language is under design; see [Coming Soon](#coming-soon). + +![](images/zero-logo.png) + +> Higher-level Zero language (`.zsrc`) is under redesign.\ +> See, [Coming Soon](#coming-soon). [Download Zero](https://github.com/SuessLabs/ZeroCompiler/releases/latest) · [Getting started](#getting-started-with-zasm) · -[Language reference](zasm-reference.md) · -[Examples](zasm-examples.md) · +[Language reference](zasm/ZASM-Reference.md) · +[Mnemonic support](zasm/ZASM-Mnemonics.md) · +[Examples](zasm/ZASM-Examples.md) · [Debugger](debugger/index.md) · [Source code](https://github.com/SuessLabs/ZeroCompiler) +## About + +The Zero programming language and compiler project (_AKA: Null Compiler_). **Zero** is a simple, fast, and efficient programming language for the x86-64 architecture. + +The compiler generates Windows x86 PE32 console executables (including programs +that create Windows GUI controls) and static Linux x86-64 ELF64 executables using +syscalls. Shared-library ELF linking, DLL output, additional architectures, macOS, +and STM32 remain future work. See [Linux x86-64 support](docs/linux64.md). + +## Zero Language Suite + +* **Zero** - _Zero Assembly and command line compiler tooling (Zero.Cli)_ +* **Zero.Ide** - _Integrated Development Environment with debugger support_ +* **Zero.Dbg** - _Debugger_ + +![ZIDE](images/Zero.IDE-Sample-1.png) + +### File Types + +| Ext | File Type | +|-|-| +| `.zasm` | Zero assembly source file | +| `.zh` | Zero (_assembly_) header file | +| `.zsrc` | Zero language source file (_coming soon_) | +| `.zero`, `.zproj` | Zero project/workspace file (_coming soon_) | + ## What Zero Supports Today | Feature | Current support | @@ -156,7 +187,7 @@ requires the caller to remove the argument with `add esp, 4`. Use `-h` or `--help` for help. `--include` is an alternative to `-I`. A compilation failure prevents `run` from executing an older output file. -See the [reference for command options and error codes](zasm-reference.md#command-line-and-errors). +See the [reference for command options and error codes](zasm/ZASM-Reference.md#command-line-and-errors). ## ZASM Language at a Glance @@ -167,6 +198,9 @@ Semicolons start comments outside quoted strings; they are not required terminat ### Mnemonics +See the [mnemonic support inventory](zasm/ZASM-Mnemonics.md) for categories, +supported operand forms, and missing instructions across Windows PE and Linux ELF. + | Group | Supported mnemonics | Example | | --- | --- | --- | | Data and addresses | `MOV`, `LEA` | `mov eax, 42` | @@ -180,7 +214,7 @@ Semicolons start comments outside quoted strings; they are not required terminat The table above summarizes Windows x86. See [Linux x64 instruction forms](linux64.md#essential-amd64-instructions) for 64-bit registers, memory stores, indirect calls, and `SYSCALL`. -Only the operand forms listed in the [instruction reference](zasm-reference.md#instruction-reference) +Only the operand forms listed in the [instruction reference](zasm/ZASM-Reference.md#instruction-reference) are supported. For example, `mov eax, 42` and `mov eax, [value]` work; register-to-register `MOV` and memory stores are Coming Soon. @@ -197,7 +231,7 @@ register-to-register `MOV` and memory stores are Coming Soon. The current instruction forms use the 32-bit registers **EAX, EBX, ECX, EDX, ESI, EDI, EBP, and ESP**. Other widths and SIMD registers are future work. -See [register roles and memory addressing](zasm-reference.md#registers). +See [register roles and memory addressing](zasm/ZASM-Reference.md#registers). ### Directives, Labels, and Statements @@ -218,15 +252,15 @@ The first emitted byte is the entry point; the name `start` has no special meani Include search order is the current working directory, then each `-I` directory, then `include` beside the compiler. Nested headers use the same search order. -See [Using included files](Zero-Assembly-Include-Files.md) for nested headers, +See [Using included files](zasm/ZASM-Include-Files.md) for nested headers, cycle detection, source locations, and library integration. -Read the [full ZASM reference](zasm-reference.md) for strings, labels, instruction +Read the [full ZASM reference](zasm/ZASM-Reference.md) for strings, labels, instruction forms, imports, calling conventions, and current limitations. ## Examples and Tutorials -Start with the [complete basic examples](zasm-examples.md): console text, integer +Start with the [complete basic examples](zasm/ZASM-Examples.md): console text, integer addition with formatted output, and a Windows MessageBox. Each includes a command and expected behavior. @@ -246,7 +280,7 @@ From the release folder, also try: - [Linux x86-64 and ELF64](linux64.md): compile and run a syscall-based Linux console application. - [Linux header drafts](linux-headers.md): future glibc interfaces and architecture-specific syscall references. - [Header catalog](https://github.com/SuessLabs/ZeroCompiler/blob/master/include/readme.md): all shipped `.zh` files and calling rules. -- [Assembly overview and opcodes](Zero-Assembly-Intro.md): a compact companion to the language reference. +- [Assembly overview and opcodes](zasm/ZASM-Intro.md): a compact companion to the language reference. ## Build and Contribute @@ -259,14 +293,14 @@ validates every ZASM sample, and publishes `zero.exe`, `include`, and - [Project background and original language ideas](readme.md): history and proposed higher-level syntax. - [Future formats and architectures](designs/Future-Formats-and-Targets.md): shared parsing with separate target backends. - [ZSRC console proof of concept](designs/ZSRC-v0.3-POC-Console.md): a future high-level language example. -- [Assembly syntax sandbox](Zero-Assembly-PoC-Sandbox.md): experimental proposals, including directives that are not implemented. +- [Assembly syntax sandbox](zasm/ZASM-vNext-Sandbox.md): experimental proposals, including directives that are not implemented. The reference describes the current compiler. Historical examples and design proposals are labeled separately so they can evolve without implying support today. ## Coming Soon -See the [ZASM feature roadmap](zasm-coming-soon.md) for implemented assembly +See the [ZASM feature roadmap](zasm/ZASM-Coming-Soon.md) for implemented assembly features, proposed key features, and nice-to-have improvements. These are documentation placeholders and development ideas, with no promised release date. @@ -286,5 +320,5 @@ They are not current compiler capabilities. | More tutorials | **Coming Soon:** loops, reusable procedures, stack frames, and a step-by-step controls application. | Contributors can replace these placeholders with tested syntax and examples as -features become available. See the [reference's limitations](zasm-reference.md#current-limitations) +features become available. See the [reference's limitations](zasm/ZASM-Reference.md#current-limitations) before adapting assembly from another assembler. diff --git a/docs/linux-headers.md b/docs/linux-headers.md index cb517b7..737482c 100644 --- a/docs/linux-headers.md +++ b/docs/linux-headers.md @@ -71,4 +71,4 @@ The build ships both platform directories. Windows samples use `using "windows/..."`; `linux64-cli-01-hello.zasm` uses direct syscalls and no libc header. For fuller notes, see the [Linux header README](https://github.com/SuessLabs/ZeroCompiler/blob/master/include/linux/readme.md) -and [ZASM roadmap](zasm-coming-soon.md). +and [ZASM roadmap](zasm/ZASM-Coming-Soon.md). diff --git a/docs/linux64.md b/docs/linux64.md index 7ff71a4..c68da93 100644 --- a/docs/linux64.md +++ b/docs/linux64.md @@ -6,7 +6,7 @@ title: Linux x86-64 and ELF64 # Linux x86-64 and ELF64 [Documentation home](index.md) · [Linux header drafts](linux-headers.md) · -[ZASM reference](zasm-reference.md) +[ZASM reference](zasm/ZASM-Reference.md) · [Mnemonic support](zasm/ZASM-Mnemonics.md#linux-elf-x64) Zero can generate static Linux x86-64 ELF64 executables from Windows or Linux. This first backend uses Linux syscalls directly: no libc, dynamic interpreter, diff --git a/docs/readme.md b/docs/readme.md index 56fe104..b7dff1a 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -2,8 +2,8 @@ > **Background and design notes:** the examples below include proposed syntax > that is not implemented. For working ZASM syntax, start with the -> [documentation home](index.md), [language reference](zasm-reference.md), and -> [basic examples](zasm-examples.md). Higher-level `.zsrc` compilation is Coming Soon. +> [documentation home](index.md), [language reference](zasm/ZASM-Reference.md), and +> [basic examples](zasm/ZASM-Examples.md). Higher-level `.zsrc` compilation is Coming Soon. Welcome to the Zero Compiler diff --git a/docs/tutorial-zasm-concat.md b/docs/tutorial-zasm-concat.md index d0d14fc..2cb4bcb 100644 --- a/docs/tutorial-zasm-concat.md +++ b/docs/tutorial-zasm-concat.md @@ -1,5 +1,8 @@ # Joining strings in Zero Assembly +[Documentation home](index.md) · [Language reference](zasm/ZASM-Reference.md) · +[Mnemonic support](zasm/ZASM-Mnemonics.md) + [win-cli-05-string-concat.zasm](../samples/Windows/win-cli-05-string-concat.zasm) prints two pieces of text, then joins them with a space. Joining strings is called **concatenation**. diff --git a/docs/windows-headers.md b/docs/windows-headers.md index ce9527f..87ad48a 100644 --- a/docs/windows-headers.md +++ b/docs/windows-headers.md @@ -5,8 +5,8 @@ title: Windows API Headers # Windows API Headers -[Documentation home](index.md) · [Include syntax](Zero-Assembly-Include-Files.md) · -[Language reference](zasm-reference.md) +[Documentation home](index.md) · [Include syntax](zasm/ZASM-Include-Files.md) · +[Language reference](zasm/ZASM-Reference.md) ZASM ships curated `.zh` headers for common Windows DLLs. They contain `#IMPORT` declarations, so your program can share library imports instead of repeating them. @@ -133,4 +133,4 @@ export tables without calling any of those APIs. - Manifest/resource support for common-controls version 6 visual styles. These headers supply imports today; they do not implement the language features -listed above. Track those separately in the [ZASM roadmap](zasm-coming-soon.md). +listed above. Track those separately in the [ZASM roadmap](zasm/ZASM-Coming-Soon.md). diff --git a/docs/zasm-coming-soon.md b/docs/zasm/ZASM-Coming-Soon.md similarity index 91% rename from docs/zasm-coming-soon.md rename to docs/zasm/ZASM-Coming-Soon.md index 07058ab..ba74e23 100644 --- a/docs/zasm-coming-soon.md +++ b/docs/zasm/ZASM-Coming-Soon.md @@ -5,8 +5,8 @@ title: ZASM Feature Roadmap # ZASM Feature Roadmap -[Documentation home](index.md) · [Language reference](zasm-reference.md) · -[Basic examples](zasm-examples.md) +[Documentation home](../index.md) · [Language reference](ZASM-Reference.md) · +[Basic examples](ZASM-Examples.md) · [Mnemonic support](ZASM-Mnemonics.md) This page tracks what Zero Assembly can do today and the features to consider next. **Implemented** describes working capabilities. **What's Next** lists @@ -16,13 +16,13 @@ commitments; their syntax and implementation order still need to be decided. ## Implemented -Support applies to the operand forms in the [language reference](zasm-reference.md), +Support applies to the operand forms in the [language reference](ZASM-Reference.md), not every form offered by other x86 assemblers. A mnemonic or register constant in the compiler source does not by itself mean its instruction encoding works. ### Instructions and Registers -- [x] [Linux x86-64 ELF64 backend](linux64.md): static executables, essential 32/64-bit AMD64 encodings, extended registers, RIP-relative addresses, stores, and `SYSCALL`. +- [x] [Linux x86-64 ELF64 backend](../linux64.md): static executables, essential 32/64-bit AMD64 encodings, extended registers, RIP-relative addresses, stores, and `SYSCALL`. - [x] Shared parser with separate architecture encoders and PE/ELF writers; explicit target selection and host compatibility checks. - [x] Windows x86 (32-bit) instruction encoding and PE32 executable output. @@ -56,7 +56,7 @@ emitted byte is the program entry point. - [x] Include search order: working directory, ordered `-I`/`--include` paths, then `include` beside the compiler. - [x] Include-cycle diagnostics, searched-path errors, and original filename/line reporting for included source. - [x] Shipped `windows/console.zh` and `windows/windows.zh` headers. -- [x] [DLL-specific Windows API headers](windows-headers.md) for controls/dialogs, drawing, core OS services, shell, sockets, security, COM, HTTP, and other utilities. +- [x] [DLL-specific Windows API headers](../windows-headers.md) for controls/dialogs, drawing, core OS services, shell, sockets, security, COM, HTTP, and other utilities. - [x] Platform folders: working Windows imports under `include/windows`; draft glibc headers and comment-only syscall references under `include/linux`. - [x] `#IMPORT dll, function[, ...]` declarations and PE import table generation. - [x] Plain imported function names such as `call [puts]`, with backward-compatible and DLL-qualified aliases. @@ -64,8 +64,8 @@ emitted byte is the program entry point. - [x] Native AOT publishing with headers and samples beside the compiler. - [x] Build-time sample compilation, sample discovery in unit tests, and selected Windows runtime checks. -See the [include guide](Zero-Assembly-Include-Files.md), -[build guide](building.md), and [sample guide](https://github.com/SuessLabs/ZeroCompiler/blob/master/samples/readme.md). +See the [include guide](ZASM-Include-Files.md), +[build guide](../building.md), and [sample guide](https://github.com/SuessLabs/ZeroCompiler/blob/master/samples/readme.md). ## What's Next @@ -145,7 +145,7 @@ These ideas can follow the core assembler work or be developed independently. ### More Targets and Executable Formats -[Linux libc drafts](linux-headers.md) are available for planning. Static syscall-only +[Linux libc drafts](../linux-headers.md) are available for planning. Static syscall-only Linux ELF64 output is implemented; shared-library linking remains future work. - [ ] **Windows x64:** PE32+ output and the Windows x64 ABI; essential AMD64 encoding exists for Linux x64. @@ -154,17 +154,17 @@ Linux ELF64 output is implemented; shared-library linking remains future work. - [ ] **Additional platforms:** define supported architecture, format, and ABI combinations before exposing target options. Changing the compiler's own host runtime does not change its generated target. -See [Future formats and architectures](designs/Future-Formats-and-Targets.md) +See [Future formats and architectures](../designs/Future-Formats-and-Targets.md) for the shared-parser design direction. ## Updating This Roadmap When a feature is ready, move it into Implemented, describe its supported forms -in the [reference](zasm-reference.md), and link a working example. A feature can +in the [reference](ZASM-Reference.md), and link a working example. A feature can be partially implemented: state which forms work and leave the remaining forms unchecked. Proposed names such as constants, section directives, and procedure helpers need a syntax decision; this page does not establish their spelling. Higher-level Zero (`.zsrc`) has its own language-design work and is outside this -assembly checklist. The [homepage's Coming Soon section](index.md#coming-soon) +assembly checklist. The [homepage's Coming Soon section](../index.md#coming-soon) also tracks broader language and documentation topics. diff --git a/docs/zasm-examples.md b/docs/zasm/ZASM-Examples.md similarity index 88% rename from docs/zasm-examples.md rename to docs/zasm/ZASM-Examples.md index 1a26ecd..addfc45 100644 --- a/docs/zasm-examples.md +++ b/docs/zasm/ZASM-Examples.md @@ -5,7 +5,8 @@ title: ZASM Basic Examples # ZASM Basic Examples -[Documentation home](index.md) · [Language reference](zasm-reference.md) +[Documentation home](../index.md) · [Language reference](ZASM-Reference.md) · +[Mnemonic support](ZASM-Mnemonics.md) Save each complete program under the suggested filename. Run the commands from the extracted compiler folder, keeping `include` beside the `zero` compiler executable. @@ -115,10 +116,10 @@ console subsystem; this example does not select a separate GUI subsystem. ## Next Steps -- [Include guide](Zero-Assembly-Include-Files.md): put shared source in `.zh` files and use custom `-I` paths. -- [String concatenation tutorial](tutorial-zasm-concat.md): print separate strings, then join them with a space. +- [Include guide](ZASM-Include-Files.md): put shared source in `.zh` files and use custom `-I` paths. +- [String concatenation tutorial](../tutorial-zasm-concat.md): print separate strings, then join them with a space. - [Sample guide](https://github.com/SuessLabs/ZeroCompiler/blob/master/samples/readme.md): explore the full sample collection, including editable Windows controls. -- [Instruction reference](zasm-reference.md#instruction-reference): choose supported operand forms. +- [Instruction reference](ZASM-Reference.md#instruction-reference): choose supported operand forms. ## Coming Soon diff --git a/docs/Zero-Assembly-Include-Files.md b/docs/zasm/ZASM-Include-Files.md similarity index 93% rename from docs/Zero-Assembly-Include-Files.md rename to docs/zasm/ZASM-Include-Files.md index 877c8a4..f1d3986 100644 --- a/docs/Zero-Assembly-Include-Files.md +++ b/docs/zasm/ZASM-Include-Files.md @@ -1,5 +1,13 @@ +--- +layout: default +title: ZASM Include Files +--- + # Zero Assembly (ZASM) - Using Included Files +[Documentation home](../index.md) · [Assembly overview](ZASM-Intro.md) · +[Language reference](ZASM-Reference.md) · [Mnemonic support](ZASM-Mnemonics.md) + Use `using` to share imports, data, and procedures between ZASM files. The compiler expands each header at the directive's position before assembly. @@ -91,13 +99,13 @@ error. Errors inside headers report the header's filename and original line numb Additional DLL-specific headers cover core OS services, windows, GDI drawing, common controls and dialogs, the shell, sockets, registry/security, COM, Automation, path helpers, multimedia, HTTP, and file version resources. -See the [Windows API header guide](windows-headers.md) for the full catalog. +See the [Windows API header guide](../windows-headers.md) for the full catalog. Windows headers now live under `include/windows`; use paths such as `using "windows/console.zh"`. Root-level compatibility copies are not shipped. Draft Linux libc headers live separately under `include/linux` and require future -shared-library linking. Static syscall-only [Linux ELF64 output](linux64.md) is -supported. See [Linux headers](linux-headers.md) for the drafts' status. +shared-library linking. Static syscall-only [Linux ELF64 output](../linux64.md) is +supported. See [Linux headers](../linux-headers.md) for the drafts' status. The headers target the compiler's current Windows x86 output. `puts` and `printf` use cdecl, so remove their arguments from the stack after calls. Windows API diff --git a/docs/Zero-Assembly-Intro.md b/docs/zasm/ZASM-Intro.md similarity index 73% rename from docs/Zero-Assembly-Intro.md rename to docs/zasm/ZASM-Intro.md index 51fc3e5..5a39414 100644 --- a/docs/Zero-Assembly-Intro.md +++ b/docs/zasm/ZASM-Intro.md @@ -1,11 +1,18 @@ +--- +layout: default +title: Zero Assembly Overview +--- + # Zero Assembly Overview -[Documentation home](index.md) · [Full language reference](zasm-reference.md) · -[Basic examples](zasm-examples.md) +[Documentation home](../index.md) · [Full language reference](ZASM-Reference.md) · +[Basic examples](ZASM-Examples.md) · [Mnemonic support](ZASM-Mnemonics.md) -ZASM currently produces Windows x86 PE32 executables. This page summarizes common -encodings; the [instruction reference](zasm-reference.md#instruction-reference) -lists every implemented mnemonic and its operand forms. +ZASM produces Windows x86 PE32 and static Linux x64 ELF64 executables. This page +summarizes selected Windows x86 encodings; the +[instruction reference](ZASM-Reference.md#instruction-reference) describes their +operand forms. See [mnemonic support](ZASM-Mnemonics.md) for both output backends; +Windows PE x64 output is not implemented. ## Selected x86 Encodings @@ -37,7 +44,7 @@ lists every implemented mnemonic and its operand forms. This is a selected encoding table; `AND`, `OR`, `XOR`, and `TEST` are also implemented. The current assembler uses **EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP**. -See [registers](zasm-reference.md#registers) for their roles. +See [registers](ZASM-Reference.md#registers) for their roles. ## Data and Other Directives @@ -57,11 +64,12 @@ parse string, floating-point, or symbol initializers. Data is emitted into the read-only code section. The first emitted byte is the entry point; use a jump to skip inline data at the beginning of a program. -See [directives](zasm-reference.md#assembler-directives), -[labels](zasm-reference.md#labels), and [headers](Zero-Assembly-Include-Files.md). +See [directives](ZASM-Reference.md#assembler-directives), +[labels](ZASM-Reference.md#labels), and [headers](ZASM-Include-Files.md). ## Coming Soon -**Coming Soon:** `DQ`, more instruction widths, writable sections, constants, -macros, and additional targets. These are not currently supported syntax. -See the [documentation roadmap](index.md#coming-soon). +**Coming Soon for Windows x86:** `DQ`, more instruction widths, writable sections, +constants, macros, and additional targets. Linux x64 already supports numeric +`DQ` and essential 64-bit instruction forms. +See the [documentation roadmap](../index.md#coming-soon). diff --git a/docs/zasm/ZASM-Mnemonics.md b/docs/zasm/ZASM-Mnemonics.md new file mode 100644 index 0000000..1ce387f --- /dev/null +++ b/docs/zasm/ZASM-Mnemonics.md @@ -0,0 +1,475 @@ +--- +layout: default +title: ZASM Mnemonic Support +--- + +# ZASM Mnemonic Support + +[Documentation home](../index.md) · [Assembly overview](ZASM-Intro.md) · +[Language reference](ZASM-Reference.md) · [Examples](ZASM-Examples.md) · +[Include files](ZASM-Include-Files.md) · [Roadmap](ZASM-Coming-Soon.md) + +## Overview + +A mnemonic is the name of a CPU instruction, such as `MOV`, `ADD`, or `CALL`. +The category describes what the instruction is used for. Support depends on the +output target and operand form, rather than the architecture running the compiler. +A Windows x64 compiler host can generate Windows x86 programs or Linux x64 +programs; it does not imply Windows x64 output support. + +| Output target | Format | Current status | +| --- | --- | --- | +| `windows-x86` | Windows PE32, 32-bit x86 | Implemented for the forms below; the default target. | +| `windows-x64` | Windows PE32+, 64-bit x86 | Entire target is unimplemented. No mnemonic currently produces Windows x64 output. | +| `linux-x64` | Static Linux ELF64, 64-bit x86 | Implemented for the forms below. | + +The supported tables enumerate the current encoder cases. The unsupported tables +list the named integer/string backlog discussed in the roadmap, including missing +constants already present in the source. They are **not an exhaustive inventory +of the entire x86 ISA**. Additional aliases, system instructions, and floating-point +or vector extensions require further work. An unlisted instruction is not supported +unless it appears in a supported table. + +Constants in `Mnemonic.cs`, syntax highlighting, and entries in `OpCodes.cs` do not +establish encoder support. The active encoders do not use the `OpCodes.cs` lookup. +`JZ8` and `JNZ8` are ZASM spellings for explicit short encodings, not additional CPU +instructions. `JE` and `JNE` aliases are currently missing even though `JZ` and `JNZ` +work. + +## Windows PE x86/x64 + +### Supported on Windows PE32 x86 + +**Every row in this table is unavailable for Windows PE x64 because that target +has not been implemented.** `r32` means EAX, EBX, ECX, EDX, ESI, EDI, EBP, or ESP. +See the [operand reference](ZASM-Reference.md#operands) and +[memory addressing](ZASM-Reference.md#memory-addressing) for syntax and limits. + +| Mnemonic | Category | Used for | Supported PE32 x86 operands | +| --- | --- | --- | --- | +| `MOV` | Data movement | Copy a value or load memory. | r32, immediate/address; r32, [memory]. | +| `LEA` | Addresses | Calculate an address without reading its contents. | r32, [memory]. | +| `PUSH` | Stack | Push a value onto the stack. | r32 or immediate/address. | +| `POP` | Stack | Pop a stack value into a register. | r32. | +| `ADD` | Arithmetic | Add the source to the destination. | r32 destination; r32 or immediate/address source. | +| `SUB` | Arithmetic | Subtract the source from the destination. | r32 destination; r32 or immediate/address source. | +| `AND` | Bitwise | Perform a bitwise AND. | r32 destination; r32 or immediate/address source. | +| `OR` | Bitwise | Perform a bitwise OR. | r32 destination; r32 or immediate/address source. | +| `XOR` | Bitwise | Perform a bitwise exclusive OR. | r32 destination; r32 or immediate/address source. | +| `CMP` | Comparison | Set flags from subtraction without storing the result. | r32 destination; r32 or immediate/address source. | +| `TEST` | Comparison | Set flags from AND without storing the result. | r32 destination; r32 or immediate/address source. | +| `JMP` | Control flow | Jump unconditionally. | Label. | +| `JZ` | Conditional branch | Jump if zero/equal. | Label; near rel32. | +| `JNZ` | Conditional branch | Jump if nonzero/not equal. | Label; near rel32. | +| `JZ8` | Conditional branch | Explicit short jump if zero/equal. | Label; range-checked rel8. | +| `JNZ8` | Conditional branch | Explicit short jump if nonzero/not equal. | Label; range-checked rel8. | +| `CALL` | Procedures | Save a return address and call a procedure. | Label or [absolute pointer location], including DLL import slots. | +| `RET` | Procedures | Return to the caller, optionally discarding stack bytes. | No operand or unsigned imm16 cleanup count. | +| `NOP` | Miscellaneous | Perform no operation. | No operands. | +| `INT` | Interrupts | Encode a software interrupt; execution depends on the OS. | imm8. | + +### Unsupported on Windows PE x86/x64 + +`Missing` means there is no working mnemonic encoder case. `Target unavailable` +means Windows x64 compilation is rejected before instruction encoding; a future +PE64 backend may reuse parts of the existing AMD64 encoder. + +| Mnemonic | Category | Used for | PE32 x86 | PE32+ x64 | +| --- | --- | --- | --- | --- | +| `ADC` | Carry arithmetic | Add with carry. | Missing | Target unavailable | +| `SBB` | Carry arithmetic | Subtract with borrow. | Missing | Target unavailable | +| `INC` | Arithmetic | Increment by one. | Missing | Target unavailable | +| `DEC` | Arithmetic | Decrement by one. | Missing | Target unavailable | +| `NEG` | Arithmetic | Negate a signed value. | Missing | Target unavailable | +| `MUL` | Arithmetic | Unsigned multiplication. | Missing | Target unavailable | +| `IMUL` | Arithmetic | Signed multiplication. | Missing | Target unavailable | +| `DIV` | Arithmetic | Unsigned division. | Missing | Target unavailable | +| `IDIV` | Arithmetic | Signed division. | Missing | Target unavailable | +| `MOVSX` | Data movement | Copy with sign extension. | Missing | Target unavailable | +| `MOVZX` | Data movement | Copy with zero extension. | Missing | Target unavailable | +| `XCHG` | Data movement | Exchange two values. | Missing | Target unavailable | +| `CBW` | Sign extension | Sign-extend AL into AX. | Missing | Target unavailable | +| `CWDE` | Sign extension | Sign-extend AX into EAX. | Missing | Target unavailable | +| `CWD` | Sign extension | Sign-extend AX into DX:AX. | Missing | Target unavailable | +| `CDQ` | Sign extension | Sign-extend EAX into EDX:EAX. | Missing | Target unavailable | +| `NOT` | Bitwise | Invert every bit. | Missing | Target unavailable | +| `BSWAP` | Bitwise | Reverse the byte order of a register. | Missing | Target unavailable | +| `SHL` | Shifts | Logical left shift. | Missing | Target unavailable | +| `SAL` | Shifts | Arithmetic left shift; alias of SHL. | Missing | Target unavailable | +| `SHR` | Shifts | Logical right shift. | Missing | Target unavailable | +| `SAR` | Shifts | Arithmetic right shift. | Missing | Target unavailable | +| `SHLD` | Shifts | Double-precision left shift. | Missing | Target unavailable | +| `SHRD` | Shifts | Double-precision right shift. | Missing | Target unavailable | +| `ROL` | Rotates | Rotate left. | Missing | Target unavailable | +| `ROR` | Rotates | Rotate right. | Missing | Target unavailable | +| `RCL` | Rotates | Rotate left through carry. | Missing | Target unavailable | +| `RCR` | Rotates | Rotate right through carry. | Missing | Target unavailable | +| `JE` | Conditional branches | Jump on equal/zero. | Missing | Target unavailable | +| `JNE` | Conditional branches | Jump on not equal/nonzero. | Missing | Target unavailable | +| `JG` | Conditional branches | Jump on greater, signed. | Missing | Target unavailable | +| `JGE` | Conditional branches | Jump on greater or equal, signed. | Missing | Target unavailable | +| `JL` | Conditional branches | Jump on less, signed. | Missing | Target unavailable | +| `JLE` | Conditional branches | Jump on less or equal, signed. | Missing | Target unavailable | +| `JA` | Conditional branches | Jump on above, unsigned. | Missing | Target unavailable | +| `JAE` | Conditional branches | Jump on above or equal, unsigned. | Missing | Target unavailable | +| `JB` | Conditional branches | Jump on below, unsigned. | Missing | Target unavailable | +| `JBE` | Conditional branches | Jump on below or equal, unsigned. | Missing | Target unavailable | +| `JO` | Conditional branches | Jump on overflow. | Missing | Target unavailable | +| `JNO` | Conditional branches | Jump on no overflow. | Missing | Target unavailable | +| `JS` | Conditional branches | Jump on negative sign. | Missing | Target unavailable | +| `JNS` | Conditional branches | Jump on nonnegative sign. | Missing | Target unavailable | +| `JP` | Conditional branches | Jump on even parity. | Missing | Target unavailable | +| `JNP` | Conditional branches | Jump on odd parity. | Missing | Target unavailable | +| `JC` | Conditional branches | Jump if carry is set; alias of JB. | Missing | Target unavailable | +| `JNC` | Conditional branches | Jump if carry is clear; alias of JAE. | Missing | Target unavailable | +| `SETE` | Conditional results | Store 1 on equal/zero; otherwise store 0. | Missing | Target unavailable | +| `SETNE` | Conditional results | Store 1 on not equal/nonzero; otherwise store 0. | Missing | Target unavailable | +| `SETG` | Conditional results | Store 1 on greater, signed; otherwise store 0. | Missing | Target unavailable | +| `SETGE` | Conditional results | Store 1 on greater or equal, signed; otherwise store 0. | Missing | Target unavailable | +| `SETL` | Conditional results | Store 1 on less, signed; otherwise store 0. | Missing | Target unavailable | +| `SETLE` | Conditional results | Store 1 on less or equal, signed; otherwise store 0. | Missing | Target unavailable | +| `SETA` | Conditional results | Store 1 on above, unsigned; otherwise store 0. | Missing | Target unavailable | +| `SETAE` | Conditional results | Store 1 on above or equal, unsigned; otherwise store 0. | Missing | Target unavailable | +| `SETB` | Conditional results | Store 1 on below, unsigned; otherwise store 0. | Missing | Target unavailable | +| `SETBE` | Conditional results | Store 1 on below or equal, unsigned; otherwise store 0. | Missing | Target unavailable | +| `SETO` | Conditional results | Store 1 on overflow; otherwise store 0. | Missing | Target unavailable | +| `SETNO` | Conditional results | Store 1 on no overflow; otherwise store 0. | Missing | Target unavailable | +| `SETS` | Conditional results | Store 1 on negative sign; otherwise store 0. | Missing | Target unavailable | +| `SETNS` | Conditional results | Store 1 on nonnegative sign; otherwise store 0. | Missing | Target unavailable | +| `SETP` | Conditional results | Store 1 on even parity; otherwise store 0. | Missing | Target unavailable | +| `SETNP` | Conditional results | Store 1 on odd parity; otherwise store 0. | Missing | Target unavailable | +| `CMOVE` | Conditional moves | Copy on equal/zero. | Missing | Target unavailable | +| `CMOVNE` | Conditional moves | Copy on not equal/nonzero. | Missing | Target unavailable | +| `CMOVG` | Conditional moves | Copy on greater, signed. | Missing | Target unavailable | +| `CMOVGE` | Conditional moves | Copy on greater or equal, signed. | Missing | Target unavailable | +| `CMOVL` | Conditional moves | Copy on less, signed. | Missing | Target unavailable | +| `CMOVLE` | Conditional moves | Copy on less or equal, signed. | Missing | Target unavailable | +| `CMOVA` | Conditional moves | Copy on above, unsigned. | Missing | Target unavailable | +| `CMOVAE` | Conditional moves | Copy on above or equal, unsigned. | Missing | Target unavailable | +| `CMOVB` | Conditional moves | Copy on below, unsigned. | Missing | Target unavailable | +| `CMOVBE` | Conditional moves | Copy on below or equal, unsigned. | Missing | Target unavailable | +| `CMOVO` | Conditional moves | Copy on overflow. | Missing | Target unavailable | +| `CMOVNO` | Conditional moves | Copy on no overflow. | Missing | Target unavailable | +| `CMOVS` | Conditional moves | Copy on negative sign. | Missing | Target unavailable | +| `CMOVNS` | Conditional moves | Copy on nonnegative sign. | Missing | Target unavailable | +| `CMOVP` | Conditional moves | Copy on even parity. | Missing | Target unavailable | +| `CMOVNP` | Conditional moves | Copy on odd parity. | Missing | Target unavailable | +| `LOOP` | Loops | Decrement the counter and jump if nonzero. | Missing | Target unavailable | +| `LOOPE` | Loops | Loop while the counter is nonzero and ZF is set. | Missing | Target unavailable | +| `LOOPZ` | Loops | Alias of LOOPE. | Missing | Target unavailable | +| `LOOPNE` | Loops | Loop while the counter is nonzero and ZF is clear. | Missing | Target unavailable | +| `LOOPNZ` | Loops | Alias of LOOPNE. | Missing | Target unavailable | +| `JECXZ` | Loops | Jump if ECX is zero. | Missing | Target unavailable | +| `BT` | Bit operations | Copy a selected bit to the carry flag. | Missing | Target unavailable | +| `BTS` | Bit operations | Test and set a bit. | Missing | Target unavailable | +| `BTR` | Bit operations | Test and reset a bit. | Missing | Target unavailable | +| `BTC` | Bit operations | Test and complement a bit. | Missing | Target unavailable | +| `BSF` | Bit operations | Find the lowest set bit. | Missing | Target unavailable | +| `BSR` | Bit operations | Find the highest set bit. | Missing | Target unavailable | +| `POPCNT` | Bit operations | Count set bits. | Missing | Target unavailable | +| `ENTER` | Stack frames | Create a stack frame. | Missing | Target unavailable | +| `LEAVE` | Stack frames | Release a stack frame. | Missing | Target unavailable | +| `PUSHF` | Flags | Push flags, with operand-size rules. | Missing | Target unavailable | +| `POPF` | Flags | Restore flags, subject to operand-size and privilege rules. | Missing | Target unavailable | +| `CLC` | Flags | Clear carry. | Missing | Target unavailable | +| `STC` | Flags | Set carry. | Missing | Target unavailable | +| `CMC` | Flags | Complement carry. | Missing | Target unavailable | +| `CLD` | Flags | Clear the string direction flag. | Missing | Target unavailable | +| `STD` | Flags | Set the string direction flag. | Missing | Target unavailable | +| `LAHF` | Flags | Load status flags into AH. | Missing | Target unavailable | +| `SAHF` | Flags | Store AH into status flags. | Missing | Target unavailable | +| `MOVSB` | Strings | Copy a string element. Element width: 8 bits. | Missing | Target unavailable | +| `MOVSW` | Strings | Copy a string element. Element width: 16 bits. | Missing | Target unavailable | +| `MOVSD` | Strings | Copy a string element. Element width: 32 bits. | Missing | Target unavailable | +| `CMPSB` | Strings | Compare string elements. Element width: 8 bits. | Missing | Target unavailable | +| `CMPSW` | Strings | Compare string elements. Element width: 16 bits. | Missing | Target unavailable | +| `CMPSD` | Strings | Compare string elements. Element width: 32 bits. | Missing | Target unavailable | +| `LODSB` | Strings | Load a string element into the accumulator. Element width: 8 bits. | Missing | Target unavailable | +| `LODSW` | Strings | Load a string element into the accumulator. Element width: 16 bits. | Missing | Target unavailable | +| `LODSD` | Strings | Load a string element into the accumulator. Element width: 32 bits. | Missing | Target unavailable | +| `STOSB` | Strings | Store the accumulator into a string element. Element width: 8 bits. | Missing | Target unavailable | +| `STOSW` | Strings | Store the accumulator into a string element. Element width: 16 bits. | Missing | Target unavailable | +| `STOSD` | Strings | Store the accumulator into a string element. Element width: 32 bits. | Missing | Target unavailable | +| `SCASB` | Strings | Compare the accumulator with a string element. Element width: 8 bits. | Missing | Target unavailable | +| `SCASW` | Strings | Compare the accumulator with a string element. Element width: 16 bits. | Missing | Target unavailable | +| `SCASD` | Strings | Compare the accumulator with a string element. Element width: 32 bits. | Missing | Target unavailable | +| `JCXZ` | Loops | Jump if CX is zero. | Missing | Target unavailable | +| `PUSHA` | Stack | Push the 16-bit general-purpose registers. | Missing | Target unavailable | +| `PUSHAD` | Stack | Push the 32-bit general-purpose registers. | Missing | Target unavailable | +| `POPA` | Stack | Pop the 16-bit general-purpose registers. | Missing | Target unavailable | +| `POPAD` | Stack | Pop the 32-bit general-purpose registers. | Missing | Target unavailable | +| `JRCXZ` | Loops | Jump if RCX is zero. | Not a 32-bit form | Target unavailable | +| `MOVSXD` | Sign extension | Sign-extend a doubleword into a 64-bit register. | Not a 32-bit form | Target unavailable | +| `CDQE` | Sign extension | Sign-extend EAX into RAX. | Not a 32-bit form | Target unavailable | +| `CQO` | Sign extension | Sign-extend RAX into RDX:RAX. | Not a 32-bit form | Target unavailable | +| `PUSHFQ` | Flags | Push 64-bit flags. | Not a 32-bit form | Target unavailable | +| `POPFQ` | Flags | Restore 64-bit flags, subject to OS restrictions. | Not a 32-bit form | Target unavailable | +| `MOVSQ` | Strings | Copy 64-bit string elements. | Not a 32-bit form | Target unavailable | +| `CMPSQ` | Strings | Compare 64-bit string elements. | Not a 32-bit form | Target unavailable | +| `LODSQ` | Strings | Load 64-bit string elements. | Not a 32-bit form | Target unavailable | +| `STOSQ` | Strings | Store 64-bit string elements. | Not a 32-bit form | Target unavailable | +| `SCASQ` | Strings | Scan 64-bit string elements. | Not a 32-bit form | Target unavailable | +| `PUSHFD` | Flags | Push 32-bit flags. | Missing | Not a 64-bit form; target unavailable | +| `POPFD` | Flags | Restore 32-bit flags. | Missing | Not a 64-bit form; target unavailable | +| `SYSCALL` | System calls | Enter the OS system-call interface. | Not implemented by this backend | Target unavailable | + +`SYSCALL` support currently belongs to Linux ELF64. Ordinary Windows programs use +imported APIs, such as `call [ExitProcess]`; a raw system-call encoding alone would +not provide a Windows calling convention or stable service numbers. + +### Missing Windows x86 operand forms + +A supported mnemonic does not mean all x86 forms are implemented. + +| Area | Implemented today | Still missing | +| --- | --- | --- | +| `MOV` | Register destination with immediate/address or memory source. | Register copies, memory stores, size-qualified immediate stores, and 8/16-bit forms. | +| Arithmetic, bitwise, `CMP`, `TEST` | r32 destination with register or immediate/address source. | Memory source/destination forms and 8/16-bit forms. | +| `CALL` | Label or an absolute pointer location, including import slots. | Register-indirect calls and base/displacement memory-indirect calls. | +| `JMP` | Direct label. | Register-indirect and memory-indirect jumps. | +| `PUSH`, `POP` | Register stack operations; `PUSH` also accepts immediate/address. | Memory operands and additional operand widths. | +| Addresses | Supported absolute/base/displacement loads and `LEA`. | General scaled-index/base-plus-index forms and broader displacement expressions. | + +## Linux ELF x64 + +### Supported on Linux ELF64 x64 + +Use `#TARGET linux-x64` or `--target linux-x64`. This is static Linux ELF output, +not Windows PE output or dynamic linking. See the [Linux x64 guide](../linux64.md). +`r32` and `r64` include the extended R8D-R15D and R8-R15 registers. Widths must +match. Arithmetic/test immediates for 64-bit destinations are sign-extended imm32. + +| Mnemonic | Category | Used for | Supported ELF64 x64 operands | +| --- | --- | --- | --- | +| `MOV` | Data movement | Copy a value or load memory. | Matching r32/r64 register copies; register/immediate; loads and register-to-memory stores. | +| `LEA` | Addresses | Calculate an address without reading its contents. | r32/r64, [memory], including RIP-relative symbols. | +| `PUSH` | Stack | Push a value onto the stack. | r64 or sign-extended imm32. | +| `POP` | Stack | Pop a stack value into a register. | r64. | +| `ADD` | Arithmetic | Add the source to the destination. | r32/r64 destination; matching register or immediate source. | +| `SUB` | Arithmetic | Subtract the source from the destination. | r32/r64 destination; matching register or immediate source. | +| `AND` | Bitwise | Perform a bitwise AND. | r32/r64 destination; matching register or immediate source. | +| `OR` | Bitwise | Perform a bitwise OR. | r32/r64 destination; matching register or immediate source. | +| `XOR` | Bitwise | Perform a bitwise exclusive OR. | r32/r64 destination; matching register or immediate source. | +| `CMP` | Comparison | Set flags from subtraction without storing the result. | r32/r64 destination; matching register or immediate source. | +| `TEST` | Comparison | Set flags from AND without storing the result. | r32/r64 destination; matching register or immediate source. | +| `JMP` | Control flow | Jump unconditionally. | Label, r64, or supported memory-indirect operand. | +| `JZ` | Conditional branch | Jump if zero/equal. | Label; near rel32. | +| `JNZ` | Conditional branch | Jump if nonzero/not equal. | Label; near rel32. | +| `JZ8` | Conditional branch | Explicit short jump if zero/equal. | Label; range-checked rel8. | +| `JNZ8` | Conditional branch | Explicit short jump if nonzero/not equal. | Label; range-checked rel8. | +| `CALL` | Procedures | Save a return address and call a procedure. | Label, r64, or supported memory-indirect operand. | +| `RET` | Procedures | Return to the caller, optionally discarding stack bytes. | No operand or unsigned imm16 cleanup count. | +| `NOP` | Miscellaneous | Perform no operation. | No operands. | +| `INT` | Interrupts | Encode a software interrupt; execution depends on the OS. | imm8; use SYSCALL for native Linux x64 system calls. | +| `SYSCALL` | System calls | Invoke the native Linux x64 system-call interface. | No operands; registers carry the call number and arguments. | + +### Unsupported on Linux ELF64 x64 + +These mnemonics have no working ELF64 encoder cases. This includes all ten +unimplemented instruction constants from the shared catalog: `ADC`, `SBB`, `MUL`, +`NOT`, `MOVSB`, `MOVSW`, `CMPSB`, `CMPSW`, `PUSHF`, and `POPF`. + +| Mnemonic | Category | Used for | +| --- | --- | --- | +| `ADC` | Carry arithmetic | Add with carry. | +| `SBB` | Carry arithmetic | Subtract with borrow. | +| `INC` | Arithmetic | Increment by one. | +| `DEC` | Arithmetic | Decrement by one. | +| `NEG` | Arithmetic | Negate a signed value. | +| `MUL` | Arithmetic | Unsigned multiplication. | +| `IMUL` | Arithmetic | Signed multiplication. | +| `DIV` | Arithmetic | Unsigned division. | +| `IDIV` | Arithmetic | Signed division. | +| `MOVSX` | Data movement | Copy with sign extension. | +| `MOVZX` | Data movement | Copy with zero extension. | +| `XCHG` | Data movement | Exchange two values. | +| `CBW` | Sign extension | Sign-extend AL into AX. | +| `CWDE` | Sign extension | Sign-extend AX into EAX. | +| `CWD` | Sign extension | Sign-extend AX into DX:AX. | +| `CDQ` | Sign extension | Sign-extend EAX into EDX:EAX. | +| `NOT` | Bitwise | Invert every bit. | +| `BSWAP` | Bitwise | Reverse the byte order of a register. | +| `SHL` | Shifts | Logical left shift. | +| `SAL` | Shifts | Arithmetic left shift; alias of SHL. | +| `SHR` | Shifts | Logical right shift. | +| `SAR` | Shifts | Arithmetic right shift. | +| `SHLD` | Shifts | Double-precision left shift. | +| `SHRD` | Shifts | Double-precision right shift. | +| `ROL` | Rotates | Rotate left. | +| `ROR` | Rotates | Rotate right. | +| `RCL` | Rotates | Rotate left through carry. | +| `RCR` | Rotates | Rotate right through carry. | +| `JE` | Conditional branches | Jump on equal/zero. | +| `JNE` | Conditional branches | Jump on not equal/nonzero. | +| `JG` | Conditional branches | Jump on greater, signed. | +| `JGE` | Conditional branches | Jump on greater or equal, signed. | +| `JL` | Conditional branches | Jump on less, signed. | +| `JLE` | Conditional branches | Jump on less or equal, signed. | +| `JA` | Conditional branches | Jump on above, unsigned. | +| `JAE` | Conditional branches | Jump on above or equal, unsigned. | +| `JB` | Conditional branches | Jump on below, unsigned. | +| `JBE` | Conditional branches | Jump on below or equal, unsigned. | +| `JO` | Conditional branches | Jump on overflow. | +| `JNO` | Conditional branches | Jump on no overflow. | +| `JS` | Conditional branches | Jump on negative sign. | +| `JNS` | Conditional branches | Jump on nonnegative sign. | +| `JP` | Conditional branches | Jump on even parity. | +| `JNP` | Conditional branches | Jump on odd parity. | +| `JC` | Conditional branches | Jump if carry is set; alias of JB. | +| `JNC` | Conditional branches | Jump if carry is clear; alias of JAE. | +| `SETE` | Conditional results | Store 1 on equal/zero; otherwise store 0. | +| `SETNE` | Conditional results | Store 1 on not equal/nonzero; otherwise store 0. | +| `SETG` | Conditional results | Store 1 on greater, signed; otherwise store 0. | +| `SETGE` | Conditional results | Store 1 on greater or equal, signed; otherwise store 0. | +| `SETL` | Conditional results | Store 1 on less, signed; otherwise store 0. | +| `SETLE` | Conditional results | Store 1 on less or equal, signed; otherwise store 0. | +| `SETA` | Conditional results | Store 1 on above, unsigned; otherwise store 0. | +| `SETAE` | Conditional results | Store 1 on above or equal, unsigned; otherwise store 0. | +| `SETB` | Conditional results | Store 1 on below, unsigned; otherwise store 0. | +| `SETBE` | Conditional results | Store 1 on below or equal, unsigned; otherwise store 0. | +| `SETO` | Conditional results | Store 1 on overflow; otherwise store 0. | +| `SETNO` | Conditional results | Store 1 on no overflow; otherwise store 0. | +| `SETS` | Conditional results | Store 1 on negative sign; otherwise store 0. | +| `SETNS` | Conditional results | Store 1 on nonnegative sign; otherwise store 0. | +| `SETP` | Conditional results | Store 1 on even parity; otherwise store 0. | +| `SETNP` | Conditional results | Store 1 on odd parity; otherwise store 0. | +| `CMOVE` | Conditional moves | Copy on equal/zero. | +| `CMOVNE` | Conditional moves | Copy on not equal/nonzero. | +| `CMOVG` | Conditional moves | Copy on greater, signed. | +| `CMOVGE` | Conditional moves | Copy on greater or equal, signed. | +| `CMOVL` | Conditional moves | Copy on less, signed. | +| `CMOVLE` | Conditional moves | Copy on less or equal, signed. | +| `CMOVA` | Conditional moves | Copy on above, unsigned. | +| `CMOVAE` | Conditional moves | Copy on above or equal, unsigned. | +| `CMOVB` | Conditional moves | Copy on below, unsigned. | +| `CMOVBE` | Conditional moves | Copy on below or equal, unsigned. | +| `CMOVO` | Conditional moves | Copy on overflow. | +| `CMOVNO` | Conditional moves | Copy on no overflow. | +| `CMOVS` | Conditional moves | Copy on negative sign. | +| `CMOVNS` | Conditional moves | Copy on nonnegative sign. | +| `CMOVP` | Conditional moves | Copy on even parity. | +| `CMOVNP` | Conditional moves | Copy on odd parity. | +| `LOOP` | Loops | Decrement the counter and jump if nonzero. | +| `LOOPE` | Loops | Loop while the counter is nonzero and ZF is set. | +| `LOOPZ` | Loops | Alias of LOOPE. | +| `LOOPNE` | Loops | Loop while the counter is nonzero and ZF is clear. | +| `LOOPNZ` | Loops | Alias of LOOPNE. | +| `JECXZ` | Loops | Jump if ECX is zero. | +| `BT` | Bit operations | Copy a selected bit to the carry flag. | +| `BTS` | Bit operations | Test and set a bit. | +| `BTR` | Bit operations | Test and reset a bit. | +| `BTC` | Bit operations | Test and complement a bit. | +| `BSF` | Bit operations | Find the lowest set bit. | +| `BSR` | Bit operations | Find the highest set bit. | +| `POPCNT` | Bit operations | Count set bits. | +| `ENTER` | Stack frames | Create a stack frame. | +| `LEAVE` | Stack frames | Release a stack frame. | +| `PUSHF` | Flags | Push flags, with operand-size rules. | +| `POPF` | Flags | Restore flags, subject to operand-size and privilege rules. | +| `CLC` | Flags | Clear carry. | +| `STC` | Flags | Set carry. | +| `CMC` | Flags | Complement carry. | +| `CLD` | Flags | Clear the string direction flag. | +| `STD` | Flags | Set the string direction flag. | +| `LAHF` | Flags | Load status flags into AH. | +| `SAHF` | Flags | Store AH into status flags. | +| `MOVSB` | Strings | Copy a string element. Element width: 8 bits. | +| `MOVSW` | Strings | Copy a string element. Element width: 16 bits. | +| `MOVSD` | Strings | Copy a string element. Element width: 32 bits. | +| `CMPSB` | Strings | Compare string elements. Element width: 8 bits. | +| `CMPSW` | Strings | Compare string elements. Element width: 16 bits. | +| `CMPSD` | Strings | Compare string elements. Element width: 32 bits. | +| `LODSB` | Strings | Load a string element into the accumulator. Element width: 8 bits. | +| `LODSW` | Strings | Load a string element into the accumulator. Element width: 16 bits. | +| `LODSD` | Strings | Load a string element into the accumulator. Element width: 32 bits. | +| `STOSB` | Strings | Store the accumulator into a string element. Element width: 8 bits. | +| `STOSW` | Strings | Store the accumulator into a string element. Element width: 16 bits. | +| `STOSD` | Strings | Store the accumulator into a string element. Element width: 32 bits. | +| `SCASB` | Strings | Compare the accumulator with a string element. Element width: 8 bits. | +| `SCASW` | Strings | Compare the accumulator with a string element. Element width: 16 bits. | +| `SCASD` | Strings | Compare the accumulator with a string element. Element width: 32 bits. | +| `JRCXZ` | Loops | Jump if RCX is zero. | +| `MOVSXD` | Sign extension | Sign-extend a doubleword into a 64-bit register. | +| `CDQE` | Sign extension | Sign-extend EAX into RAX. | +| `CQO` | Sign extension | Sign-extend RAX into RDX:RAX. | +| `PUSHFQ` | Flags | Push 64-bit flags. | +| `POPFQ` | Flags | Restore 64-bit flags, subject to OS restrictions. | +| `MOVSQ` | Strings | Copy 64-bit string elements. | +| `CMPSQ` | Strings | Compare 64-bit string elements. | +| `LODSQ` | Strings | Load 64-bit string elements. | +| `STOSQ` | Strings | Store 64-bit string elements. | +| `SCASQ` | Strings | Scan 64-bit string elements. | + +Legacy `PUSHA`/`PUSHAD`, `POPA`/`POPAD`, `PUSHFD`/`POPFD`, and `JCXZ` forms are not +long-mode instruction forms to port into this target. Use individually supported +64-bit register operations where appropriate; flag-stack support remains future +work. Other condition aliases also remain unimplemented. + +### Missing ELF x64 operand forms + +| Area | Implemented today | Still missing | +| --- | --- | --- | +| `MOV` | Matching-width register copies, immediate loads, memory loads and register stores. | Size-qualified immediate stores, 8/16-bit forms, and SIMD moves. | +| Arithmetic, bitwise, `CMP`, `TEST` | r32/r64 destination with matching register or immediate source. | Memory operands and 8/16-bit forms. | +| Stack | `PUSH r64`, `POP r64`, `PUSH` sign-extended imm32. | Memory operands and broader stack instruction coverage. | +| Addresses | Base plus signed numeric displacement, RIP-relative symbols, RSP/R12 base encoding. | Scaled-index/base-plus-index forms and general expressions. | + +Data remains inline in a read-only executable section. Memory-store instruction +support does not make inline data writable; use suitable writable storage such as +the process stack. Writable sections/BSS are separate roadmap items. + +## Data Directives and Prefixes + +Data directives emit bytes; they are not CPU instructions. + +| Directive | Category | Used for | PE32 x86 | PE32+ x64 | ELF64 x64 | +| --- | --- | --- | --- | --- | --- | +| `DB` | Data | Bytes or UTF-8 strings. | Supported | Target unavailable | Supported | +| `DW` | Data | 16-bit integer values. | Supported | Target unavailable | Supported | +| `DD` | Data | 32-bit integer values. | Supported | Target unavailable | Supported | +| `DQ` | Data | 64-bit integer values. | Missing | Target unavailable | Supported, numeric values | + +Instruction prefixes also require parsing, validation, and encoding support. + +| Prefix | Category | Used for | PE32 x86 | PE32+ x64 | ELF64 x64 | +| --- | --- | --- | --- | --- | --- | +| `REP` | String repetition | Repeat an applicable string instruction using the counter. | Missing | Target unavailable | Missing | +| `REPE` / `REPZ` | String repetition | Repeat applicable compare/scan operations while equal/zero. | Missing | Target unavailable | Missing | +| `REPNE` / `REPNZ` | String repetition | Repeat applicable compare/scan operations while unequal/nonzero. | Missing | Target unavailable | Missing | + +## Floating-Point, SIMD, and Other Extensions + +No floating-point or vector instruction family currently has working encoder +support in either output backend. The examples below identify broader work rather +than promise a complete implementation of each extension. + +| Family | Example unsupported mnemonics | Category / use | +| --- | --- | --- | +| x87 | `FLD`, `FST`, `FSTP`, `FADD`, `FSUB`, `FMUL`, `FDIV`, `FILD`, `FISTP` | Stack-based floating-point arithmetic and conversions. | +| MMX | `MOVQ`, `PADDW`, `PADDD`, `PAND`, `POR`, `PXOR` | Packed integer operations. | +| SSE | `MOVAPS`, `MOVUPS`, `ADDPS`, `ADDPD`, `MULPS`, `DIVPS` | Scalar/packed floating-point and vector operations. | +| AVX / AVX-512 | `VMOVAPS`, `VADDPS`, `VMULPS`, `VDIVPS` | Wider vector operations and additional operand/prefix encodings. | +| Additional CPU features | `CPUID`, `RDTSC`, `CMPXCHG`, `AESENC` | Feature queries, timestamps, atomic operations, and cryptography. | + +CPU availability, execution mode, and OS permissions must be considered when +choosing future instruction forms; a lookup-table entry alone is insufficient. + +## Related Assembly Documentation + +- [Assembly overview](ZASM-Intro.md): selected Windows x86 encodings and basic concepts. +- [Full ZASM reference](ZASM-Reference.md): syntax, operands, registers, labels, imports, and calling conventions. +- [Linux x64 and ELF64](../linux64.md): AMD64 operands, syscall examples, and executable layout. +- [Include files](ZASM-Include-Files.md): shared headers, search paths, and source loading. +- [Examples](ZASM-Examples.md) and [string concatenation tutorial](../tutorial-zasm-concat.md): working assembly programs. +- [Feature roadmap](ZASM-Coming-Soon.md): implemented capabilities and proposed priorities. +- [vNext sandbox](ZASM-vNext-Sandbox.md): experimental syntax proposals, separate from current support. + +## Maintaining This Inventory + +Check [X86Encoder.cs](https://github.com/SuessLabs/ZeroCompiler/blob/master/source/Zero/Targets/X86/X86Encoder.cs), +[X64Encoder.cs](https://github.com/SuessLabs/ZeroCompiler/blob/master/source/Zero/Targets/X64/X64Encoder.cs), +[AssemblyData.cs](https://github.com/SuessLabs/ZeroCompiler/blob/master/source/Zero/Assembly/AssemblyData.cs), and +[target selection](https://github.com/SuessLabs/ZeroCompiler/blob/master/source/Zero/Assembly/Assembler.cs) when updating support. +Add encoding tests and, where appropriate, runtime tests before marking a form +supported. Update this page, the operand reference, the roadmap, and working +examples together. diff --git a/docs/zasm-reference.md b/docs/zasm/ZASM-Reference.md similarity index 95% rename from docs/zasm-reference.md rename to docs/zasm/ZASM-Reference.md index 797b5ca..81ba356 100644 --- a/docs/zasm-reference.md +++ b/docs/zasm/ZASM-Reference.md @@ -5,11 +5,11 @@ title: ZASM Language Reference # ZASM Language Reference -[Documentation home](index.md) · [Complete examples](zasm-examples.md) · -[Include files](Zero-Assembly-Include-Files.md) +[Documentation home](../index.md) · [Complete examples](ZASM-Examples.md) · +[Include files](ZASM-Include-Files.md) · [Mnemonic support](ZASM-Mnemonics.md) This reference covers Windows x86 operand forms. For the Linux x86-64 target, -see [Linux x86-64 and ELF64](linux64.md), including its 64-bit encodings and syscalls. +see [Linux x86-64 and ELF64](../linux64.md), including its 64-bit encodings and syscalls. Shared source syntax, labels, comments, and includes also apply to Linux. An instruction name appearing in a source-code constant or an older design document does not establish @@ -158,7 +158,7 @@ done: This is a fragment: add program termination in a complete application. ZASM has no high-level `if` statement or loop statement yet; use labels and branches. -See [the arithmetic example](zasm-examples.md#add-two-integers) for a complete program. +See [the arithmetic example](ZASM-Examples.md#add-two-integers) for a complete program. ## Assembler Directives @@ -266,7 +266,7 @@ For x86 Win32 APIs such as `MessageBoxA`, the callee removes its arguments: ``` These snippets require the referenced labels and imports. See the -[complete examples](zasm-examples.md). Library calls can overwrite EAX, ECX, and +[complete examples](ZASM-Examples.md). Library calls can overwrite EAX, ECX, and EDX. Preserve any values you need across calls, and preserve EBX, ESI, EDI, and EBP when implementing a procedure or callback whose ABI requires it. @@ -296,14 +296,14 @@ requesting source location and searched paths. DLL-specific headers also cover Kernel32, User32, GDI32, ComCtl32, ComDlg32, Shell32, Winsock, registry/security, COM, Automation, path helpers, multimedia, -HTTP, and file versions. See [Windows API headers](windows-headers.md) for the catalog, +HTTP, and file versions. See [Windows API headers](../windows-headers.md) for the catalog, architecture naming, string encodings, and initialization requirements. The repository keeps these files in root `include`; publishing copies them to -`publish/include`. Read the [include guide](Zero-Assembly-Include-Files.md) for more details. +`publish/include`. Read the [include guide](ZASM-Include-Files.md) for more details. Use the `windows/` prefix for working Windows headers. Separate -[Linux libc drafts](linux-headers.md) under `linux/` prepare future shared-library -interfaces. Static syscall-only ELF64 applications work today; see the [Linux guide](linux64.md). +[Linux libc drafts](../linux-headers.md) under `linux/` prepare future shared-library +interfaces. Static syscall-only ELF64 applications work today; see the [Linux guide](../linux64.md). ## Command Line and Errors @@ -350,6 +350,6 @@ The following require future implementation: - Higher-level Zero compilation, ELF shared-library linking/PIE, ARM/ARM64, Windows x64, macOS, and STM32 backends. **Coming Soon:** expand this reference as each feature gains working syntax and -examples. The [ZASM feature roadmap](zasm-coming-soon.md) tracks implemented -features and outstanding work. The [documentation roadmap](index.md#coming-soon) +examples. The [ZASM feature roadmap](ZASM-Coming-Soon.md) tracks implemented +features and outstanding work. The [documentation roadmap](../index.md#coming-soon) collects broader topics to fill in. diff --git a/docs/Zero-Assembly-PoC-Sandbox.md b/docs/zasm/ZASM-vNext-Sandbox.md similarity index 71% rename from docs/Zero-Assembly-PoC-Sandbox.md rename to docs/zasm/ZASM-vNext-Sandbox.md index 73ddd92..be8ce61 100644 --- a/docs/Zero-Assembly-PoC-Sandbox.md +++ b/docs/zasm/ZASM-vNext-Sandbox.md @@ -1,9 +1,17 @@ -# Zero - Assembly Compiler Proof of Concept Sandbox +--- +layout: default +title: ZASM vNext Sandbox +--- + +# ZASM vNext Sandbox + +[Assembly overview](ZASM-Intro.md) · [Mnemonic support](ZASM-Mnemonics.md) · +[Feature roadmap](ZASM-Coming-Soon.md) > **Design proposal, not current syntax.** The directives and `PROC`/`ENDP` -> forms below are experimental ideas. Use the [current ZASM reference](zasm-reference.md) -> and [working examples](zasm-examples.md) for supported programs. -> [Back to documentation home](index.md). +> forms below are experimental ideas. Use the [current ZASM reference](ZASM-Reference.md) +> and [working examples](ZASM-Examples.md) for supported programs. +> [Back to documentation home](../index.md). The following document contains a sandbox before becoming a Mark-N revision (*i.e. MK-1*). diff --git a/include/readme.md b/include/readme.md index 1abb580..add32b2 100644 --- a/include/readme.md +++ b/include/readme.md @@ -59,5 +59,5 @@ Keep Linux, Windows, future macOS, and STM32 platform interfaces separate. Add `macos` and `stm32` folders when their first headers are ready. Shared platform-neutral headers can get their own folder when an actual common interface exists. -See [include syntax](../docs/Zero-Assembly-Include-Files.md) and the -[ZASM reference](../docs/zasm-reference.md). +See [include syntax](../docs/zasm/ZASM-Include-Files.md) and the +[ZASM reference](../docs/zasm/ZASM-Reference.md). diff --git a/include/windows/readme.md b/include/windows/readme.md index cc67d98..633ede8 100644 --- a/include/windows/readme.md +++ b/include/windows/readme.md @@ -78,6 +78,6 @@ and in combination. On Windows they also check function spellings against the installed x86 DLL export tables, without loading or invoking those DLL functions. This checks the local Windows installation, not availability on every Windows version. -See [include syntax and search order](../../docs/Zero-Assembly-Include-Files.md) and -the [language reference](../../docs/zasm-reference.md). Add your own headers here or +See [include syntax and search order](../../docs/zasm/ZASM-Include-Files.md) and +the [language reference](../../docs/zasm/ZASM-Reference.md). Add your own headers here or pass extra search directories with `-I "my headers"`. diff --git a/samples/readme.md b/samples/readme.md index a77af63..e9d3a0e 100644 --- a/samples/readme.md +++ b/samples/readme.md @@ -120,7 +120,7 @@ using "windows/console.zh" ; Imports puts, printf, and exit The build ships `windows/console.zh` and `windows/windows.zh` in `publish/include` beside both compiler executable. Run `.\zero.exe run samples\Windows\win-cli-01-hello-using.zasm` from `publish` to try it. Add your own search directories with repeated `-I "headers"` options. -See [Using included files](../docs/Zero-Assembly-Include-Files.md). +See [Using included files](../docs/zasm/ZASM-Include-Files.md). For the full DLL-specific catalog, see [Windows API headers](../docs/windows-headers.md). Import Address Table lookup references imported functions and can be called by their names in brackets: