Hello Peter,
I'm not sure if it is necessary for your task to store the location of the bits
in macro symbols.
We do it this way:
FLAGA DS 0BL1
FLAGB DS 0BL1
FLAGC DS 0BL1
FLAGD DS 0BL1
FLAGE DS 0BL1
FLAGF DS 0BL1
FLAGG DS 0BL1
FLAGH DS BL1
that is, 8 bits make one byte, every 8 definitions the 0 repeat factor is
omitted, so all definitions from FLAGA to FLAGH define the same byte. If you
need more bits, you start this scheme again with the next eight bits, and so on.
and then we define
$FLAGA EQU X'80'
$FLAGB EQU X'40'
$FLAGC EQU X'20'
$FLAGD EQU X'10'
$FLAGE EQU X'08'
$FLAGF EQU X'04'
$FLAGG EQU X'02'
$FLAGH EQU X'01'
so every bit has its own name and an EQU constant which defines its position.
The fact that FLAGA to FLAGH are in the same byte is hidden from (and not
relevant to) the user.
The user uses instructions like
TM FLAGA,$FLAGA test bit
OI FLAGA,$FLAGA set bit on
NI FLAGA,X'FF'-$FLAGA set bit off
XI FLAGA,$FLAGA change status of bit
To make the definitions and instructions above easier, we have macros
DEFBIT list-of-bit-names-of-arbitrary-length
TESTBIT bit
SETBIT bit
RESETBIT bit
CHGBIT bit
Kind regards
Bernd
Am 04.10.2014 21:13, schrieb P.F.:
> John,
>
> Thank you for that example, it helps a lot. The example I gave was generating
> DC lines for the sake of figuring out the proper syntax. My real goal is a
> bit different.
>
> I have a static list of 64 flag bit names (each one like Flag_A EQU X'80').
> I want to create a flag-test macro FTEST to test one or more of those bit flags
> against a set of 8 flag bytes, each named FLAGn, 1 <= n <= 8. So if Flag_A
> is defined as a bit in Flag1, I will generate a test like:
>
> FTEST Somewhere,Flag_A
> + TM Flag1,Flag_A
> + BO Somewhere
>
> And if a list of multiple flag names are provided to the test macro,
> the result should resemble:
>
> FTEST Somewhere, (Flag_P,Flag_H,Flag_G,Flag_A)
> + TM Flag1,Flag_A+Flag_G+Flag_H
> + BO Somewhere
> + TM Flag2,Flag_P
> + BO Somewhere
>
> Obviously the trick is to associate a flag number with each name, and to sort
> the list of flag names provided to the FTEST macro by the flag byte number
> so that all tests against the same flag byte are grouped together.
>
> Also, other than a manually created list of GBLA definitions and SETA
> initializations for the flag names (like GBLA &Flag_A and &Flag_A SETA 1),
> is it possible to create a loop that dynamically computes the flag number
> for each name (where the flag names are stored in the proper order in an
> initialized GBLC array) and dynamically creates the GBLA and SETA lines?
> I.E., is it legal to loop over GBLA as well as SETA statements?
>
> Have you solved a problem like this already, or can you suggest an
> approach that will work for such a macro?
>
> Thank you again for your clear example.
>
> P.
>
|