I've been trying to use SDCC to compile extremely lightweight C programs to run on a TI83 calculator (yes, you can do that). Being an old calculator, it doesn't have much RAM to store the program, and the processor is extremely slow. I wrote code similar to *((char*)(x/8)) |= 0x80>>(x&7)
as a simple routine to turn on a single bit where x is a signed char. The problem is, SDCC implements the C standard of upcasting everything into 16 bit ints, which adds one layer of complexity, then it misses out on the fact that x/8 can be achieved by bitshifts and implements an entire inline division algorithm.
My question is: Can I redefine the arithmetic operators to avoid upcasting where possible? And perhaps secondly, can I define the division operation once, then call it several times to avoid massive file sizes?
EDIT: I realized a lot of the problems caused by my code reside in the type of the variables in question, as only unsigned division can have this kind of optimization. The questions of redefining operators and moving the operations to a seperate, single location still stand.