User Tools

Site Tools


SDCC framework - technical details

Framework content

C start up code

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

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.

Note: To link to absolute address, SDCC want a separate C file, with separate segment. That's why we need to generate separate source file flos_proxy_code.c
(For conversion from binary to C source file, xd.exe utility used.)

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

Note: For now, not all FLOS calls have equivalent C functions, but I plan to add missing functions.

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 fileDescription
0000C start up code
0080asm proxy
0080asm proxy - “data exchange” area
00a0asm proxy - actual code
CODEstart of code
DATAstart of data

(you set CODE and DATA values and also STACK value, in your project Makefile)

technical_details.txt · Last modified: 2017/07/03 20:52 by z00m