-
Notifications
You must be signed in to change notification settings - Fork 2
/
SETUP.ASM
168 lines (168 loc) · 6.22 KB
/
SETUP.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
MACRO
&LBL SETUP &TYPE=,&BASE=1,&CSECT=
.**********************************************************************
.* *
.* THIS MACRO PROVIDES REENTRANT STARTING CODE FOR THE FOLLOWING: *
.* 1) A REGULAR ASSEMBLER ROUTINE (EXCEPT HAS 20 WORD SAVE AREA) *
.* 2) AN ASSEMBLER ROUTINE TO BE CALLED FROM PL/I *
.* 3) AN ASSEMBLER MAIN ROUTINE WHICH WILL CALL PL/I SUBROUTINES *
.* *
.* TO UNDO WHAT THIS MACRO DOES USE THE FINISH MACRO. *
.* *
.* THE LABEL SPECIFIED ON THE MACRO STATEMENT BECOMES THE CSECT NAME *
.* FOR (1) AND THE ENTRY POINT FOR (2) AND (3). THIS NAME IS ALSO *
.* PUT INTO AN IDENTIFIER SECTION AT THE BEGINING OF THE CODE *
.* FOLLOWED BY ITS LENGTH. *
.* *
.* THERE ARE TWO KEYWORD PARAMETERS WHICH CONTROL THE MACRO *
.* EXPANSION. TYPE, DETERMINES WHICH OF (1), (2) OR (3) TO GENERATE, *
.* AND BASE GIVES THE NUMBER OF BASE REGISTERS DESIRED. FURTHER *
.* DETAILS BY CLASS FOLLOW: *
.* *
.* TYPE= *
.* 1) NULL OR ANYTHING OTHER THAN (2) OR (3) *
.* 2) PLI *
.* 3) ASMPLI *
.* *
.* BASE= (DEFAULT IS 1) *
.* 1) STARTS WITH REG 12 AND WORKS DOWN *
.* 2) STARTS WITH REG 11 AND WORKS DOWN *
.* 3) STARTS WITH REG 11 AND WORKS DOWN *
.* *
.**********************************************************************
LCLA &A,&B,&C,&BSNUM,&CNT,&BSPREV
LCLC &NAME,&BS
AIF (&BASE LE 9).BASEOK
MNOTE 8,'TOO MANY BASE REGISTERS SPECIFIED'
MEXIT
.BASEOK ANOP
&A SETA K'&LBL
&C SETA &A
&NAME SETC '&LBL'
AIF ('&TYPE' EQ 'PLI').PLI
AIF ('&TYPE' EQ 'ASMPLI').ASMPLI
AIF (&A/2*2 NE &A).ALIGNED
&NAME SETC '&NAME'.' '
&C SETA &A+1
.ALIGNED ANOP
&B SETA ((&C+2)/2)*2+4
&LBL CSECT
B &B.(0,15) BRANCH AROUND PROGRAM ID
DC AL1(&A) ..
DC CL&C'&NAME' ..
STM 14,12,12(13) SAVE REGISTERS FOR CALLER
BALR 12,0 GET BASE ADDRESS
AIF (&BASE LE 1).BASED
&CNT SETA 1
&BSNUM SETA 11
.ANOTHER ANOP
&BS SETC '&BS'.',&BSNUM'
&BSNUM SETA &BSNUM-1
&CNT SETA &CNT+1
AIF (&CNT LT &BASE).ANOTHER
.BASED ANOP
USING *,12&BS IDENTIFY BASE ADDRESS
AIF (&BASE LE 1).FIN
&CNT SETA 1
&BSNUM SETA 11
&BSPREV SETA 12
.LANOTH ANOP
LA &BSNUM,4095
LA &BSNUM,1(&BSNUM,&BSPREV)
&BSNUM SETA &BSNUM-1
&BSPREV SETA &BSPREV-1
&CNT SETA &CNT+1
AIF (&CNT LT &BASE).LANOTH
.FIN ANOP
LR 2,1 SAVE PARAMETER LIST POINTER
GETMAIN R,LV=80 GETMAIN SAVE AREA
ST 13,4(1) CHAIN SAVE AREAS
ST 1,8(13) ..
LR 13,1 POINT TO NEW SAVE AREA
LR 1,2 RESTORE PARAMETER ADDR LIST POINTER
MEXIT
.PLI ANOP
AIF (&A/2*2 NE &A).ALIGNEDP
&NAME SETC ' &NAME'
&C SETA &A+1
.ALIGNEDP ANOP
&B SETA ((&C+2)/2)*2+4
&CSECT CSECT
ENTRY &LBL PROGRAM IDENTIFIER
DC CL&C'&NAME' ..
DC AL1(&A) ..
&LBL STM 14,11,12(13) STORE REGISTERS
BALR 11,0 GET BASE ADDRESS
AIF (&BASE LE 1).BASEDP
&CNT SETA 1
&BSNUM SETA 10
.ANOTHERP ANOP
&BS SETC '&BS'.',&BSNUM'
&BSNUM SETA &BSNUM-1
&CNT SETA &CNT+1
AIF (&CNT LT &BASE).ANOTHERP
.BASEDP ANOP
USING *,11&BS IDENTIFY BASE ADDRESS
AIF (&BASE LE 1).FINP
&CNT SETA 1
&BSNUM SETA 10
&BSPREV SETA 11
.LANOTHP ANOP
LA &BSNUM,4095
LA &BSNUM,1(&BSNUM,&BSPREV)
&BSNUM SETA &BSNUM-1
&BSPREV SETA &BSPREV-1
&CNT SETA &CNT+1
AIF (&CNT LT &BASE).LANOTHP
.FINP ANOP
LR 2,1 SAVE PARAMETER LIST POINTER
GETMAIN R,LV=80 GETMAIN SAVE AREA
ST 13,4(1) CHAIN SAVE AREAS
ST 1,8(13) ..
LR 13,1 POINT TO NEW SAVE AREA
LR 1,2 RESTORE PARAMETER ADDR LIST POINTER
MEXIT
.ASMPLI ANOP
ENTRY PLIMAIN
PLIMAIN DC A(&LBL)
AIF (&A/2*2 NE &A).ALIGNEDA
&NAME SETC ' &NAME'
&C SETA &A+1
.ALIGNEDA ANOP
&B SETA ((&C+2)/2)*2+4
&CSECT CSECT
DC CL&C'&NAME' PROGRAM IDENTIFIER
DC AL1(&A) ..
&LBL STM 14,12,12(13) STORE REGISTERS
BALR 11,0 GET BASE ADDRESS
AIF (&BASE LE 1).BASEDA
&CNT SETA 1
&BSNUM SETA 10
.ANOTHERA ANOP
&BS SETC '&BS'.',&BSNUM'
&BSNUM SETA &BSNUM-1
&CNT SETA &CNT+1
AIF (&CNT LT &BASE).ANOTHERA
.BASEDA ANOP
USING *,11&BS IDENTIFY BASE ADDRESS
AIF (&BASE LE 1).FINA
&CNT SETA 1
&BSNUM SETA 10
&BSPREV SETA 11
.LANOTHA ANOP
LA &BSNUM,4095
LA &BSNUM,1(&BSNUM,&BSPREV)
&BSNUM SETA &BSNUM-1
&BSPREV SETA &BSPREV-1
&CNT SETA &CNT+1
AIF (&CNT LT &BASE).LANOTHA
.FINA ANOP
LR 2,1 SAVE PARAMETER LIST POINTER
GETMAIN R,LV=80 GETMAIN SAVE AREA
ST 13,4(1) CHAIN SAVE AREAS
ST 1,8(13) ..
MVC 72(8,1),72(13) COPY PL/I SLOTS
LR 13,1 POINT TO NEW SAVE AREA
LR 1,2 RESTORE PARAMETER ADDR LIST POINTER
MEND