OK all of you Macro gurus, I have a macro that I want to specify a valid
register pair (to potentially be used for a divide instruction in the
macro).  I've come up with:

         MACRO
&LABEL   LOADK &STG,&REG,&SCALE=1000
.*
         LCLC  &REG1,&REG2
         LCLA  &X
.*
.*       VALIDATE REQUIRED PARAMETERS PRESENT
.*
         AIF   ('&STG' EQ '').ERR1
         AIF   ('&REG' EQ '').ERR1
         AIF   ('&REG'(1,1) NE '(').ERR2
&X       SETA  INDEX('&REG',')')
         AIF   (&X EQ 0).ERR2
&REG1    SETC  '&REG'(2,&X-2)
         AIF   ('&REG1'(1,1) NE 'R').CHKEVN
&REG1    SETC  '&REG1'(2,*)
.CHKEVN  ANOP
&X       SETA  &REG1
         AIF   (&X GT 15).ERR3
         AIF   (((&X/2)*2) NE &X).ERR2
&REG1    SETC  SIGNED(&X)
&REG2    SETC  SIGNED(&X+1)
.*
...
         MEND

which works great for me (yeah, I know the assembler will check for a
closing paren but, what the heck).  This finds (R14), (14), and flags (R15),
(15), and (16).  But doesn't catch (RA) (i.e. register 10) or anything like
(VALUE) (where VALUE EQU 14).

The 'SIGNED' function seems awkward but the other things I tried are:

&REG1    SETC  '&X'
&REG2    SETC  '&X+1'        (sets &REG2 to '14+1' for example which works,
but looks funny, i.e generates L 14+1,AREA)


and


&REG1    SETC  '&X'
&X       SETA   &X+1
&REG2    SETC  '&X'          (sets &REG2 to '15' for example which works,
but needs the extra SETA)

Anyway, what I'm wondering is if anyone has come up with a better solution.

Thanks for looking,

Mark Hammack
Senior Technical Specialist
Systemware, Inc.

Reply via email to