Skip to content

Commit

Permalink
Merge branch 'abi-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
atirut-w committed Oct 15, 2024
2 parents a1eb84d + 30f93c6 commit 12f9564
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 63 deletions.
18 changes: 18 additions & 0 deletions docs/abi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Application Binary Interface
The ZDK project specifies an Application Binary Interface (ABI) employed across its compilers, tools, and libraries. This ABI is based on the [cdecl](https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl) calling convention and adheres to conventional C symbol naming rules.

## Function Naming
In contrast to traditional 8-bit compilers, ZDK functions do not have an underscore prefix. This approach simplifies the compilation and linking processes, resulting in cleaner and more intuitive function names.

## Function Parameters
- Parameters are pushed onto the stack from right to left.
- The caller is responsible for cleaning up the stack after the function returns.

## Return Values
- Single-byte values are returned in the `A` register.
- Multi-byte values are returned with the most significant word in the `DE` register pair and the least significant word in the `HL` register pair.

## Register Usage
- Functions can freely use the `A`, `B`, `C`, `D`, `E`, `H`, `L` registers and their pairs without restrictions.
- The caller must save and restore any registers it needs to preserve across function calls.
- If the `IX` register is used (e.g., for indexing arguments or local variables), the callee must preserve it.
62 changes: 0 additions & 62 deletions docs/calling-convention.md

This file was deleted.

2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edit_uri: edit/main/docs/

nav:
- 'index.md'
- 'abi.md'
- Development:
- 'development/compiler-debugging.md'
- 'calling-convention.md'

theme:
name: material
Expand Down

0 comments on commit 12f9564

Please sign in to comment.