10-04-2016, 02:42 PM
Post: #403
 Bruno Member Posts: 74 Joined: Sep 2014
(10-04-2016 01:31 PM)Claudio L. Wrote:  Lately, all compilers automatically generate a jump table when compiling switch statements with consecutive numbers, so from a speed point of view it's almost equivalent, except you don't need to explicitly code the array or the jump.

Ok, thanks, I envisioned this fact, compiler's optimizations are so powerfull !

(10-04-2016 01:31 PM)Claudio L. Wrote:  Also, using separate functions causes additional overhead in passing arguments, setting up variables, etc. that could be shared between all cases.
....
So I think our use case is a very good fit for a switch() statement, the only drawback is that the code is less readable,

As a workaround we can 'inline' the functions.

I've successfully compiled my first 'custom' ROM (Ok custom only mean that I have added the MEM command),
this worked well but the command is not displayed by the autocompletion feature, is there any place to declare this function I missed ?

extract from 'lib-65-system.c' :
Code:
#define COMMAND_LIST \     CMD(TICKS,MKTOKENINFO(5,TITYPE_NOTALLOWED,1,2)), \     CMD(MEM,MKTOKENINFO(3,TITYPE_NOTALLOWED,1,2)), \     CMD(MEMCHECK,MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2)), \     CMD(MEMFIX,MKTOKENINFO(6,TITYPE_NOTALLOWED,1,2)), \     CMD(READCFI,MKTOKENINFO(7,TITYPE_NOTALLOWED,1,2)), \     CMD(PEEK,MKTOKENINFO(4,TITYPE_NOTALLOWED,1,2)), \     CMD(POKE,MKTOKENINFO(4,TITYPE_NOTALLOWED,1,2)), \     CMD(VERSION,MKTOKENINFO(7,TITYPE_NOTALLOWED,1,2))

MEM push the result on the stack :