•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileUsing the $S& option, you can make the SELECT-CASE instruction treat all
following expressions as two-byte parameters. The default $S% option makes
SELECT and CASE treat all values as four-byte parameters.

A look at the resulting code illustrates the differences. The listing

    SELECT a%
    CASE 1
      case_1:
      INC a%
    CASE 2
      case_2:
      INC a%
    DEFAULT
      default:
      INC a%
    ENDSELECT
    endsel:
    INC a%

contains markers to make the symbolically disassembled code more transparent.
Each marker is followed by an instruction (INC a%) as a placemarker for the
individual instruction blocks.

Use of the $S& option results in the following code:

              move.l  -$8000(a5),d0
              bra.s   L1
    _CASE_1:  addq.l  #$1,-$8000(a5)
              bra.s   _ENDSEL
    _CASE_2:  addq.l  #$1,-$8000(a5)
              bra.s   _ENDSEL
    _DEFAULT: addq.l  #$1,-$8000(a5)
              bra.s   _ENDSEL
    L1:       cmpi.w  #$2,d0  ;CASE evaluation
              beq.s   _CASE_1
              cmpi.w  #$2,d0
              beq.s   _CASE_2
              bra.s   _DEFAULT
    _ENDSEL   addq.l  #$1,-$8000(a5)

The L1 label is not generated here.

The listing first places the four-byte value a% into d0. Then the routine to
branch to the individual CASE instruction blocks is called. This is marked in
the listing by the comment "CASE evaluation". There cmpi.w (compare integer
words) is used to compare, for wordlength only, the values after CASE with the
contents of d0.

If these values are found to be identical, beq.s (branch equal) jumps to the
block after the appropriate CASE. This block ends with the jump to the line
behind the SELECT-ENDSELECT block. Here the jump is made using bra.s _ENDSEL.
If none of the values after CASE fits, the DEFAULT block is called. Without the
S& option the comparisons made here would be for longword length.

Memo: $S% is the default.
      Whilst viewing a diss-assembly of the GFA Compiler I discovered a check
      for the $S| command.  However, my tests seem to indicate that it's
      identical to the $S& command. The reason is simple, there is no size or
      speed advantage to byte comparisons on the 68000. The $S| command seems
      to have been added just for completeness.