On Oct 14, 2011, at 14:15, McKown, John wrote: > This is just a thought that I had. I'd appreciate feedback about its utility. > HLASM currently can do some tests on symbols, such at "type" (T'SYMBOL) or > "length" (L'SYMBOL) and others. I thought it might be useful to have another > test to see if the symbol can be resolved via as "relative" operand, or only > via a base+displacement, or not currently addressable. Perhaps A'SYMBOL with > a single character returned: which would be "R" for "short" relative (16 bit > relative value), "L" for "long" relative (32 bit relative value needed), > "0".."F" for the base register (hex 0..F) which the assembler would select, > "U" if it is not addressable at all (including does not exist). The order of > preference would be "R" if a short relative would work, "L" if a short > relative wouldn't work, but a long relative would, the base register if based > is required, or "U" if none of the previous. Why? Because I like relative > instructions. I think it might be helpful to have code such as: > > LCLC &T > &T SETC A'SYMBOL > AIF (&T,EQ,"R").R > AIF (&T,EQ,"L").L > AIF (&T,EQ,"U").U > BAS R14,&SYMBOL > AGO .CONT > .R ANOP > BRAS R14,&SYMBOL > AGO .CONT > .L ANOP > BRASL R14,&SYMBOL > AGO .CONT > .U ANOP > MNOTE 8,"CANNOT ADDRESS SYMBOL" > .CONT ANOP > You're forcing the assembler into circular reasoning. It may not know which addressing forms work until it knows how many bytes of code will be generated by a particular branch of the AIF.
(But compilers regularly solve this sort of problem.) -- gil
