Thanks everyone! Seymour, I don't see anywhere that Branch Relative on Condition takes an "index register". Maybe I missed something?
Charles, the macro I wrote has bounds checking (one of the reasons I wrote it was because I found the potential for exactly the problem you mention). I may have gotten mixed up. I had started to use: LARL 14,*+((48+32+16)/8) L 14,0(15,14) BR 14 DC A(RC0ROUTINE) DC A(RC4ROUTINE) DC A(RC8ROUTINE) and confused myself. I'm not real big on branch tables myself but they're cleaner than trying to use the select structured macro (IMO). Also, my intent was to hide a lot of the branch table weaknesses. From a LOOONG time ago, the original IBM C compiler implemented branch tables for switch/case. Steve, I need to investigate BAS. Thought about BAL but guess I never "equated" the two. *Mark Hammack* Systemware, Inc. Senior z/OS Developer mark.hamm...@gmail.com 214-478-0955 (c) On Tue, Nov 23, 2021 at 11:13 AM Seymour J Metz <sme...@gmu.edu> wrote: > The problem isn't branch tables; the problem is code that doesn't validate > its input. > > LTR R15,R15 > JM BADIX > CHI R15,LIMIT > JH BADIX > TML R15,3 > JNZ BADIX > J *+4(R15) > BRTAB EQU * > J RC0ROUTINE > J RC4ROUTINE > J RC8ROUTINE > LIMIT EQU *-BRTAB > > > > > > -- > Shmuel (Seymour J.) Metz > http://mason.gmu.edu/~smetz3 > > ________________________________________ > From: IBM Mainframe Assembler List [ASSEMBLER-LIST@LISTSERV.UGA.EDU] on > behalf of Charles Mills [charl...@mcn.org] > Sent: Tuesday, November 23, 2021 11:24 AM > To: ASSEMBLER-LIST@LISTSERV.UGA.EDU > Subject: Re: Base-less macros > > Should that second instruction be an LA? > > I quit using branch tables. I know, they are useful, but IMHO wild > branches are the worst of bugs, and so I have eschewed branch tables. > > The architecture could use a new instruction "branch relative indexed" or > JI. So then your original code would become > > JI *+4(15) > J RC0ROUTINE > J RC4ROUTINE > J RC8ROUTINE > > Charles > > > -----Original Message----- > From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU] > On Behalf Of Mark Hammack > Sent: Tuesday, November 23, 2021 7:42 AM > To: ASSEMBLER-LIST@LISTSERV.UGA.EDU > Subject: Re: Base-less macros > > So as a related question, I started working on a 'baseless' version of a > branch table macro I wrote years ago. I have it working but was curious > what other people have done. > > In 'based' code, it typically generates something like: > > B *+4(15) > B RC0ROUTINE > B RC4ROUTINE > B RC8ROUTINE > etc. > > The best I could come up with for 'baseless' code is: > > LARL 14,*+((48+32+16)/8) > L 14,0(15,14) > BR 14 > J RC0ROUTINE > J RC4ROUTINE > J RC8ROUTINE > > As to the specific question asked in the thread, I recently ran into an > issue where a macro expanded by a couple of bytes which threw the literals > out of the 4k 'base'. The way I took care of *most* of the issue was to go > with immediate, long displacement or relative instructions as much as > possible which all but eliminated the need for an LTORG or at least reduced > the need for multiple LTORGs in the program. >