This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SWITCH in banked mode

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!

Parents
  • 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

Reply
  • 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

Children
  • 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:
    

    Wouldn't these DW's be part of the ?CO?module segment? Or are they literally "following the call" in the ?PR? segment?

    I assume from the discussion thus far that it's the former. Otherwise, you wouldn't be able to relocate the constants in a bank different from the code, as they'd be all one segment and relocated together.

    If they're in the ?CO? segment, it would also answer my question about why I'm getting lucky; my ?CO? segments for these modules happen to be in the common bank.

    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?