
;
;       Test of the CASE opcodes
;
;       There just isn't a really elegant way to make this assembler
;       code more readable yet.  And the disassembly is gawdawfull.
;
;       You specify the table of case entries with one or more .CASE
;	directives.  These _must_ immediately follow the CASEx instruction
;	or the base address for the fixup won't be right if you create
;	the (very likely) instance of a forward reference.
;
;       Assemble this and then call test with a parameter.  If the
;       parameter is 5, 6, or 7 then R0 is returned as F5, F6, or F7.
;
;       Any parameter outside the range will result in an FFFF instead.
;       This could be extended at the _exit location to check the PSL 'n'
;       bit which tells if the value was too large or too small...
;

        .entry test


        movl b^4(ap), r0                ; can be 5, 6, or 7

        caseb r0, #5, #2                ; Note limit is z-count of selectors

        .case _f5                       ; These could all be in a single
        .case _f6                       ;     .CASE with comma-separated
        .case _f7                       ;     values.

        brb _exit                       ; land here if outside range

_f5:    movl #000f5, r0
        ret

_f6:    movl #00f6, r0
        ret

_f7:    movl #00f7, r0
        ret

_exit:  movl #0ffff, r0                 ; land here if outside range
        ret


        .end

