login | register
Fri 18 of May, 2012 (00:36 UTC)

V6Z80P Documentation

Similar PagesHistorys5 slideshowPrint

SDCC framework - How to add new kernal function

Created by: valen, Last modification: Tue 15 of Nov, 2011 (15:39 UTC)
How to add support for new kernal function, to SDCC framework code.
Example for kjt_scroll_up


Create "asm proxy" code, in dir c_support\os_proxy\
- Find in file flos.asm, label proxy__scroll_up and add proxy code.
kjt_scroll_up have not any input/output params, so you can copy'n'paste proxy code from similar function.
(If kjt call have input/output params, the proxy code must handle them. See note 1.)
- Check (just for sure), the label proxy__scroll_up is exist in
file i__kernal_jump_table.asm

Create a C wrapper code, in dir c_support\os_interface_for_c\
- Create new file FLOS_ScrollUp.c
(copy'n'paste C code from function, with similar input/output params, e.g. FLOS_ClearScreen,
and edit for your needs)
(If function have input/output params, the wrapper code must handle them. See note 2.)
- Run script generate_makefile_lib.sh
It will read all files with names FLOS_xxxxxxx.c and will create library
make file Makefile_lib.
(Note 1: this step require a Linux environment. And, thus this step can not be run in Windows.
Note 2: This step in not required, because we use new scons based build system.)

Create a C function prototype, in dir inc\os_interface_for_c\
- Add function prototype to file i_flos.h

That's all. Now you can use function FLOS_ScrollUp() in your program.






Note 1.
Asm proxy.
How to handle input/output params.

Handle input params: copy input params from memory buffer (data exchange area between C and asm)
to appropriate z80 registers.
Do call to kernal code.
Handle output params: copy z80 regs (returned by kernal) to memory buffer.


Note 2.
C wrapper.
How to handle input/output params.

Handle input params: copy function args to memory buffer (data exchange area between C and asm)
Do call to asm proxy code.
Handle output params: copy values from memory buffer to appropriate C vars.


Search


Last modif pages