Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uwm.edu!linac!midway!gargoyle!chinet!laird From: laird@chinet.chi.il.us (Laird J. Heal) Newsgroups: comp.lang.asm370 Subject: Re: help for new assembly'er Message-ID: <1991Mar03.103002.12946@chinet.chi.il.us> Date: 3 Mar 91 10:30:02 GMT References: <9102272012.AA08264@ucbvax.Berkeley.EDU> Distribution: inet Organization: Chinet - Chicago Public Access UNIX Lines: 48 In article <9102272012.AA08264@ucbvax.Berkeley.EDU> IBM 370 Assembly Programming Discussion List writes: >On Wed, 27 Feb 91 04:32:34 GMT Laird J. Heal said: > >>All other registers [besides 0, 1, 2, 13, 14 and 15] >>can be used for base or scratch as you like. >>Writing reentrant code (use RU-type GETMAIN for all data areas) >>is good practice but not much good otherwise. > >Actually R2 is not used by any usual operating system functions, so >it's safe too (though the TRT instruction does use it as an implicit I find its special status a good excuse to use it as a single scratch register whose contents will not be normally modified by the operating system. There is no special error in using it, for example, as a base register, but I can remember well solving a nightmare for a co-worker by noting that the last byte of R2 was providing him with a little unexpected auto-indexing. >>Since registers zero, one and two can be modified by everything from >>SVCs to TRTs, use them for scratch areas. R15 is your entry address >>but you should save it off - R12 is typically used for this and thus >>as the code base register. R14 is the return address but can be used >>within your code as can R15, as the OS never really relies on them. >>R13, on the other hand, should always point to your Register Save >>Area, unless you are working with DOS/VSE/POWER, in which case I >>commend your soul to the appropriate power. >Please note that at least in OS/MVT and VS/1 and (presumably) the >various MVS variants, and the OS Simulation routines under VM/CMS, >that the various QSAM I/O macros (such as GET and PUT), involve >a BALR 14,15 - so these registers should *not* be used except as >scratch unless you *know* that any system macros you use don't modify >these registers. Incidentally, macros like this are the *REASON* you >usually use R12 as the base rather than R15.... Excuses for the extensive attributions. You note that I was commenting on scratch registers. Simply put, I was cautioning against using R13 for anything except save area chaining. The other registers (from R14 to R2) are not so sacrosanct. Some folks use R2 for a base register or such - I feel this is a mistake of style, but since TRT is not normally used, it often is harmless. During my first class in BAL, the assistant (who was grading all of the exercises) said "always use PRINT GEN" to which the instructor said "you mean, never use PRINT GEN". I tend to the "always" mode. -- Laird J. Heal The Usenet is dead! Here: laird@chinet.chi.il.us Long live the Usenet!