C445585@UMCVMB.BITNET ("John M. Kelsey") (02/24/91)
I'm a bit confused about how to get GETMAIN to give me an amount of memory determined at execution time, rather than assembly time. I seemed to have no problems with GETMAIN R,LV=1000 What would I have to specify to get, say, a number of bytes equal to the number of bytes in register 2? GETMAIN always returns a chunk of memory alligned on a doubleword boundary, right? --John Kelsey internet: c445585@umcvmb.missouri.edu BITNET : C445585@UMCVMB
rickert@CS.NIU.EDU (Neil Rickert) (02/24/91)
In article <9102232014.AA08196@ucbvax.Berkeley.EDU> you write: > > I'm a bit confused about how to get GETMAIN to give me an amount of >memory determined at execution time, rather than assembly time. I seemed >to have no problems with > > GETMAIN R,LV=1000 > >What would I have to specify to get, say, a number of bytes equal to the >number of bytes in register 2? GETMAIN always returns a chunk of memory >alligned on a doubleword boundary, right? How about GETMAIN R,LV=(2) or GETMAIN R,LV=0(2) I believe either will work. The first will definitely work. Yes, you get doubleword alignment. -- =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= Neil W. Rickert, Computer Science <rickert@cs.niu.edu> Northern Illinois Univ. DeKalb, IL 60115 +1-815-753-6940
seb1525@mvs.draper.COM ("Stephen E. Bacher") (03/05/91)
>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
news@ucf1vm.BITNET (03/07/91)
> There's even a parameter called "RELATED" on GETMAIN....
"RELATED"... yuk. SETLOCK actually *requires* the use of RELATED,
which I always thought was pretty heavy handed, even for IBM.
Whenever I code one of these I either use RELATED=(X) - if I'm in
a hurry - or I code RELATED=(IBMSUCKS). Usually I code the latter
when my first assembly failed because I neglected to include the
officially IBM sanctioned comment parameter.
- David Andrews tarpit!rtmvax!dandrews
gah@HOOD.HOOD.CALTECH.EDU (Glen Herrmannsfeldt) (03/11/91)
Sorry about the SVC comment. It was to suggest that the final result of the macro is an SVC call, and that the goal of the macro is to get the number into the register. It has been about 10 years since I did this, and that was OS/VS2 and OS/MVT. The only reason I would suggest using the SVC is for the fun of seeing the SVC work under unusual conditions, not hthat I can think of many. -- glen