After receiving feedback of Joachim from ZX81 user group that assembled the TEK I've started to porting the code to SDCC. At this time I can compile the code in SDCC running under Windows. On Linux I am still dealing with some compilation errors related to libraries but this is a matter for another log.
The porting basically required:
- Installing the necessary tools
- Changing the type of some variables to be compatible with SDCC: chars have been replaced by uint8_t to avoid warnings and int1 have been replaced by uint8_t. I've tried to use _Bool type (from stdbool.h) but this resulted in an internal SDCC error!
- Changing the way of defining the fuses
//#fuses INTRC_IO, NOPROTECT, NOBROWNOUT, NOWDT, PUT
uint16_t __at _CONFIG configWord = _INTRC_OSC_NOCLKOUT & _CPD_OFF & _CP_OFF & _WDT_OFF & _PWRTE_ON;
- Replacing library functions by macros or direct accessing the registers.
// output_low (PIN_SDA);
TRIS_SDA=0; //set as output
PIN_SDA=0;
- Changing the delay_us funcion to reflect the time spent by the assembly code generated by the macro (it takes 4+ 9*X cycles).
#define delay_us(x) { uint8_t us; \
us = (x)*FOSC/36000000L - 4/9;\
while(--us != 0) continue; }
The SDCC compiler provides an estimate size of code generated: 669 instructions.
It is almost the same size of the code generated with CCS. The difference is minimal.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.