Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!bionet!agate!ucbvax!mvs.draper.COM!seb1525 From: seb1525@mvs.draper.COM ("Stephen E. Bacher") Newsgroups: comp.lang.asm370 Subject: RE: GETMAIN Message-ID: <9103050113.AA15905@ucbvax.Berkeley.EDU> Date: 5 Mar 91 00:15:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: IBM 370 Assembly Programming Discussion List Distribution: inet Organization: The Internet Lines: 55 >I believe you put the register number in (), in place of the >length. If you put the number, it has to load it into >a register, anyway. Then again, you can do the SVC directly. >It is, I believe, SVC 10. There is also SVC 4, and SVC 5, >which are related. This is a VERY BAD recommendation. Here are some reasons: (1) Various releases of the MVS operating system have different capabilities with regard to GETMAIN. In particular, MVS/XA allows specification of the location of the returned storage wrt the 16M line (above or below), and MVS/ESA allows further options as to the nature of the addressability of the storage. These all use different SVC numbers. In fact, SVC's 4, 5 and 10 are pretty much "out of style". Even non-ESA code for the past several years has tended to use SVC 120. (2) In any case, coders should ALWAYS use documented interfaces to system facilities unless there is a very good reason to do otherwise (e.g. IBM doesn't provide a way for you to do X, which is true of things like reentrant CAMLST calls, but not of GETMAIN/FREEMAIN to my knowledge). (3) The code will be less than perspicuous to anyone who does not have the popular SVC numbers memorized, unless very heavy commenting is present. And in such a case, why go to the trouble of filling in the gap with comments when the presence of the sanctioned IBM macro itself provides much of the documentation? (There's even a parameter called "RELATED" on GETMAIN, for those who hate typing comments that the assembler can't read for some unknown reason.) In short, such coding practices should NOT be encouraged, particularly for novice users. GETMAIN for length encoded at run time? Here's the best way: LA R0,constant_length_value_between_1_and_4095 GETMAIN R,LV=(0) or L R0,fullword_containing_length_value * (but be sure the high-order byte is zero) GETMAIN R,LV=(0) Note that the specification (0) not only says that the length to get is in register 0, but for many simple GETMAIN cases it will eliminate a register load, since the macro knows that the GETMAIN SVC expects the length in register zero. Admittedly this relies on knowledge of the underlying SVC, but this is established practice and is even recommended in the relevant IBM manual, as I remember. - SEB