Add documentation about C/ASM calling conventions.
This commit is contained in:
parent
05ae364cfc
commit
636e5787de
41
README.md
41
README.md
@ -5,3 +5,44 @@ Demo for the Sanco 800x.
|
|||||||
The purpose of this demo is mainly to thinker with the hardware of the mentioned computer, since we are reverse-engineering it, and even writing an emulator.
|
The purpose of this demo is mainly to thinker with the hardware of the mentioned computer, since we are reverse-engineering it, and even writing an emulator.
|
||||||
|
|
||||||
This repository is part of the [CEDA project](https://github.com/GLGPrograms/ceda-home) by [Retrofficina GLG Programs](https://retrofficina.glgprograms.it/).
|
This repository is part of the [CEDA project](https://github.com/GLGPrograms/ceda-home) by [Retrofficina GLG Programs](https://retrofficina.glgprograms.it/).
|
||||||
|
|
||||||
|
## C/ASM calling conventions
|
||||||
|
Because the folks at z88dk were not able to put this plain and simple table
|
||||||
|
in their messy documentation :smile:
|
||||||
|
|
||||||
|
### Prologue
|
||||||
|
```
|
||||||
|
push ix
|
||||||
|
ld ix,$0000
|
||||||
|
add ix,sp
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters stack
|
||||||
|
```
|
||||||
|
uint8_t
|
||||||
|
ix+$04
|
||||||
|
|
||||||
|
uint8_t, uint8_t
|
||||||
|
ix+$04, ix+$05
|
||||||
|
```
|
||||||
|
|
||||||
|
### Access call parameters
|
||||||
|
```
|
||||||
|
ld a,(ix+$04)
|
||||||
|
ld a,(ix+$05)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Return value
|
||||||
|
```
|
||||||
|
uint32_t de (msb), hl (lsb)
|
||||||
|
uint16_t hl
|
||||||
|
uint8_t l
|
||||||
|
void* hl
|
||||||
|
```
|
||||||
|
|
||||||
|
### Epilogue
|
||||||
|
```
|
||||||
|
pop ix
|
||||||
|
ret
|
||||||
|
```
|
||||||
|
|
||||||
|
16
src/main.c
16
src/main.c
@ -12,3 +12,19 @@ int main(void) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t ret_u8(void) {
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t ret_u16(void) {
|
||||||
|
return 0x0123;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ret_u32(void) {
|
||||||
|
return 0x01234567;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *ret_ptr(void) {
|
||||||
|
return (void *)0x1234;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user