SDCC framework - technical details
Created by: valen, Last modification: Sat 16 of Oct, 2010 (15:00 UTC)
Framework content
Coded in as-z80 assembler.
Coded in pasmo assembler.
Have a “data exchange” area (between C and asm code) at offset 0. (area len is $20 bytes)
Actual code start at offset $20.
For each FLOS procedure:
Compilation process:
(For conversion from binary to C source file, xd.exe utility used.)
This is a C file, which contain FLOS C functions.
Each function do the following:
The call chain is:
Current status
The content of “obj” folders is auto generated by SDCC compiler and linker.
Start address 5000.
(you set CODE and DATA values and also STACK value, in your project Makefile)
C start up code
(c_programs/c_support/crt)Coded in as-z80 assembler.
- save FLOS stack ptr
- save ptr to command line args
- set own stack
- call gsinit (init global C vars)
- call main()
- restore original FLOS stack ptr
- exit to FLOS, with exit code returned by main()
OS interface - asm proxy
(c_programs/c_support/os_proxy)Coded in pasmo assembler.
Have a “data exchange” area (between C and asm code) at offset 0. (area len is $20 bytes)
Actual code start at offset $20.
For each FLOS procedure:
- push all regs
- get args from “data exchange” area to z80 regs
- call FLOS
- store returned values from z80 regs to “data exchange” area
- pop all regs
Compilation process:
- proxy source code flos.asm compiled to flos.asm.bin
- flos.asm.bin (binary) converted to flos_proxy_code.c (C source code)
- flos_proxy_code.c compiled and linked to user program, at address $5080.
(For conversion from binary to C source file, xd.exe utility used.)
OS interface for C
(c_programs/c_support/os_interface_for_c)This is a C file, which contain FLOS C functions.
Each function do the following:
- copy function arguments to “data exchange” area
- call “asm proxy”
- copy returned results from “data exchange” area to C vars
The call chain is:
- user program call C function in “OS interface for C”
- “OS interface for C” call “asm proxy”
- “asm proxy” call FLOS code
Current status
- number of C FLOS function implemented: about 30 (see inc\os_interface_for_c\i_flos.h for complete list)
- asm proxy compiled size: about 1,8 KB
The content of “obj” folders is auto generated by SDCC compiler and linker.
Executable file map
Start address 5000.
| Offsets in file | Description |
|---|---|
| 0000 | C start up code |
| 0080 | asm proxy |
| 0080 | asm proxy - “data exchange” area |
| 00a0 | asm proxy - actual code |
| CODE | start of code |
| DATA | start of data |
(you set CODE and DATA values and also STACK value, in your project Makefile)