Peter Relson wrote:
As to Ed's point,
I believe these system macros deliberately avoid the use of literals.
I'd have to say "not really". Particularly for the SYSSTATE ARCHLVL-related
changes, quite the reverse -- literals are the approach taken (when there
are not suitable "immediate" instructions).
Recently, I coded my first NIL in a relative-addressing module and was
surprised that it required an additional work register. Here is the
expansion:
+ BRAS 15,LA0631 BRANCH TO LA INSTRUCTION
+ PUSH USING
+ DROP ,
+ USING *,15
+BY0631 DC 2AL1(X'FF'-EAX1OPOV) HALF WORD OF MASK BYTES
+IC0631 ICM 2,0,BY0631 INSERT MASK BYTE IN REGISTER
+LA0631 DS 0H
+ LA 1,1(0,0) LOAD ONE IN REGISTER FOR USE IN
+* SETTING UP MASK REGISTER YM1995
+ LNR 2,1 SET REGISTER TO ALL ONES
+ SLL 1,3-((EAXFLAG1-EAXFLAGS)-(((EAXFLAG1-EAXFLAGS)/4)*4))(0)
+* SHIFT THE ONE TO PROPER POSITION FOR
+* 4-BIT MASK FOR ICM INSTRUCTION YM1995
+ EX 1,IC0631 EXECUTE ICM INSTRUCTION
+* TO PUT MASK BYTE
+* IN PROPER POSITION IN REGISTER WITH
+* ALL ONES
+ POP USING
+ L 0,EAXFLAGS+(((EAXFLAG1-EAXFLAGS)/4)*4)
+* LOAD WORD CONTAINING BYTE TO BE SET
+LR0631 DS 0H
+ LR 1,0 LOAD WORD CONTAINING BYTE TO BE SET
+ NR 1,2 AND MASK INTO BYTE IN REGISTER
+* USE COMPARE AND SWAP TO STORE UPDATED
+* REGISTER IN STORAGE IF STORAGE WORD WAS
+* NOT MODIFIED
+ CS 0,1,EAXFLAGS+(((EAXFLAG1-EAXFLAGS)/4)*4)
+ JNE LR0631 DO AGAIN FROM LR IF WORD WAS MODIFIED
The term "base-less" programming is a misnomer. Generally, no fewer base
registers are required for a program written to use relative branches
than for one written to use based branches. The obvious exceptions are
programs written by inexperienced programmers using really ugly,
old-school techniques in which 2, 3, 4, or even 5 bases are used. But
serious software developers that have been writing code with a single
base all along do not experience reduced register utilization using
relative branch programming techniques. (Relative branch is quite
beneficial in other ways, however.)
For this reason, a macro that implements an additional work register
requirement instead of simply using literals creates additional
unnecessary burden and hardship on the programmer. I originally assumed
the developer that updated NIL was attempting to avoid the use of literals.
On closer examination, I now suspect the programmer felt challenged by
the lack of a relative form of EXecute, and didn't see how a literal
could be used to mitigate that problem. That's understandable. This
major architectural restriction has forced me to write macros with
embedded EX instructions like this:
| **********************************************************
| * The literal used as the object of the following EX *
| * instruction is equivalent to: 'PACK &WRKDBL,0(*-*,R1)' *
| EX R15,=S(((L'&WRKDBL-1)*16)+512(15),&WRKDBL,0(1)) *
| **********************************************************
It works, but a) is so unintuitive it *requires* surrounding commentary
and b) the I-stream locality of reference for the object of the EXecute
is lost. The best solution (IMHO) is the introduction of an EXR
instruction to the architecture. But that is for another thread.
BTW, the "USING *,15" generated by NIL is most unwelcome. If a base
register can't be avoided, _at least_ let the range be explicitly
specified (e.g., "USING (A,B),15") to avoid potential USING overlap
issues with the surrounding code!
--
.-----------------------------------------------------------------.
| Edward E. Jaffe | |
| Mgr, Research & Development | [EMAIL PROTECTED] |
| Phoenix Software International | Tel: (310) 338-0400 x318 |
| 5200 W Century Blvd, Suite 800 | Fax: (310) 338-0801 |
| Los Angeles, CA 90045 | http://www.phoenixsoftware.com |
'-----------------------------------------------------------------'
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html