Page 1 of 1

getmain one new memory

PostPosted: Fri Mar 08, 2013 6:40 am
by bobguo
Hi guys,

in general, if we want to getmain one memry, almost all the programs would like to issue
EXEC CICS GETMAIN FLENGTH...

but right now, if i want to getmain one new memory in one small HLASM program which does NOT use cics command, how can i achieve it?
thanks very much!

Sincerely,
Bob

Re: getmain one new memory

PostPosted: Fri Mar 08, 2013 7:27 am
by Robert Sample
Is the program running in CICS?

For batch programs, look at the GETMAIN or STORAGE macros in the Assembler Services Reference manuals.

Although, it is hard to tell if you want 1 byte or 1 page or what from your post:
one new memory

Re: getmain one new memory

PostPosted: Fri Mar 08, 2013 9:27 am
by steve-myers
Actually it is difficult to divine your intent. In z/OS internals, the term "memory" often refers to the concept of allocating something like a data space, which is moderately difficult and not suited for discussion in a a beginner's forum. If what you really need is a "small" amount of storage, and the program is not running in CICS, you want to use something like the GETMAIN or STORAGE macros, as suggested by Mr. Sample, and use FREEMAIN or STORAGE to release the storage when you no longer need the storage. These macros are described in detail in Assembler Services Guide or Assembler Services Reference ABE-HSP (the exact title changes sightly from release to release) for your z/OS release. There are so many options with these macros I won't begin by trying to describe them.

Historically, there have been two major versions of the GETMAIN and FREEMAIN macros: the OS/360 versions and the MVS "native" versions. The OS/360 macros generate SVC 4, SVC 5 or SVC 10 machine instructions; the MVS "native" versions generate the SVC 120 instruction. The two versions are mixed together in a nearly incomprehensible (especially if you attempt to understand the macro source itself) manner. The documentation does not distinguish the version; it just lumps everything together. Most of us just use the R (OS/360) or RU, RC, VRU, VRC ("native" MVS) forms of the macros, and rarely, if ever, use the other forms (all OS/360) of the macros. The STORAGE macro is strictly MVS, though I don't recall when it was added.

The STORAGE macro provides the same general services as the "native" MVS forms of the GETMAIN and FREEMAIN macros. but it uses the PC instruction operating as what 80x86 hardware calls a "call gate" to invoke the service. Most of us avoid the STORAGE macro; if it abnormally terminates your program it is difficult to determine where in your program the failing STORAGE macro was issued.

Hope this helps.