I'm developing a banked program: BANK0 and BANK1 :program BANK2: constants I can't execute long SWITCH statements in functions located at bank1. That't because the big switchs utilizes C?CCASE to resolve its possibilities, and somehow C?CCASE is not working right in the banked mode. How do I force ALL the switchs of my program to be implemented as jumps? Thanks!
Jump tables are listed at optimization level 4. If you compile with a lower optimization level, you might get the if-then-else form. I do not know of a way to disable that one specific optimization. I have a large, banked, application, including some switches that generate calls to C?CCASE not in the common bank, and haven't noticed any trouble with the switch statements. But then, maybe I haven't looked hard enough. So now I'm nervous! Can you describe exactly what problem you're seeing?
Well, as I said, I put some functions of my program in BANK1. Some of these functions have switch statements. In a low level of optimization, all switches are implemented by a calling to C?CCASE. So, all of them results in CPU reset when compiled in LEVEL0 and located at BANK1. At level 4, the smaller switches are implemented as jump tables, but the more complex switches are still implemented with C?CCASE, resulting in CPU reset also. The solution that I found was to divide my switches in smaller switches, in order to make them to be implemented as jump tables. This worked, but I still prefer to don't change the entire code, dividing switches or replacing all by if then else... If anybody has some other suggestion, it would be helpful.. tanxs
I can't execute long SWITCH statements in functions located at bank1. That't because the big switchs utilizes C?CCASE ... How do I force ALL the switchs of my program to be implemented as jumps? Switch-case statements should work in any bank. The C?CCASE routine uses offsets that are stored in CONST (or CODE) space --usually following the call to C?CCASE. If you move all const stuff to a different code bank, the CCASE function won't be able to find the correct case offsets and will jump to indeterminate addresses. There are several solutions to this kind of problem. 1. Locate all of your functions that have switch statements into the common area. 2. Locate the function with switch statements into bank 2 (where constants are stored). 3. Don't put constants into a code bank (they do take longer to access if they're in a code bank). I know that this may not be an option. 4. Force constants from files with switches into the same bank as the rest of the function. Jon
The C?CCASE routine uses offsets that are stored in CONST (or CODE) space --usually following the call to C?CCASE.. When you say "following the call":
E CALL ?C?ICASE R DW ?C0126 DW 08000H R DW ?C0128 DW 09000H R DW ?C0130 DW 0A000H R DW ?C0132 DW 0B000H R DW ?C0126 DW 0C000H R DW ?C0128 DW 0D000H R DW ?C0130 DW 0E000H R DW ?C0132 DW 0F000H DW 00H R DW ?C0124 ; SOURCE LINE # 1237 ; SOURCE LINE # 1238 ; SOURCE LINE # 1239 ?C0126:
START STOP LENGTH ALIGN RELOC MEMORY CLASS SEGMENT NAME ========================================================================= *** COMMON AREA *** 0032D2H 003358H 000087H BYTE UNIT CODE ?CO?ALARMS * * * * * * * * * * * C O D E M E M O R Y * * * * * * * * * * * * * *** CODE BANK 1 *** 00A337H 00A3D3H 00009DH BYTE UNIT CODE/B1 ?PR?ALARMPOLL?ALARM
Which device are you using? Has your device any restrictions in executing MOVC insturctions?