REFERENCE MATERIAL FOR CCS 476 AND CCS 573 L. K. Flanigan W. E. Riddle Department of Computer and Communication Sciences University of Michigan Fall/Winter 1972-73

d; (Etion 67 j 042~k~

PREFACE The reference material in this volume is an amalgam of two sets of notes: a set prepared by Professor Riddle for CCS 476; and a set prepared by Professor Flanigan for CCS 573. Since the two courses each provide lectures on System/360, we decided to combine the two sets of notes into one volume for both courses to use. The bulk of this reference material will be used in both courses; some individual sections may be used directly by only one of the courses. This material is designed to provide backup, reference material for the course lectures; it is not self-contained, and it is not designed to provide self-instruction or to aid independent study. Frequent reference will be made to this material in the lectures, and students are therefore encouraged to carry these notes to the lectures in each course. We also hope that this material will serve as a reference to basic System/360 concepts throughout the course, thereby reducing the need to peruse the IBM manuals and the MTS manuals. We would appreciate any comments, corrections, and/or suggestions generated by this reference material. L. K. Flanigan W. E. Riddle i

TABLE OF CONTENTS Page I. INTRODUCTION TO SYSTEM/360 I.1 II. FIXED AND FLOATING POINT INSTRUCTION SETS II.1 III. BRANCHING INSTRUCTION SET III.1 IV. INTRODUCTION TO ASSEMBLER LANGUAGE IV. 1 V. DECIMAL INSTRUCTION SET V.1 VI. LOGICAL INSTRUCTION SET VI.1 VII. EXAMPLE PROGRAMS VII.1 VIII. INTRODUCTION TO MACRO ASSEMBLER VIII.1 IX. STATUS SWITCHING INSTRUCTION SET IX.1 X. I/O INSTRUCTION SET X.1 XI. THE U. OF M. SYSTEM/360 MODEL 67 XI.1 XII. EXCERPTS FROM MTS VOL. 3 XII.1 ii

1.1 BASIC SYSTEM/360 STRUCTURE: UNITS I/O UNITS MAIN. g CONTROL UNITS 1 — I CONCEPTUAL CPU-STORAGE ORGANIZATION: STORAGE ADDRESS MAIN STORE INSTRUCTIONS OPERANDS (DATA) iCONRLee- GENERATED r ~-.~ED VARIABLE FLOATING I CONTROL ADDRESS POINT LENGTH POINT L_ _ (PSw) 16 L GPRS FPRS o0,1,..oX, 1o5 O 0 2,4,6 FULL WORD DOUBLE WORD

1.2 MAIN ST)RE -- DATA TYPES F I'XED UNIJTS: BYTE = 8 BITS HA.LfWORD 2 BYTES FULL WORD iWOT. RD 2 HALI,(WOLDS hL BYTES DOUBLE TWORD W: 2 BWORTS = 8 BYTS.i,DATA TYPES: FIXED POINT GHALFWORDJ GULL WOIt FLOATTNG POINT W-. ORD~. DOUBLE WORDn,, EXTEIEDJ (16 BYTES) DEC InAL - I DCIGITS + SIGN (UP? -TO 1.6 BYTS S CHARACTER 1 TO0 256 Ci-HAL —RACfTjR ( BYR T ES) FIXED POINT FORMA. T:e Yo + HALFWORD FULL WORDS 1X-... z 31TAXIM.M POSITIVE: 7FFF!FFFF 2=:UiL7:, 83,6)4? (32767) IMAX NEGATIVE: 8O00000 2 2127 183 61L8 (-32768) FLOATING POINT FORMAT: SHORT l 1 i-& 31 7 DEC PLACES LONG ~ SI < L s $zO w63. 17 DEC PLACES CHARAC TER E TIC I tA.C C T IOC)IE EXTENDED: DATA TYPE IS lWO LJONG FATIG LIG [OINrT NUiTLBERS VALUE: S(,FRA CTIOJ16 ) i6 (CAJ'CTERiST::... ICi.) RANGE (5, 4)10"79 ( 7y?.2)105 CHARACTER FORA T: ONE CHARACTER = ONE.i BYT.E HUS UP TO 26 D STI NCT CO RACT'IRS SAMPLE EBCDIC ENCODINGS: o- 9 FOF9 - g... t 0 A-I Cl1-09.0 B J-,R Dl-D9. L-t 50 S-Z E2-E9... E rr 71?p ~en g

I.3 DECIMAL FORMAT: ZONED FORMAT: Z D Z D Z D Z D _S D Z = ZONE = HEX F D = DIGIT = 0 -- 9 S = SIGN -= + HEX C (1100) - HEX D (1101) PACKED DECIMAL: D D D D D D D D D S D =.DIGIT = 0 -- 9 S - SIGN = + HEX C (1100) - HEX D (1101) UP TO 16 BYTE LENGTH - UP TO 31 DIGITS + SIGN EXAMPLE: +684 -684 FIXED POINT FORMAT 000002AC FFFFFDSh FLOATING POINT FORMAT 432ACOQ C32ACO00 PACKED DECIMAL FORMAT 0000684C 000068hD ZONED DECIMAL FORMAT FOF6F8C4 FOF6F8D4 CHARACTER STRING lEF6F8F4 6oF6F8F4 /0 CONVERS IONS: SCARDS, READ SPRINT, WRITE CHARACTER STRING PROGRAM (MOV SIGN) ZONED DECIMAL PACK | jUNPK PACKED DEClIAL CVB jCVi FIXED POINT N" O TIN'~ ~BY PROGRAM FLOATINJ POINT

I.4 CONCEP".JAL CONTROL SEQUENCE: I:-LR = INSTRUCTION LOCATION REGISTER -- CONTAINS THE ADDRESS OF THE FIRST BYTE OF THE NEXT INSTRUCTION TO BE EXECUTED (HALF WORD ALIGNED) 1. NEXT INSTRUCTION FETCHED FROM STORAGE AS SPECIFIED BY ILR 2. ILR UPDATED BY LENGTH OF INSTRUCTION FETCHED 3. INSTRUCTION DECODED IN CONTROL'UNIT 4. INSTRUCTION OPERANDS FETCHED FROM STOTA GE, IF NECESSARY 5, INSTRUCTION EXECUTED USING SPECIFIED OPETRANDS 6. RESTART CYCLE -- GO TO STEP 1, INSTRUCTIONS FETCHED SEQUENTIALLY FROM STORAGE EXCEPT FOR BRANCH, INTERRUPT, OR STATUS SWITCH. INSTRUCTION FORMATS: TYPE BITS 0,1 RR 00 OP RI R2 SI 10 OP I2.] Dl ~~I j~~i I I RX 01 1 OP _L2 LB *: 2 D RS 10 BE HALFWORD ALIGNED D RRRX RSS-,IM.~'IEDB OP COD ^IkONE OP F EAC TYE - SS 11IN UCION I T EL a a L t a a a a a a INSTRUCTIONS MIUJST BE HALF WORD ALIGNED. ADDRESS COrMUTATION: R:Re N(:EE N. <, Y SP9ECIFY GIPR>3 IF NONZERO;D IS FROM RX: D + C( B + C( x) S TtrUl:cTION ITSErLF A.DDRESS COMPUTED RSSISS~ r0G(B) tPRAO TO,INSTvrUCETION EXECUTION OPERAND LEN(3 TH U FEC IF]. i iA iITK3 RR,RX,RISSI: LPLIED BY OP COI)E ONE OP FOR EACH TYPE AND TLENGTH SS: SPECIFIE EN L ENGT F EtLF(S) OF INSTRUCTION ITSELF

I.5 PROGRAM STATUS WORD (PSW): SYSTEM~dl MASK KEY AMWP INTERRUPTION CODE O 8 12 16 31 SYSTEM MASK: BITS 0-6 MASK CHANNELS 0-6, RESPECTIVELY BIT 7 MASKS EXTERNAL INTERRUPT (TIMER) O = MASKED; 1 - UNMASKED KEY: S TORAPGE PROTECTION KEY 4 BIT STORE PROTECT -- 1 BIT FETCH PROTECT MAY PROTECT BLOCKS OF 2048 BYTES PSW KEY MUST MATCH STORAGE BLOCK KEY IF USED AMWP: A (12) 0 = EBCDIC; 1 = ASCII M (13) 0 = MACHINE CHECK MASKED; 1 = UNMASKED W (14) 0 = RUNNING STATE; 1 = WAIT STATE P (15) 0 = SUPERVISOR STATE; 1 = PROBLEM STATE INTERRUPTION CODE: THIS IS INFORMATION STORED WITH THE PSW WHENEVER AN INTERRUPT IS ACCEPTED BY THE CPU. THE INFORMATION DESCRIBES T1IE CAUSE OF THE INTERRUPT AND DEPENDS UPON THE TYPE OF INTERRUPT. <LC cc PORMINSTRUCTION LOCATION REG-ISTER (ILR) 32 34 36 40 63 ILC: INSTRUCTION LENGTH CODE = LENGTH OF CURRENTLY EXECUTING INSTRUCTION IN HALF WORDS (2 - FULL WORD INSTRUCTION) CC: CONDITION CODE -- SET BY ALL TEST AND COMPARE INSTRUCTIONS, MANY ARITHMETIC INSTRUCTIONS, AND SEVERAL OTHERS., TO INDICATE RESULT OF THE INSTRUCTION EXECUTION; CC MAY ITSELF BE TESTED FOR BRANCHING PURPOSES PROGRAM MASK: BIT 36 = FIXED POINT OVERFLOW MASK BIT 37 = DECIMAL OVERFLOW MASK MAY BE SET BY NONBIT 38 = EXPONENT UNDERFLOW MASK PRIVILEGED USER BIT 39 = SIGNIFICANCE MASK ILR: INSTRUCTION LOCATION REGISTER -- EXCEPT FOR STATUS SWITCH OR BRANCH OR INTERRUPT, NEXT INSTRUCTION TO BE EXECUTED IS BY DEFINITION THE INSTRUCTION LOCATED AT THE ADDRESS IN TIHE ILR NOTE: IN CASE OF MUJLTIPLE CPUS IN THE SYSTEM, EACH CPU HAS ITS OWN PSW.

1.6 INTERY JPT CLASSES: MACHINE CHECK INTERRUPT PRIORITY PROGRAM OR SVC PROCESSING PRIORITY EXTERNAL' I/O CPU INTERRUPT PROCESSING: CPU PROCESSES INTERRUPT WHEN IT ARISES IF THE CPUJ IS IN A STATE OF ACCEPTING INTERRUPTS AND THE SPECIFIC INTERRUPT IS =NOT MASKED. CPU PROCESSING IS AS FOLLOWS: 1. CURRENT INSTRUCTION IN CPU IS ALLOWED TO FINISH IF POSSIBLE 2. CURRENT PSW IS FORMED WITH APPROPRIATE INTERRUPTION CODE 3. CURRENT PSW IS STORED IN OLD PSW LOCATION FOR INTERRUPT CLASS 4. PSW FOUND AT NEW PSW LOCATION FOR INTERRUPT CLASS BECOJES CURRENT PSW NOTE: IF MASKED, PROGRAM INTERRUPTS ARE LOST, WHILE I/O, EXTERNAL, AND/OR MACHINE CHECK INTERRUPTS REMAIN PENDING. OLD AND NEW PSW LOCATIONS (ADDRESSES IN HEX): OLD PSW INTERRUPT CLASS NEW PSW 18 EXTERNAL 58 EACH LOCATION IS DOUBLE 20 SVC 60 WORD; FOR MULTIPLE CPUS, 28 PROGRAM 68 EACH HAS A UNIQUE SET OF 30 MACHINE CHECK 70 OLD/NEW PSW LOCATIONS. 38 I/O 78 INTERRUPTION CODE: MACHINE CHECK: CODE IGNORED SVC: BITS 21h-31 SET TO SECOND BYTE OF SVC I/O: BITS 21-23 SET TO CHANNEL ADDRESS BITS 24-31 SET TO DEVICE ADDRESS CSW (LOCATION L0) ALSO STORED EXTERNAL: BIT 24 = TIMER BIT 25 = ATTENTION KEY BITS 26-31 = EXTERNAL SIGNALS 2-7 PROGRAM: 1 = OPERATION 2 = PRIVILEGED OPERATION (M) 3 = EXECUTE (EX) 4 = PROTECTION (P) 5 = ADDRESSING (A) 6 = SPECIFICATION (S) 7 = DATA (D) 8 = FIXED POINT OVERFLOW (IF) * 9 = FIXED POINT DIVIDE (IK) A = DECIMAL OVERFLOW (DF) * B = DECIMAL DIVIDE (DK) C = EXPOET OVERFLOW (E) D = EXPONENT UNDERi.fLOW ( I), E = SIGNIFICANCE (LS) * F = FLOATING POINT DIVIDE (FK) (*= MAY BE MASKED IN PROGRAM MASK)

S1MA NTT'S OF TEF SYFTFM/&7O MACHr4TNP TNSTPRC~TONrN Eaeh of the followlng sete.i..o' of thbee rFfrrnee r o, ts t eovw:rs n. difforrert sibspet t! + he Systfm/!'O machlrt~ 4 nstr't1et on, A.t the bepgirrnx of eanh.of th e. sectionns (,,r,,-eept ti'e seot-lon on th47 j~ ltl. t 5l +'n.~otie oS?all o f tf+' lnStrAne ttonrs rovored -" 4hl'+~ SeoCtior' are Istr(ied 0aeh.ieab 4'tSt r1v:toJrOn is r1ven it'. - h,~le'r TanrgmtaXg f'n or!ma+t an I ndier'at.'iOn of whetber or not I +'-t- eyentor.' -fee h +.etop+r r- f' the nond.itf on code (if' the instr..tte~ n. prrefa-ed w4ith a'*' then f+. dlnes affeet'he ~?ttin-g of the condi.tion'noiae) 1 ra a" pxrlanatlorn o the.emantle"'s te h' n~t~t.r tion, The,em erte.jt nf t~e -is.+..,,tleti.ons are rl.-a.' ed by showirnff t+hei- effeelt. or +be va.3..is in re..sters n.d In f tor-arrp'Xn terms$ of +,he prmat vt ca.,-ri-d otr on these valun1op. 1~ Mn "+ s,. +.he oe rat,.on' anre P.mpl), and s eo.sre..Yond1~.~,I. y s~lm.e de.osn.~.on o' +he operation is all that. is redLed., These de.se.r?_.. a-re gi.vrn in {hG nota+ion di o.e..soed on t he rnet.ew Tinges S ome of the It.s+rt r.,.o4n s hRve a rather comnp.er effec.t..nd. for thes, short:rora ms.r.n eawsi.ly'tIrir..tPood algor' thmine programming language, emnloylvng statements enmPros&ea from the notatIfn deserbS.d below as wepl1 as mor.e nor"a.]. progamm ]s.n?,1ar.er statement+s, are presented Nota+.lon for dC. __..n. seman.tis Pr..ed-.f i.ned symbolls, B-, X, D, L T, M and L ar.e 1i.. e..Zd and the, h.ve +-he Rame mptanri ng as In the POOP manulal Whether R, derotes a. e..n er l O.rTrse or fl.oatinr npoi..nt rvegster is determined by context, G Pr. referPs t.o thoe sette ~clc gneral mrrtroiT, r.pmit.+.t witth name na * ff' r.fers +,o,he + tvo-bt+.. eorndit.tion cede.reg4~te r which. Is part of a.he TAR ref'rs to thee "h-bI.t It t!;l,-r ction address. roTIster swhc7 ) al s'n xrar-t o fr t he.PW,,Y P.W refers +fo the 64-bit program stat+us (douih1.e)w:rd, * AlT nllv."brs srh'Xl.d b orst-d?- t pE e decmal< 7rsvmrs v'nloies sn.cif.ied otherwis, by g.vi.n, the.Olx,y et +th4',1mer s3vte-'m.- -, *~..51+~. f. at~ the end of th,~ n.umbe.r, Tempo_.erv?oc,,+. ons ar. e. defined as neeid. A,- ~ -~? ind"~termo.d.!v.$. r,,ilts, They are dscript+,ivev "amed (~,e +~.n. cowut+v etfr e

2 Des erption. of. hasi peratt ons ~nmbe..g of wv r o...-+.oeo of ore of? tres et.aly "1r(4g ran T)O-" r+r ~e of 4^;5 vs 4 @"- fo, r.r k-'dd reP P.I i-.;tiTOot.n ~, thr: na.m-' re oeb' X8-rlrur-pose rr tors o"' h }er''ro' nbe't rr (Nf' fotr 4 "'-"'~. n ry rs * -nd v nm'e n t w'tF'+ PCPOOP aintil-IT, dt-e0 n Odres', se- rdb 3?ar+ plt nprr ul'menr of whj. -h onr.' I +. 1w ~w,-rOe.-r L.-tt,, a re, tl....ly vahlue stad r l. n-b -it-'t bl.iry ni.w r, where the sh eP r aAnd the. n-terat+. L.aon sf' f~dtel withn ~E -s!4 p <.s<5 d (eg,, r.n addrzsr a.1.i.thmeti.e the nhmbtr-e, nrt- 2-?it4+ ornes, in f..xed ibna.ry.....+.h.. t.hvf ar' 3'2it on'- wt.h. t he dk~mnr**Wn 4 2 or; o< Stqr r4 ~)o ard an I-rtpreer f l1p p ete w then +he bh..Se oTr?*,".on are,, (dAdr) t he resl +it nf th e T rpet io n n -vai ie, ramel that stored,..+. +_.,e 1rnead+.n Sre.f.ed by t*he add rest * iAd-SH'}, this ntrerati, n l4 Ijm..+s attentlonn t.o the selpeted bit pnos I.t.ons (w ith r lm.r-_nr f' ror the.ef, -ta.!.rtn t: r +, t,ero) w!+t r p he ~ h t. d at +.he se1f i.ed add. re s some o& +-,e decimal Ins+.zrctIons, the i-j asi bsoepts denote +.he bytes ra-fther than the bt+.s which,,f.oe of tntee.s+. -- thi will be.spparnt from context * [UreJG7 ~l t.+he Vr7Thl' zeron lf reV i zero; ntherwise-?t is r \vallheJ1ii. thiis opeTr.ntion ha. Thb ef eet of truncating bits by seleotin~ out biMt proslt o+.ns withi.n the binary repTrsentation of the va ueS; as with'add ]._j the i-j s,,hbsrve pt' s sonmeim~e. dienon.te h3rt pe'sit.l non *._e.~,re~. ervs toF denot; e +.the elren-odd..egster ~.l.r which star+s with -,?

3. valiet means that the value,i a 16-bit b.nary nutmber and should be, expanded iFnto a 32-bit binary number by extending the sign-hbt i.nto the high-order 16 bit positions * tPval1e' denotes the two's-nomplement oaf~ the val]ue. tvaluel denotes the abolute v.a.lte of t+he value * <valle> denotes rorpali,atinn of & fl.osnting-polnt nmrber. value -~+ addr reflects the operation of st+.orin the valute at+ the specified address; the wi.dth of the fieltd used at the spneTified tloeaior Isnn I-t.lit ned by the si-ze of the valut-t and/or the tyrp of the ins+trulction vle {denotes somwhat the sm operatinn exept thaft the va.. lue s stored in the subfieldd b.tween bit positionS (or by+,e ~politn+ln in some instances) f and of + he addresased location convertj value.F I- addr alson denotes somewhatf the same operat+ inr except that the value _is converted from a number In the number sst+e. with radix i into one in the nulmber sy,,Ast.em with the radiwx i value * b-..-. denotes a right. shift ohera+e.on the bi, in 4*he {addr}-_ sel.ected su.bfeld of the f.ild,+.t tohe specified ].ona+,.on ar. shi.fted rivght, the nutmber one bit, Positior.s given by value: +h bhit b (either zero or one) is sMhtfted into the va.eca+',d po.tl$ontns at the left-hand end; bits shi.ft.ed out of thle ritght.hand end are, dropped val. t,. *........ b denotes a lofft shift oreritior, taddrh1 * ~, -.,*, / integer arithmetic or floatincf-noint. ari;thmetice operations depending p9on the contex+. where used (note thatf the Ireviously defined use for prventheses precludes thetr use fo.? o._erl.ng the operati.ons tIn an expression -- +he opr.trors have +the normally defitned n.recedeve and parentheses' are never used to mear an nve.rriding of fh.ts preceden e)

4 * +16 modulo-16 additIor e.*, O logical arithmetic on 3?2-bfit unsigned vallues * At, V, the logical operators. and, (inclusive) or, and exclusive or

II.1 FIXED POINT ARITHMETIC INSTRUCTIONS LR R1,R2 (R2) -R1 L R1,D2(X2,B2) ([B C+ [X +D2) R1 LH R1,D2(X2,B2) (LB2]+~X23+D2)t+ Ri * LTR R1,R2 a. (R2) - R1; b. _ (R, tO Set -sCC f(se c', * LCR R1,R2 (R2)' -2'R1 * LPR R1,R2 I(R2) R -* R1 * LNR R1,R2 I(R2)1' - R1 LM R1,R3,D2(B2) a. CB2j+D2' temp b. determine n such that R1 +16(n)= R3 c. ~temp))- R1 1 ((temt)4)- Ri +16 1 (Itempr8) -* Ri +16 2 ((tem)t4*(tr)- R1 +16(n) LA R1,D2(X2,B2) a. [B2)+1X22+D2 4D R118-311 * AH R1,D2(X2,B2) (R1) + (B2 +EX +D24)- R1 * ALR R1,R2 (R1) + (R2) - R * AL R1 D2 (X2 B2) (R1) + ( B~1 + X2 +D2).R1 * SR RR2 (R1) - (R2).R1 * S RD2(X2,B2) (R1) - ([B2+[X23+)+D2)R * SH R1,D2(X2,B 2) (R1) ( +xB2SF[X +D2)1RR1 * SLR R1,R2 (R1) - (R2)*R1 * SL R1,D2(X2,B2) (R1) - (rLB21+j[x2+D2) - R

II..2 MR Npt) 0. ece Akad R, bcvev ltw. C,.WAo vAc M a,@zatB, S Q eZlwck. itjC+?,!u CYJ tc\;cxitula r dJo~ (I f t 1, 0(YE2 )I q8 t itRl ti. t~srje Va,'r iit\t \s e.sve\~ fWseM4Ucre le 5 oe9 bc (Ra) R*, c (za,es4)-)- ot ItiR~jo Q _ *- 4s Ps.-s &'- Q:!rtt)'+- K;,. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_~ RJ'% a.....~ ~.: i1

x* $tbA 0Rp, (1) a CK ~ F, Q vl4tc P,'4osg. -iUtsc ktet C. Ik I6- 3 K, fB1>34Dr-Bt; bk dc2zAvx\uit vt t Y-. (R,+,Qv) -At(j)4, s- @R IZ,,k, (S (Q\) W- t't) 4vt 8A @jC * C g (R tK 4(Rj) 4t ORZ elset z~cz

II.4 * C Q,.9tftt) 6C It l', b. l cez,,)-( i~e >)b-> ~j)CC ef (k>(Ae)PX Z' wO>CC *. l&14)y —BT bt O -*Q CC bc e ->.~rXr) rase Is < Se Z~!6FCt\ctlp) CP _* @~~~~~~~~'s icel~ )D2 - XL5 9 t d8l zlt5Z;tDt'N \srix r~air iGln i (Vt ~ ~ ~ ~ ~ ~ ~~ YILIC~ ___

f-Y~ ~ ~ ~ ~ ~~~~~~~f 4v~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~( A I -~~~~~~~~~~~~~~~~~~~.~~~~~~~~~~~~~:7 AA4 -=~ ~ ~.: N 0 ~' d F~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C f w' LL,.),f,8,, i f,i'' - %...< - W 2r / > ro 7. 4.' C * 4,.- @ J Lo @,, sq, S_ o wo N _ 7.M "- Y - z -4-A _ -F = a Fa W, As>z; piL *A4..4 4< *~~~~. * ~, ~~, ~

116 ""~~~~~~~~~~~~~~~~~~~~~~~~~. A " N;'4 *CI~ X'2R P U'Ia P Ij K<jr (V ) - u'* 1 t KI?,'-V laid~~~~~~~~~~~~~~~~~~~~~~~~~~~~~d;3~~~~~~~~~~~~~ n "~~~~~~ >4) 3' LW I jt EQ'-k K.'',$ r a~~~ fA At a' il ioR1 k"11 V,' 5A tCy A, t * bW.9-1 R S Cx, k S',*;s'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~A' Pt r ~~~~~~~~~~~~i*F 0 < W L',l(2W78-r a it ri F' I X 3 i D )R "4k~~ 4'SX R~ AiX <;E W~~~~~~~~~ NT 5S,,T c )i), b'lB?- Rk\er 9 23 9 \)>t;<3-.t~~~~~~~~~~~~~~~~~~k'"'2%it ~ ~ ~ A t t ) D [84 2 3 ~~~~~~~1~9> >4tt,+5 >,Wi tA~s tvZ R | k-~~~~~~~~~~~~E~~ ~ r; =? mar, si 6 Lt X SX L A <~)?i~ r:'1(rIi:r~ ML~~~~~w i *t'rV A P i a.ti L i n ~~~~~~s~~ si'~r J' 1 $':;~.:~, 1 3 4 \ j'}\~ 1', 1"1? 4>~~~~~~~~~~~~~~~~~~~~t.,.,'~-i 4'~~~~~~~~~~~~~~~~~ A ~ ~ ~ ~ ~ ~~~~~~~~~~~~a, Y~ ~~~~~~~ ~~~f i~~~~

"I.7 * CD Rf3Da,(.8~,. b. F~ (Q~) =- CteL9p) StUe O te else,~ C9s (ED (tea 4 - fL1% e Z3 ~en

II.8 PROGRANi EXCERPT 1:4 fOMPITE ((A+B)*(C+D))/(A-D) WHERE A, Bj C AND D ARE UiLL WORD FIXED POINT NUMBERS STORED IN CONSECUTIVE SFULL WORDS.1X STOR LGE AND THE ADDRESS OF A IS IN GPR 15, T, 3 o(,15) A TO GPR 3 A 32L( 15).ADD B TO GPR 3 J GNPR 3 - A+4B L 2,8(,15) C TO GPR 2 A 2il2(,15) ADD D TO GPR 2, GPR 2 = C+D Im 2 2 (A..+B>)(C+),TO GPRS 2 & 3 L l00,o(,l5) A. TO GPR 10 S 0,12(,15) SU'BTRACT D FROM GPR o0 CGPR 10 ) A-D DR 2, 10 RESULT TO GuR 3 ST 3,16(,15) STORE RI:i-SULT AFT.ER D 1 N STORAGE PROGRAM EXCERPT 2: SAME AS PROGRAM EXCERPT 1 EXCEPT THAT A, B. C, AND AFRE NTOW FULL WORD FLOATING POINT NUMBERSO LBE 0O,(.5) A TO PIR 0 ABE o:h(.,, ADD B TO0.FR CO R A.Y.. 0 A+B LE 6,8(:L15) C TO FPR 6 AE 6,12(..15) ADD D TO FPR 61 FPR 6 C+D MER 0, 6 FR 8 (A.DB) ( +C1 LE 6o 9o( J) A'U70 F?P, 6 SE 6112(is5) SUBTRACT D.,)ROM FPR 6: FyR 6 c.D DER 0,6 RESULT TO FPR O STE O,i6(15) ST)ORE RE~tSULT. AFTER D IN STORAGE NOTE: IN ABOVE TWO EXCERPm'T. FIEDS B AND X AIWAYS r-EiR O G PJ S E ADDRESS COMPUTATION IS DON)E IN GPRS FOR ALL INSTRUCTXONS REiQUIRING ADDRESSE" IN\ STORAGE, THE R FIELD'S IN FIXFD POINT jISTRUSit.f.I,.S SClorz~,I~ GPR5 7 3NCE FIXEDP POINT COMBUT"A.TON Io DONE TH.,ERE. BiUjT t'i:I; R F~3E3D3S 15M FINOAI NGi POINT INSTRUCTIONS.RExR TO FPRS, SINCE FLSO ATXLCT OIINT flTCMuiUTI)N TS DONE THERE. IN EITHER CASE, OP ERAND LENGTH IS ItNEJ!JENT5 Wi'T1 THI-E SPEC EIFIC MACHINE INSTRUCTION USE 9,

II.1 t3kAWC~s IN C~r IK$ Ji oflO NS. t cse, tC C I.,= O,. 0, 0 rcwd. C CC1g (,' tO +Jco OOt2- - tia C 0o a 2'~ Co'c w \a, If TS CR A tLtA + {fr82 + CX +D tAR bAc~r-p: P(|> a,; i (R;9~,)},s2~, V+';. vd2 (VY) t (.aAR. o 1>Et~t't~b Y' (r taa o +' L)1"; > IQAIQ) <^ (4 P)4_1 V Ask

III.2 (2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gs? ~ - ~ I~3~ e.;,P " iV if. X,]e b 3- t ~ *. )>A p ~~~Y~~~~~6'~~~~~~ ~ tji,e; $ tR-~ (?j ";4 t ~ xr. a~ L t~jvt;Ef tt W;4i fa,,p; t,,Z i... -." ~",t~.4.wI r I.> <N~ Z;2 5.r4 t3 K —:) C WEu~~ ip~ tR ii? -; X t z;;., —r? b ~?!r' Ui P a - 5 9.1oi t 4">,,)- efgg~Sa 9 e,,.'' >4,` i;V ( ) +v t t W $

III.3 PROGRAM EXCERPT 3: COMPUTE IN GPR 6 THE SUM OF THE 100 CONTIGUOUS FULL WORD FIXED POINT NUMBERS STORED BEGINNING AT THE ADDRESS IN GPR 9. LOOP CONTROLLED BY A BCTR. LA 10,99 99 TO GPR 10 L 6,o0(,9) FIRST # TO GPR 6 BALR 15,0 SET LOOP ADDRFSS A 6,4(,9) ADD NEXT # TO SUM LA 9,4(,9) UPDATE VECTOR ADDRESS BCTR 10,15 LOOP 99 TIMES PROGRAM EXCERPT 4: SAME AS EXCERPT 3, EXCEPT LOOP CONTROLLED BY A BXLE. LR 2,9 FIRST # ADDRESS TO GPR 2 SR 6,6 O TO GOPR 6 LA h, h TOG -PR h LA 5,396(,9) LAST # ADDRESS TO GPR 5 BALR 15,0 SET LOOP ADDRESS A 6,0(,2) ADD T-EXT # TO SUM BXLE 2,,0O(15) UPDATE ADDRESS AND LOOP PROGRAM EXCERPT 5: SAME AS EXCERPT 3, EXCEIPT LOOP CONTROLJELTD DY A BI)~. SR 2,2 0 TO PR 2 LA 5 s96 396 To GPR 5 LA, L T'O G PR 4 L 6,0(,9) I.PT T " TO GPP 6 PALR 15,0 SET 90? AlD'RESS BXH 2,( 15 ) ITCR ENT,AND 7.T A 6,0(2,9) ADD NEXT # TO SUM BCR 15,15 LOOP BACK

PROGRAM: PROGRAM: a. initions MACRO-PROCESSOR text with (rest of) btextiwithn (part of ASSEMBLER) subroutines: ASSEMBLER b. text with process references to: a. in a library expand symbolic i, subroutines b. in another names assembly a. in a library translate b. in another c. already in core al r assembly i. in MTS c. already in core ii. in UMMPS i. in MTS ii. inMACRO Libraries 2. macro's *OSMAC and *1 private text of *MACGEN NcOrO' S

MODULES from this g assembly L mWRV M rLBORA MMMRY I routhies text with:-,L ER01FE (rest of) PARTS OF a*S a holes" for load and fix-up I PROGRAM ASSEYM~~E actual addresses fixuo;3n symbolic @i~~~sre~b. SVC instructions D ixuo UMM' nai~$ ~P~ne S'2. list n; iaes of BAL $ refernced sub- SVC 1lnterrupt InMTS ~ ~ ~ ~ ~ ~ ~ ~~~~~T asi Jies f La. -ry Libraries1 b. in anthr nmeadr LWMM n=%swm m= MW, for ~~~~ ~ ~ am t~l rpffiog assesubrout Sne I~~~~~~ub~~~c. alreadyv in core i~n WISfT L *MM 4=ft CIM~a cum am m MEM GM& MOM cmmt~ froPani other SUBROUTINE6E~ assemu~blies L." CM& 6vmP mom 49M M 4EM Mf faW&s' b 4es Libraries a i ~~CLIB3RARY L,, *SLIP Mod~ules pr~ivate subroutinesn ~ -d L

IV.3 ASSEMBLER ASSEMBLER SOURCE 3 j LISTING ASSEMBLER MACRO | 8 OBJECT MODULE DEFINITIONS) r OTHER OBJECT 4.- LIBRARIES: PUBLIC, PRIVATE MODULES LOADER DATA EXECUTION RESULTS ASSEMBLER SOURCE: 1. SYMBOLIC MACHINE INSTRUCTIONS 2o ASSEMBLER INSTRUCTIONS 3. MACRO DEFINITIONS AND/OR INSTRUCTIONS STATEMENT FORMAT FOR THE ASSEMBLER (DEFAULT): COLUMNS 1-71 STATEMENT COLUMN 72 CONTINUATION INDICATOR COLUMN 16 CONTINUATION COLUMN NAME FIELD: BLANK OR CONTAINS SYMBOL STARTING IN COLUMN 1; TERMINATED BY FIRST BLANK OPERATION FIELD: MANDATORY; 1-8 CHARACTERS; TERMINATED BY FIRST BLANK; CANNOT START IN COLUMN 1 OPERAND FIELD: CONTAINS OPERAND EXPRESSIONS IF NEEDED; TERMINATED BY FIRST BLANK COMMENT FIELD: THROUGH COLUMN 71; MAY CONTAIN ANY CHARACTERS; IF COLUMN 1 CONTAINS AN *, WHOLE STATEMENT IS TRFATED AS COMMENT ID FIELD: COLUMNS 72-80; FOR IDENTIFICATION AND SEQUENCING SYMBOLS: ORDINARY: 1-8 CHARACTERS, FIRST IS ALPHABETIC (A-Z,$,#,@), REST ARE ALPHABETIC OR DIGITS (0-9); RELOCATABLE OR ABSOLUTE; ATTRIBUTES INCLUDE VALUE AND LENGTH VARIABLE: FIRST CHARACTER IS &, FOLLOWED BY 1-7 CHARACTER ORDINARY SYMBOL; PRIMARILY USED IN MACROS SEQUENCE: FIRST CHARACTER IS., FOLLOWED BY 1-7 CHARACTER ORDINARY SYMBOL; USED IN CONDITIONAL ASSEMBLY

IV.4 OPERA) ID EXPRESSION: IEJVALUATED AT ASSEMBLY TIME RESULT IS 24 BIT ADDRESS, h BIT LENGTH OR REGISTER SPECIFICATION, 8 BIT LENGTH OR MASK SPECIFICATION, OR 12 BIT DISPLACEMENT EVALUATED WITH 32 BIT SIGNED ARITHMETIC AND TRUNCATED TO FIELD WIDTH COMPOSED OF SINGLE TERM OR ARITHMETIC COMBINATION OF TERMS OPERATORS: + - * / ( ) INTEGER DIVISION; NO MORE TIAN 5 LEVELS OF PARENS TERM: SYMBOL, SELF-DEFINING TERM, LOCATION COUNTER REFERENCE (*), LITERAL, SYMBOL LENGTH ATTRIBUTE (L SYMBOL), OR OTHER SYMBOL ATTRIBUTE REFERENCE. ABSOLUTE OR RELOCATABLE VALUE SELF-DEFINING TERMS: 24 ABSOLUTE TERMS; LENGTH ATTRIBUTE = 1; MAXIMUM VALUE = 2 -1 = 16,777,215; ASSEMBLED INTO INSTRUCTION RIGHT-JUSTIFTED IN FIELD TYPES: DECIMAL UNSIGNED DECIMAL INTEGER, 1-8 DIGITS IN LENGTH HEXADECIMAL X'n', n = 1-6 HEXADECIMAL DIGITS (O-9,A-F) BINARY B'n', n = 1-24 BINARY DIGITS (0,1) CHARACTER C's'. s = 1-3 CFHARACTERS LITERALS: SYMBOLIC D.ATA (OPERAND) REFERENCES; RELOCATABLE TERMS; ASSEMBLER COLLECTS LITERALS AND STORES THEM IN ONE OR MORE LITERAL POOLS; ADDRESS OF LITERAL IS ASSEMBLED INTO INSTRUCTION; LITERAL MAY BE USED WHERE ADDRESS IS EXPECTED, UNLESS DATA MOVEMENT IS INTO ADDRESS. FORMATS: =keyIvt NON-ADDRESS LITERALS; v = 1 OR MORE CONSTANT VALUES =key(a) ADDRESS LITERALS; a: ONE OR MORE EXPRESSIONS IN EITHER CASE, key IDENTIFIES THE SPECIFIC LITERAL TYPE SAMPLE TYPES, DEFAULT BYTE LENGTHS, AND DEFAULT ALIGNMENTS: A ADDRESS BYTES FW V ADDRESS 4 BYTES FW H FIXED POINT 2 BYTES HW F FIXED POINT 4 BYTES FW E FLOATING POINT 4 BYTES FW D FLOATING POINT 8 BYTES DW P PACKED DECIMAL VARIABLE BYTE Z ZONED DECIMAL VARIABLE BYTE C: CHARACTER VARIABJLE BYTE X HEXADECIMAL VARIABLE BYTE B BINARY VARIABLE BYTE

IV. 5 SIMPLIFIED ASSEMBLY PROCESS (IGNORING MACROS AND ERRORS): PASS 1: DEFINE SYMBOLS, COLLECT LITERALS, COMPUTE CSECT LENGTHS AND INITIAL ADDRESSES (DOUBLE WORD ALIGNED) PASS 2: PRODUCE OBJECT CODE ORDERFD BY CSECTS CONCEPTUAL PASS 1 FLOW: START INITIALIZE O.- LOC CTRS Gp~it-.-' ~ ~GET NEXT STATEMENT MACHINE INSTRUCTIONS ASSEMBLER INSTRUCTIONS hEND CLEAN UP & GO TO PASS 2 ALIGN LOC CTR TO HALF WORD DEFINE NAME FIELD SYMBOL -- EQU DEFINE NAME FIELD SYMBOL VALUE - LOC CTR LENGTH = INST LENGTH DC ALIGN LOCATION COUNTER, THEN COLLECT LITERAL IF THERE DS UPDATE FOR NEEDED BYTES ADD INST LENGTH TO LOC CTR CSECT SAVE CURRENT LOC CTR & GET -47 DSECT NEW ONE OUTPUT INFORMATION FOR PASS 2 USING UPDATE USING INFORMATION -DROP LTORG ESTABLISH LITERAL POOL CNOP ADJUST LOC CTR TO SPECIFIED ALIGNMENT ENTRY IDENTIFY ESD ENTRIES EXTRN LOC CTR ALWAYS CONTAINS ADDRESS OF NEXT BYTE OF CSECT TO BE USED. SOME ASSEMBLER INSTRUCTIONS DEFINE NAME FIELD SYMBOLS ALSO (CSECT, DSECT, DC, DS, LTORG, AND SO ON) * USED AS A ERM HAS VALUE ATTRIBUTE = LOC CTR AND LENGTH ATTRIBUTE 1

IV.6 C: NCEPTUAL PASS 2 FLOW: PASS 1 REI -T CSECTS UPDATE RLATABLE SYMBOLS GET NEXT STATEMENT MACHINE INSTRUCTION ASSEMBLER INSTRUCTION ALIGN LOC CTR TO HALF WORD END FINISH LISTING AND OBJECT DECK, DONI EVALUATE OPERAND EXPRESSIONS CHECK OPERAND ALIGNMENT, IF POSSIBLE -- DC OUTPUT CONSTANTS, UPDATE LOC CTR CHECK REGISTER SPECIFICATIONS OUTPUT OBJECT CODE - DS UPDATE LOC CTR OUTPUT ASSEMBLY LISTING UPDATE LOC CTR BY INST LENGTH ICSECT SAVE CURRENT LOC CTR; SET NEW IDSECT LOC CTR SUSING UPDATE USING TABLE ROP LTORG OUTPUT LITERAL POOL CNOP ADJUST LOC CTR AND OUTPUT NO-OPS NOTE: THE FLOW SHOWN FOR PASS 1 AND PASS 2 ARE CONCEPTUAL ONLY; ACTUAL ASSEMBLER PROCESSING IS CONSIDERABLY MORE COMPLEX AND DIFFERS GREATLY FROM THAT SHOWN,

IV. 7 ADDRESSING: EXPLIC IT ADDRESSING: USER SUPPLIES BASE, INDEX, AND DISPLACEIENT FOR ADDRESS FORMATS: RX D(X B); D(,B); D RS D(B;,D RS D(B5; D D, B, X, L ARE ABSOLUTE EXPRESSIONS SS D(L,B); D(,B); D IMPLIED LENGTH = L'D IMPLICIT ADDRESSING: USER SUPPLIES RELOCATABLE EXPRESSION -- ASSEMBLE CONVERTS IT TO THE PROPER BASE AND DISPLACEMENT AND INSERTS THEM INTO THE INSTRUCTION. FOR THIS TO WORK, MUST: 1. AT ASSEMBLY TIME, INFORM ASSEMBLER WHICH GPRS MAY BE USED AS BASE REGISTERS AND SPECIFY WHAT VALUES THESE REGIST WILL CONTAIN AT EXECUTION TIME; 2* AT EXECUTION TIME, MUST ENSURE THAT PROPER VALUES ARE IN BASE REGISTERS AS PROMISED DURING ASSEMBLY. EXAMPLE USINGS: 1. THESE 4 SEQUENCES ARE EQUIVALENT: BALR 5,0 S BALR 5,0 USING S+2,5 USING S,5 USING *,5 USING S+2,5 S BALR 5,0 BALR 5,0 S o00oo 2. LM 2,4,ADDRS USING HERE,2,3,4 ADDRS A(HERE,HERE+4096,HERE+8192 ) 3. ~ LM 10,11, =A( BASE+100, BASE+4196 ) USING BASE+100,10,11 4. LA 5,SY USING SY,5 NOTE: NO RELOCATABLE EXPRESSION MAY BE USED I A PROGRAM (INCLUDING * AS A TERM AND LITERALS) UNIESS THERE IS A USING REGISTER WHOSE VALUE IS WITHIN 4095 OF THE RELOCATABLE EXPRESSION VALUE. FORMATS: RX S(X); S RS S S = RELOCATABLE EXPRESSION SI S X, L = ABSOLUTE EXPRESSIONS SS S(L); S IMPLIED LENGTH = L'S

IV. 8 MACHIN',J INSTRUCTION PROCFESING: NIAME FIELD SYMBOL: VALUE IS ADDRESS OF LEFT-MOST BYTE OF INSTRUCTION LENGTH IS INSTRUCTION LENGTH RR 2 RX,RS,SI 4 Ss 6 ASSEMBLER CHECKING DURING PROCESSING: IEGAL OPERATION MNEMONICS ONLY HALF WORD ALIGNED (FILLS WITH X'oo0) OPERAND ALIGNMENTS CHECKED, IF POSSIBLE REGISTER SPECIFICATIONS CHECKED FPRS 0,2,4,6 ONLY GPRS 0 THROUGH 15 ONLY, EVEN-ODD PAIRS CHECKED WHERE NEEDED EXTENDED MNEMONICS FOR BC AND BCR: MASK CONDITION MNEMONICS 0 NONE NOP,NOPR 1 OF, Is BO,BOR 2 BHBIHR,BP,BPR 4 ( BL,BLRBM, BMR 7 BNE, BNER, BNZ,BNZR 8 = BEe,BE,BZBZR 11 BNL, BNLR, BNM, BNMR 13 BNHH, BNHR, BNP, BNPR 14 NOT ls BNO 15 ALL BBR PROGRAM EXCERPT 6: REPEAT OF PROGRAM EXCERPT 1 USING IMPLIED ADDRESSING. ASSUME A, B, C, AND D NAME THE FOUR FIXED POINT NUMBER WHICH ARE IN CONTIGUOUS LOCATIONS. BALR 12,0 ESTABLISH ADDRESSABILITY -- ASSUME USING *,12 IT COVERS WHOLE PROGRAM AND DATA L 3,A A TO GPR 3 A 3,B A+B TO GPR 3 L 2,C C TO GPR 2 A 29D C+D TO GPR 2 MR 2,2 PRODUCT TO GPRS 2 & 3 L 10,A A TO GPR 10 S 10,D A-D TO GPR 10 DR 2,10 RESULT TO GPR 3 ST 39D+4 STORE RESULT -- ADDRESS D+4 COULD ALSO BE *g~~ E~~WRITTEN AS C+8, B+12, OR A+16

IV.9 PROGRAM EXCERPT 7: REPEAT OF PROGRAM EXCERPT 4 USING IMPLIED ADDRESSING. WE NOW ASSUME THE 100 FIXED POINT NUMBERS ARE STORED CONTIGUOUSLY IN A VECTOR NAlED VECT AND THE SUM IS TO BE PLACED IN A FULL WORD NAMED SUM. BALR 10,0 ESTABLISH ADDRESSABILITY USING *,0lO L 2,p=A(VECT) FIRST ADDRESS TO GPR 2 SR 6,6 0 TO GPR 6 LA 4,4 4 TO GPR 4 LA 5,VECT+396 LAST ADDRESS TO GPR 5 A 6,O(,2) SUM TO GPR 6 BXLE 2,4,*-4 LOOP ON COUNT OF NUNMERS ST 6,SUM STORE SUM PROGRAI EXCERPT 8: SAME AS PROGRAM EXCERPT 7 EXCEPT WE NOW ASSUME THE COUNT OF THE ENTRIES IN VECT IS IN A HALF WORD NAMED COUNT; THE COUNT IS GREATER THAN OR EQUAL TO ZERO. BALR 10,0 ESTABLISH ADDRESSABILITY USING *,10 LH 6,COUNT COUNT TO GPR 6 LTR 7,6 COUNT TO GPR 7 AND SET CC BZ STORE BRANCH ON ZERO COUNT - GPRS 6,7 = 0 SR 1,1 ZERO TO GPR 1 L 6,VECT FIRST NUMBER TO GPR 6 B STORE-4 ENTER THE SUM LOOP LOOP LA 1,h(,1) UPDATE THE INDEX A 6,VECT(1) ADD NEXT NUMBER TO SUM BCT 7,LOOP LOOP ON COUNT OF NUMBERS STORE ST 6,SUM STORE SUM 0

IV. 10 DEFINF CONSTANT (DC) AND DEFINE STORAGE (DS) ASSEMBLER INSTRUCTIONS: lAME FIELD SYMBOL PROCESSING: VALUE = ADDRESS OF FIRST CONSTANT OR FIRST STORAGE AREA, AFTER ALIGNMENT LENGTH = LENGTH OF FIRST CONSTANT OR FIRST STORAGE AREA EACH OPERAND IS COMPOSED OF UP TO FOUR SUBFIELDS: 1 DUPLICATION FACTOR -- OPTIONAL SUBFIELD 2 KEY SUBFIELD -- REQUIRED SUBFIELD 3 MODIFIERS -- OPTIONAL SUBFIELD 4 NOMINAL VALUES -- REQUIRED SUBFIELD FOR DC, OPTIONAL FOR DS NOTE: IN FOLLOWING, dae STANDS FOR "UNSIGhND DECIMAL SELF DEFITN G TERM OR PREDEFINED ABSOLUTE EXPRESSION ENCLOSFD IN PARENTHESES, WITH VALUE GREATER THAN OR EQUAL TO ZERO". DUPLICATION FACTOR: SPECIFIED AS dae; DEFAULTS TO 1 IF NOT GIVENJ A VALUE OF ZERO FORCES ALIGNMENT BUT RESERVES NO STORAGE KEY SUBFIELD: DEFINES TYPE OF CONSTANT TO BE HANDLED AND SELECTS THE IMPLICIT (DEFAULT) LENGTH AND ALIGNMENT. THE KEYS, TYPES, DEFAULT ALIGNMENTS, DEFAULT IENGTHS, MAXIMUM LENGTHS, AND CONSTANTS PER OPfERAND ARE AS FOLLOWS: C CHARACTER BYTE AS NED 256 1 X HEXADECIMAL BYTE AS NEEDED 256 1 B BINARY BYTE AS NEEDED 256 1 P PACKED BYTE AS NElJ)ED 16 MULTIPLE Z ZONED BYTE AS NEF TED 16 MULTIPLE F FIXED PT FW 4 8 MULTIPLE H FIXED PT HW 2 8 MULTIPLE E FLOAT PT FW 4 8 MULTIPLE D FLOAT PT DW 8 8 MULTIPLE L FLOAT PT DW 16 16 MULTIPLE A ADDRESS FW 4 4 MULTIPLE EXPRESSIONS V ADDRESS FW 4 4 MULTIPLE EXT SYMBOLS Y ADDRESS HW 2 2 MULTIPLE EXPRE;SSIONS S BASE/DISPL HW 2 2 MULTIPLE Q ADDRESS FW 4 4 MULTIPLE MODIFIERS: LENGTH: L.n BIT LENGTH n GIVE AS dae Ln BYTE LENGTH IF GIVEN, OVERRIDES DEFAULT LENGTH AND CANCELS ALIGNMENT SCALE: Sn n GIVEN AS dae WITI OR WITHOUT SIGN SCALES F,H,E,DL TYPES OF CONSTANTS ARTER CONVESION TO BINARY EXPONENT: En n GIVEN AS dae WITHi OR WIIHOUT SIGN SCALES F,H,E,D,L TYPES OF CONSTANTS BEFORE CONVERSION TO BINARY NOMINAL VALUES: FOR ADDRESS TYPES, SPECIFIED AS (EiE,..,Ern) FOR V TYPE, EACH Ei IS AN EXTERNAL RELOCATABLE SYM3OL FOR A TYPE, EACH Ei IS A RELOCATABLE OR ABSOLUTE EXPRESSION FOR ALL, OTHER TYPES, SPECIFIED AS IC' OR'C1,C2,,.,,,,Cnt TYPES CX,B:'Ca ONLY TYPES P,Z,FHE,DL: MULTIPLE VALUES AIL(ZD2B * AS A TERM HAS VALUE OF LEFT MOST BYIE A.DDRESS IN GONSTANT FOR THE DS ASSEMBLER INSTRUCTI3ON NOMINAL VAL1UES OPTIONAL SAME ALIGNMENT/LENGTH, BUT fgOTING LO.ADED TYPES X,C MAY HAVE MAXIMUM LENGTH OF 65535 BYTS

IV. 11 DS EXAFPLES: DS OH ALIGNS TO HALF, FULL, OR DOUBLE WORD, RESPECTIVELY, BUT RESERVES DS OF NO STORAGE; LENGTHS = 2, 4, 8, RESPECTIVELY DS OD DS nH ALIGNS TO HALF, FULL, OR DOUBLE WORD, RESPECTIVELY, THEN RESERVES DS nF n HALF, FULL, OR DOUBLE WORDS, RESPECTIVELY; LENGTHS = 2, 4, 8, DS nrD j RESPECTIVELY DS CLn RESERVES n BYTES; LENGTH IS n; NO ALIGNMENT FOR ALIGNMENT, DS mCLn RESERVES m*n BYTES; ENGTH IS n; NO ALIGNMENT MAY PRECEDE WITH DS nC RESERVES n BYTES; LENGTH IS 1; NO ALIGNMENT% DS OH,OF,OD EXAMPIE OF FIELD OVERLAP USING DS: DS OD ALIGN TO DOUBLE WORD CARD DS OCL80 LENGTH = 80; NO STORAGE RESERVED FIELDA DS OCLIO LENGTH = 10; NO STORAGE RESERVED 80 FIELDB DS OCL20 LENGTH = 20; NO STORAGE RESERVED T BYTES DS CI40 RESERVE 40 BYTES OF STORAGE TOTAL MIDD DS OCL40 TLENGTH = 40; NO STORAGE RESERVED FIELDC DS C0120 LENGTH = 20; 20 BYTES OF STORAGE RESERVED FIELDD DS 10CL2 LENGTH = 2; 20 BYTES OF STORAGE RESERVED / FOR LITERALS: NO MULTIPLE OPERANDS -- SINGLE OPERAND MAY HAVE MULTIPLE VALUES, IF ALLOlWED DUPLICATION AND LENGTH MUST BE UNSIGNED DECIMAL SELF DEFINING TERMS ONLY DUPLICATION MUST BE GREATER THAN ZERO SCALE AND EXPONENT MUST BE DECIMAL SELF DEFINING TERM ONLY (SIGN ALLOWED) TYPES S,Q NOT LEGAL AS LITERALS * AS A TERM HAS AS VALUE THE ADDRESS OF THE LEFT-MOST BYTE OF THE INSTRUCTION IN WHICH THE LITERAL OCCURS

IV. 12 PROGR'M SECTIONING AND CONTROL SECTIONS (CSECTS): 2SECT: BASIC ASSEMBL/LINKEDIT/LOAD UNIT IN SYSTEM SOURCE/OBJECT MODULE = 1 OR MORE CSECTS LOADER PROCESSING: CSECT LOADED WHEREVER THERE IS SUFFICIENT ROOM CSECT LOADED IN CONTIGUOUS LOCATIONS BEGINNING ON jIt BOUNDARY ALL CSECT NAMES APPEAR IN IOAD MAP CSECT DEFINITION DURING ASSEMBLY: [sya START org = BLANK OR SEli DEFINING TERN NAMES FIRST OR ONLY CSECT IN ASSEMBLY; CSECT STARTS AT org OR ZERO; sym DEFINED (LENGTH = 1) AND MADE EXTERNAL syi,CSECT RESETS LOCATION COUNTER TO THAT OF CSECT sym; sym DEFINED (LENGTH = 1) AND MADE EXTERNAL sym DSECT RESETS LOCATION COUJNTER TO TALT OF DSECT syrm; EACH DSECT MUST BE NAMED; sym IS VALID RELOCATABLE INTERNAL SYNIBODL WITH LENGTH OF 1; EACH DSECST I ASSEMBLED BUT IS NOT PART OF OBJECT MODULE; DSECTS USED TO ESTABLISH A MNEMONIC DESCRIPTION FOR USING PURPOSES OF A STORAGE AREA FIRST CSECT IS ASSEMBLED AT org OR AT ZERO -- REST ARE ASSEMBLED ON DW BOUNDARIES IN ORDER OF OCCURRENCE DURING ASSEMBLY; LITERALS NOT CAPTURED BY LTORG'S GO TO LITERAL POOL AT END OF FIRST CSECT; CSECT NAMES ARE EXTERNAL -- DSECT NAMES ARE INTERNAL FOR CSECTS ASSEIBLED TOGETHER: ALL SYMBOLS ARE DEFINED IN ALL CSECTSa USINJG IN CSECT COVERS ONLY THAT CSECT -- BUT USING RANGE DURING ASSEMBLY IS INDEPENDENT OF CSECT BOUNDARIES; NO EXTERNAL SYMBOIS NEEDED FOR COMMUNICATION; iN E&CH CSECT, ADDRESSABILITY TUST BE ESTABLISHED SEPARATELY FOR EACH OTHER CSECT REFERENCFJD SYMBOLICALLY; ADDRESSABITLITY OVER LITERALS MUST.BE MAINATAINED OVER CSECTS SYMBOLIC LINKAGES -- INDEPENDENTLY ASSEMBLED CSECTS: IN EACH CSECT ASSEMBLED, CSECT NAMES AND ENTRY NAMES (VIA ENTRY ASSEMBLER INSTRUCTION) ARE INTERNALLY DEF'INFD BUT ARE MADE EXTERNALLY KNOWN — ALL OTHER DEFINED SYMBOLS ARE PRESUmFSD INTERNAL ONLY IN EACH CSECT ASSEMBLED, SYMBOLS OCCURRDIG IN V-TYPE ADDRESS CONSTANTS OR IN THE EXTRN OR WXTRN ASSEBLER INSJeRUCTIONS, ARE PRESUMED TO BE EXTERNALLY DEFINED (THEY MUST NOT BE INTERNALLY DEFINED) -- ALL OTHER SYMBOLS MUST BE INTERNALLY DEFINED EXAMPLE LINKAGES: 1. L 15,=V(SUB) 29 EXTRN SUB BALR 14,15 L =A(SUB) BALR 14,15 3. L 12, =V(DlAT) 46 EXTRN DATA USING DAUTD,J12 L 12, =A(DATA ) USING DATAD,12 3. AND 4. PRESUME DESCRIPTIONS OF DATA PROVIDED) DURING ASSEMBLY BY DSECT NAmD DATAD o. L 129=V( n5A) q &IJTSSUIMLG DATA FW ALIGNED, LOADS GPR 10 L 10,4(h,12) WITH SECOND FW OF DATA

IV. 13 EXAMPLE SYMBOLIC LINKAGE: NAME CSECT LR 10,15 USING NAME,10 L 5,9=A(D1) USING D1,5 L 15,-V(SUB) BAIR 14,15. EXTRN S1'' X SUB CSECT L 15,=A(Sl) U DATA,5 BALR - 14,15 BR 14 DATA DSECT D1 CSECT'(SYMBOLIC DESCRIPTION OF I/~~~~~ 0 * DATA CSECT) END, I END 4 S CSECT ENTRY Si USING *,15 >' Si L il,-=V(Dl) (REFERENCES TO DI VIA DISPLACEMENTS ON GPR 11) BR E14 END

CALLER PROGRAM I program text. I CALLED PROGRAM BALR | GR15 BI entry point I s I,,,, IIPI4return code I CALLER'S CALLER GR14 I data areas G o F I O akI R or FRO result (if program I "'s asavearea ar. - is a function) savearea flag length t GR13 r low pointer _ 1,#'|high pointer | savearea,I ~' O*' Iarea for GR14! 11I| I I I_ r_ __I "'"'" I @ area for GR15 a I area for CR12 C1 m I I I I' L I I t I ist - |li L _.j 0_ BJ storage L __..... —- 4- am-mt lLare for I LO <> variables s iI I I, ro I P vo —o__ _ _ _ ___ _ _ _O _~~~~~~~~~~~~~~~~

V.I D M('lAT Av TTHM'Tr' TNS.TRtCTTONS Wor thp fo1-IwirrE I ncSthr tino'R theP ror. in -tm" ked o0r' zoed d.reeimal forma+. and ocreuny a f.ieldr wh.eh.t- e.,tarts.t, the -c ^if'ied addrerss and xts.mnds for the SnpfjfiS' yyr't-e nv bvtps. Operands whi ek are of iunen tvi 1W. nrth ri made of on' I. — lerth Vy _ste+.nd1.ng the shorter with hi.gh ordier z rnes Al - operands mwst.p i ~ parkeed decimnal for~w't.xr'vpt, the, oneranr 4 the PA(W!!n?.t,-rctt.on, whi.h muist be v i onnd denieMal format,, A.ll resi+].s will.be,. n packrnd d.ens.mal. format x,,cneep thie rfsil +. of the, UNPK tinstr.etnt on, whiceh wl.l bo Tn zsend ddeelmal format, Th r Iesu.lt of all instvrictlens alway3 fill +ht er4~P +tare fe1Ar beng extended with high order zeroos ~'. nee.ssSarV ve f~t- (L 1t2av 8,j' s * AP ),'L3,iD t —sBu (CK,3tD 3tD,- -, CBv29U D(BL Id) 4)', d.L..;,. jr,,. t 4. i MV0t>Ft~orl O26te18;3'$ J-) tL S., i _;_ FV, 4.~ ) v lu -o r L\~ -lt i; R ^ t;- _c1. L -k Ita l.>N ~tj~d; "::3 a,~ ~ D

*- 4-5 Q~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ r,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- j ~ ~~~.9 -'- -$ I l J 1 r m -~~1 -~r V~% r -4- ~ ~ ~ ~ ~ ~ ~ ~- — ~; r a -~t~:i %J -4 j j -lit~~~,;~ ~ g t~~~~~f *C~J~*'L~3 c3, y f ~oC4J Z;- t'- __ -IL/ -4 ~ d ~ p~ P pa, 1 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~r~, rU_-~~-I i b~~~ I~ wJe Cr ( hA-L a'4- 0u 2C r(-r r A 1 ~I~s V"~-I 4i/3 ""\~*/' ~3'J * 4ed c ~ r

VI. 1 LQ4 C. AL tN$StRUC Tio tx: to4e: Tb kh fie iSt Si~ b, Le + D, -> a fcw;, 4, M \/ h X s ( t >P4, 3, )D2 ta) C. Or t';-0> \ +b. LS't 0; o, ~ \.'0, -Aa.-'it, k, at1sb 124Th > aOI }((tifet o. t Cq;~ii(d l ^> S. >+ )\ &tk 2. tr o-g 5TC W>1);t.)(z13 iCR~ia~j;;>'3& =3wX @aM+

VI.2 * CLR R,,! i14 c32 Utit WjdncrW i J' 4n atet'D,( L, AA, Oj C, C" * N x CNr E, N,,, (Vb L->,b P <Q i. <(,.A,) ^:; * jB A >, ".>, bc> j,.~.( ) C K u Co C V, 1)^C4->i' ~~~~~~~~~~~~~~~~~ki4 t i3t@i53 s>4~

VI.3 *O>CRI K 1; A t~oY P) Cu U) VA * >4 ANII QwY, -lr j;t Mn t*4E flvt ~p~ IJDL > 1Li Tz L 0 (1XwuSuv, ov ) b. P LAN> Le si ta4 2C ta tj o 0 f6:et> (add v $(.o, vi Ar) h: s~~~~~~~if>l'tai e r >8(e,>;Tz X 0Ce~~~~~~q,+s<)t) > 4>fX C3

VI.4 t4,~. 0 -1l('txr, A *-h*t P o CC I I atddrA + rC CdC.a) t 9t 8 3; ((ffiadr,) (jddn)+4 nd456) -k t7L' ItC. L~t ltRd 7 L (6lbR2o'1 -~.> c4 UZ4A"CI(K.D, LT ~.Un),,at.' c E t)2| ~ e 1)) a{ S f>lg(S S X ea; r28~-?W JI lp

VI.5 LOGICAL MACHINE INSTRUCTION EXAiFLES: 1. MVI BUFF,C'' PUTS BLANKS IN 80 BYTES STARTING MVC BUFF+1( 79),BUFF AT LOCATION BUFF 2. MVI A,O EROES OUT AREA A, ASSUMING L'A IS MVC A+I(L'A-1),A AT MOST 256 3. CLI BYTE,X'F5' BRANCHES TO EQUAL IF BYTE CONTAINS BE EQUAL A HEXADECIMAL F5 4. STM O,1O,GPRS BRANCHEF TO CHECKS IF GPRS 0 10 CLC GPRS(44),VALS CONTAIN THE SAME VALUES AS THE 11 BE CHECKS FULL WORDS STARTING AT VALS 5. TM BYTE,X'FO' BRANCHES TO SET IF BITS 0 - 3 OF BO SET BYTE ARE ALL ONES 6. TM BYTE,,1 BRANCHES TO UNSET IF BIT 7 OF BYTE BZ UNSET IS ZERO 7. NI BYT,X'OO' SETS BITS 0 - 7 OF BYT TO ZERO NI BYTX'77 1 ZEROES BITS 0 AND 4 OF BYT N 6,=X'OOFFFFFF' ZEROES FIRST BYTE OF GPR 6 OI BYT,X'FF' SETS BITS 0 - 7 OF BYT TO ONE OI BYT,X'EE' SETS BITS 3 AND 7 OF BYT TO ONE XI BYT,X'OO BYT UNCHANGED XI BYT,X'FF' ALL 8 BITS OF BYT INVERTED XI BYT,X'88' BITS 0 AND 4 OF BYT INVERTED 8. THE TRANSLATE (TR) INSTRUCTION: TR q(L,Bl)D2(B2) ~C_{A- GN i 256 FUNCTION BYTES =.ARGUMENT _: BYTES _IJ EACH OF THE L ARGUMENT BYTES IS PROCESSED, LEFT TO RIGHT, AS FOLLOWS: 1. COMPUTE ADDRESS A = D2(B2) + ARGUMENT BYTE (I. E., USE ARGUMENT BYTE AS INDEX) 2. REPLACE ARGUMENT BYTE BY FUNCTION BYTE AT ADDRESS A FOR EXAMPLE, TO CONVERT EBCDIC STRING OF LENGTH L IN STR TO A STRING IN WHICH C'O'...C'9' BECOMES X'OO'...X'09' AND ALL OTHER CHARACTERS BECOME X'FF', COULD USE: TR STR( L),TAB TAB DC (CO')X'FF',X'00010203040506070809',6X'FF 0

VI. 6 THE TRANSLATE AND TEST (TRT) INStRUCTION: TRT Di(L,Bj),D2(B2)'' L - a RGUMENT 256 FUNCTION BYTES I BYTES THE ARGUMENT BYTES ARE PROCESSED~, ONE BY ONE FROM LEFT TO RIGHT, AS FOLLOWS: 1. CONMUTE ADDRESS A =- D2(B) + ARGUVENT BYTE (I. E,, USE ARGUNE1 BYTE AS INDEX) 2. IF FUNCTION BYTE AT LOCATION A IS ZERO, CONTINUE AT STEP 1 WITH NEXT ARGUME'NT BYTE 3. IF FUNCTION BYTE AT LOCATION A IS NON-ZFRO, THEN: a. ARGUMENT BYTE ADDRESS IS PLACED IN BITS 8-31 OF GPR ]., BITS 0-7 ARE UNCHANGED; bo THE NON-ZERO FUNCTION BYTE IS PLACED IN BITS 24-31 OF GPR 2; BITS 0-23 ARE UNCHANGED; co THE TRT IS TERMINATED, SETTING THE CC, 4. AT TERMINATION OF A TRT, THE CC IS SET AS FOLLOWS: 0 ALL ARGUME T BYTES WERE USED AND NO FUNCTION BYTES SEIECTED WERE NON-ZERO 1 A NON-ZERO FUNCTION BYTE HAS BEEN SELECTED AND ONE OR MORE ARGUMENT BYTES HAVE NOT YET BEEN USED 2 THE LAST ARGUMENT BYTE PRODUCED A NON-ZERO FUNCTION BY') (I, E., THERE ARE NO MORE ARGUPENT BYTES) EXANPTLE TRT: TO TEST STRING STR, OF LENGTH LVSTR, FOR THE CHARACTERS +, -, AND DIGITS ONLTY, COULD USE: TRT STR, TAB BJZ ILLEGAL 0 TAB DOC (C'+')X'FF' X'00 1 I (( -C - l )X.11,X 00 (CIO,-C'-' -1)XOF',1OXt O',6X'FO' WHEN CONTROL REACEIES ILLEGAL, THE FUNCTION BYTE IN GPR 2 WILL INDICATE THE PART OF THE TABLE INDEXED BY THE ARGUMENT BYTE EXAMPLE TRT: THE FOLLOWING CODE TEST THE 8 BYTE STRING IN F AMD CIOViTS IT TO A FIXED POINT NUMBER IN GPR 15 IF THE STRTNG IS A HEX CHARACTER STRING (CONSISTS OF HEX CHARACTERS ONLY) TRT EX(8),TEST TEST FOR e L CHARACTERS BNZ NOGOOD M7VC TEPEX MOVE STRING INTO Tf TR TE, TWRANS-'A CONVERT STRING TO BINARY VALUES PACK T1MP(9),T EP CONVERT TO BINARY JUMBER L 15,TEP+4 PUT INTO GPR 15

VI.7 TEMP DS D DS CL1 TEST DC (C'A')X'FF',6X'oo',(C'O'-C'G )X'FF',1X'oO',6X'FF' TANPS DC 6AL1(*-TRANS+10),(CO'-CG,' )X'FF',OAL1(*-TRwS-4a7) 0

VII.1 SAMPLE PROGRAM 1: SUMSQ ROUTINE SUMSQ COMPUTES THE SQUARE ROOT OF THE SUM OF THE SQUARES OF A VECTOR OF SHORT FLOATING POINT NUMBERS AND RETURNS THE RESULT IN FPR O. SUMSQ USES THE FOLLOWING R-TYPE CALLING SEQUENCE: GPR O NUMBER OF ENTRIES IN VECTOR; MUST BE GREATER THAN ZERO GPR 1 ADDRESS OF FIRST FULL WORD FLOATING POINT NUMBER IN VECTOR THE RETURN CODES FROM SUMSQ ARE: 0 RESULT IS IN FPR O 4 SOMETHING WENT WRONG -- NO RESULT SUMSQ CSECT LTR O,0 TEST COUNT BP GOOD-SUMSQ(,15) BRANCH IF OK IA 15,4 SET ERROR RC = 4 BR 114 AND RETURN USING SUMSQ,10 GOOD STM 4114,12,12(13) LR 10,15 LA 2,SAVE STANDARD ROUTINE ENTRY SEQUENCE WITH ST 2,8(,13) SAVE AREA CHAINING AND REGISTER SAVING ST 13,24(,2) LR 13,2 SER 0,0 0 TO FPR O LOOP LE 2,(,1) NEXT NUMBER TO FPR 2 MER 2,2 SQUARE THE NUMBER AER 0,2 ADD SQUARE TO SUM LA 1,4(,1) UPDATE ADDRESS BCT O,LOOP COUNT DOWN LA 15,0 SET RC TO ZERO BZ EXIT ALL DONE IF SUM = O STE O,HOLD LA 1, A(HOLD.) CALL SQRT FOR FINAL RESULT -LEAVES SQUARE L 15,=V(SQRT) ROOT IN FPR 0 AND SETS RC = O OR 4, WE BALR 14,15 ASSUME HERE EXIT L 13,14(,13) L 142,12(,13) STANDARD ROUTINE RETURN SEQUENCE -- RC LM 0,12,20(13) AIREALY SET IN GPR 15 BR 14 J HOLD DS F HOLDS SUM IN SQUARE ROOT CALL SAVE DS 18F SAVE AREA END

VII. 2 SAMPLT PROGRAM 2: FDELE.OUTINE FDELE SEARCHES A DOUBLY-LINKED LIST STRUCTURE, IGNORING SUBLISTS, FOR A NODE CONTAINING A SPECIFIED DATUM FIELD, IF THE NODE IS FOUND, IT IS DELETED FROM THE LIST STRUCTURE AND A POINTER TO THE NODE IS RETURNED. IN THE LIST STRUCTURE EACH NODE IS 12 BYTES LONG AND FULL WORD ALIGNED. THE NODE FORMAT IS: BYTE 0 KEY FIELD: 0 = HEAD NODE; 1 = SUBLIST REFERENCE; 2 = DATUM NODE BYTES 1-3 ADDRESS OF SUCCESSOR NODE BYTES 4-7 ADDRESS OF PREDECESSOR NODE BYTES 8-11 SUBLIST ADDRESS (KEY 1) OR 32 BIT DATUM (KEY- 2) SAMPLE LIST STRUCTURE:'~HEAD~H 0 SUBLIST EMPTY STRUCTU RE t FDELE USES AN R-TYPE CALLING SEQUENCE: GPR 0 32 BIT COMPARAND -- SEARCHING FOR NODE WITH THIS DATUM VALUE GPR 1 ADDRESS OF HEAD OF LIST STRUCTURE POSSIBLE RETURN CODES FROM FDELE: 0 NODE FOUND & DELETED; NODE ADDRESS IN GPR 1 4 LIST STRUCTURE IS EMPTY 8 UNSUCCESSFUL SEARCH OF NON-EMPTY LIST STRUCTURE FDELE CSECT USING FDELE, 15 PROGRAM ADDRESSABILITY USING NODE,1 LIST ST'IUCTURE ADDRESSABILITY C 1,SLINK TEST FOR EMPTY STRUCTURE BNE SAVE BRANCH IF NOT LA 15,h EMPTY STRUCTURE EXIT -- SET RC = 4 BR 14 SAVE L 1,SLINK GET NEXT NODE POINTER CLI KEY,1 TEST NODE KEY BE SAVE BRANCH ON SUBLIST RKYERENCE BH LOOP BRANCH ON DATM1 NODE LA 15g8' BE AtCKT TO HE HEAD NODE BR ] i EXIT WITII RC 8

VII.3 LOOP C O,DATUM TEST DATUM VALUE BNE SAVE BRANCH IF NOT EQUAL TO COMPARAND SWPR 2,2 GOT IT -- SAVE GPRS 2 & 3 LM 2,3,SLINK GET NODE'S POINTERS ST 3,4(,2) UPDATE SUCCESSOR NODE MVC 1(3,3),SLINK+l UPDATE PREDECESSOR NODE SWPR 2,2 RESTORE GPRS 2 & 3 SR 15,15 SET RC = 0 BR 14 AND RETURN NODE DSECT ) LKEY DS OF DSECT DESCRIPTION OF NODE FOR StLINK DS F IMPLICIT ADDRESSING PURPOSES PLINK DS F DATUM DS F END

VII.4 SAMPIU.A PROGRAM 3: FDETE -'HIS EXAMPLE IS THE SAME AS THE PREVIOUS EXAiPLEe, EXCEPT THAT HERE NO DSECT IS USED AND ALL ADDRESSING IS EXPLICIT VIA DFFINED SYIBOLS FOR EASE OF READING AND WRITING THE PROGRAM. FDELE CSECT NODE EQU 1 BASE REGISTER CONTA'INI G NODE ADDRESS KEY EQU 0.'KX_~f FTIELD DISPIACEDTSNT SLINK EQU 0 SUCCESSOR F!'EJ? DISPLACF lENT PLINK EQU 1 PREDECESSOR FIELjD DISPLACEMENT DATUM EQU 8 DAdU'M FIEIJ DISPLACEMFNT USING, FDELE.,15 PROGRAM ADDRESSABILITY C NODE,SLINK(,NODE) TEST FOR EifP7' STRUCTURE BNE SAVE BRANCH IF NOT LA 1534 EIPrY STR.CTURE EXIT -- SET RC 4 1 BR 14 SAlVE L NODE,SLINK(,NODE) GET NEXT NODE POINTER CLI KEY(NODE ),1 TES T NODE KEY' BE SAVE BRANCH ON SUBLIST REFERENCE RH LOOP BRANCH ON DATUM NODE LA 15,8 TWERE R.C'K TO ThiE HEAD NODE BR 1 EXIT WIE'IH C" 8 LOOP C ODATUM(,NODE).TFST DATUM VALUE BNE SAVE BRANCH IF NOT EQUAL TO COMPARAND SWPR 2,2 GOT IT -- SArE GPRS 2 & 3 LM 2,3,SLLNK(NODE) GET NODE S POINTERS ST 3,PLINK(,2) UPDATE SUCCESSOR NODE MVC 1(3,3 ),SLINK+1(NODE) UPDATE PR.LDECESSOR NODE SWPR 2,2 RESTORE G PS 2 & 3 SR 15,15 SET RC = 0 BR 114 AN'D REIIJ-RN END

VII.5 PROGRAM SAMPLE 4: CONVERT GIVEN A STRING OF CHARACTERS OF LENGTH N, ROUTINE CONVERT SEARCHES THE STRING FOR OCCURRENCES OF INTEGER STRINGS AND CONVERTS SUCH INTEGER STRINGS TO FIXED POINT BINARY NUMBERS STORED IN A VECTOR GIVEN AS AN ARGUMENT. CONVERT OPERATES WITH THE FOLLOWING ASSUMPTIONS: 1. EACH INTEGER STRING ENDS IN ONE OR MORE NON-DIGITS; 2. NO INTEGER STRING CAUSES AN OVERFLOW DURING CONVERSION; 3. INTEGER STRINGS ARE CORRECTLY WRITTEN WITHOUT ARITHMETIC SIGNS. CONVERT USES AN S-TYPE CALLING SEQUENCE WITH PARAMETERS: ST ADDRESS OF THE CHARACTER STRING N FULL WORD LENGTH OF THE STRING (TRUE "LENGTH) V ADDRESS OF THE FULL WORD FIXED POINT RESULT VECTOR THE RETURN CODES USED BY CONVERT ARE: 0 ONE OR MORE NUMBERS PIACED IN V; NUMBER OF ENTRIES IN V IS IN GPR O 4 NO ENTRIES STORED IN V THE ALGORITHM USED BY CONVERT IS AS FOLLOWS: 1. FIND NEXT DIGIT IN CHARACTER STRING USING TRT 2. IF NO MORE DIGITS IN STRING, THEN ALL DONE 3. FIND NEXT NON-DIGIT IN CHARACTER STRING USING TRT 4. CONVERT THE INTEGER STRING TO FIXED POINT 5. STORE THE FIXED POINT RESULT IN THE NEXT RESULT VECTOR ENTRY 60 UPDATE THE RESULT VECTOR INDEX 7. RETURN TO STEP 1l CONVERT USES GPRS AS FOLLOWS DURING PROCESSING: 1 ADDRESS OF REMAINING PART OF CHARACTER STRING TO BE PROCESSED 2 USED BY THE TRTS 3 INDEX ON THE RESULT VECTOR V h ADDRESS OF THE RESULT VECTOR V 6 ADDRESS OF THE LAST BYTE IN THE CHARACTER STRING 7 CURRENT TRT LENGTH OR MOVE LENGTH 8 255 - FOR COMPARISON PURPOSES 9 HOLDS FIRST DIGIT ADDRESS OF INTEGER STRING 10 PROGRAM ADDRESSABILITY CONVERT CSECT USING *,10 STM 14,12,12(13) LR 10,15 LA 12,SAVE ST 12,8(,13)' STANDARD ENTRY SEQUENCE ST 13,4(,12) LR 13,12 SR 3,3 0 TO INDEX L 4,8(,1) ADDRESS OF V TO GPR 4 L 6,4(,1) ADDRESS OF N TO GPR 6 L 6,0(,6) N TO GPR 6 LTR 6,6 IF N LESS THAN ZERO, OR ZERO, BNP 12,DONE BRANCH HERE - WE'FE DONE L 1,O(,1) ADDRESS OF ST TO GPR 1 AR 6,1 ADDRESS OF LAST BYTE OF ST TO GPR 6 BCTR 6,0 LA 8,255 255 TO GPR 8 FOR COMPARISONS

VII.6 VI/OP LR 796 LAST BYTE ADDRESS TO GPR 7 SR 7,1 IBM LENGTH TO GPR 7 BM DONE IF NEGATIVE LENGTH, ALL DONE CR 7,8 IF LENGH GREGATER THAN 255 BNH *+6 LR 7,8 USE 255 EX 7,EXDIG LOOK FOR A DIGIT BNZ DIGIT BRANCH IF FOUND ONE LA 1,256(,1) COIP.UTIVE NEW' INITIAL ADDRESS B LOOP AND THEN T TY AGAIN DIGIT LR 9,1 SAVE DIGIT ADDRESS IN' GPR 9 LR 7,6 LAST BYTE ADDRESS TO GPR 7 SR 7,1 IBM LENGTH TO GPR 7 CR 7,8 IF LENGTH GREATER THAN 255, BNH *+6 LR 7,8 USE 255 EX 7,EXCHR FIND NEXT NON-DIGIT LR 7,1 NON'-DIGIT ADDRESS TO GPR 7 SR 7,9 CON1FUTE INTEGER STBING LENGTH BCTR 7,0 COMPUTE IBM INTEGER STRING LENGTH EX 7,PACK CONVERT INTEGER STRING TO PACKED DECIMAL CVB 5,NUM CONVERT PACKED DECZIMAL TO FIXED POINT ST 5,( 3,4 ) STmOI RESt rlN'RSSULT VE:CTOR LA 3,h4(,3) UPSATE RESULT.VEC.TOR INSDEX B LOOP ROUND AND ROUNiJD U E GO,......o DONE LA 1534 AJLLt DONE -- STEI, =T 4 h" LTR 0, 3 TEST RESULT VEIC TOR INDEX BZ EXIT BRANCH IF NO EENTRIES IN RESULT VECTOR LA 150, HAVE EATRIES -- SET iC = 0 SRA 0,2 COMPUTE NUMBER OF ENTR-lES IN RESULT VECTO: EXIT L 13,4(,13) L ),112(,13) LN 1,12,24(13) TANDARD RET~ SEQUENCE BR 1 4 EXDIG TRT O(,1),DIGT FINDS NEXT DIGIT IN CHARACTER STRING EXCHR TRT O(,1),CHRT FINDS NEXT NON-IC.IGIT IN CHARACTER STRING PACK PACK NUM(8),0(,9) PACKS INTImDER STRING INTO NUM SAVE DS 18F SAVE A:REA NUM DS D HOLDS PACPK DECINTAL NUMBERS DIGIT DC (c!O')Xto00':,OXEFF %6X 01 CHRT DC (C'0 )X'FF',1OX'OO,6XfFFw END

VII. 7 PROGRAM SAMPLE 5 PROBLEM: Prepare, in assembly code, a program which can process a data deck which is structured as follows. The first part of the deck defines a number of LISP elements, giving them a name and exhibiting their structure. E.g., LIST1 LIST ( (A (B C)) D E F ) ATOM1 ATOM B NIL LIST () LIST2 LIST ( A ((B C) D) (E F) ) ATOM2 ATOM K The second part of the data deck specifies some composed functions which use the now-defined elements as arguments. The program is to read these, one at a time, and evaluate them. E.g., CONS ( ATOM2, CAR ( LIST1 ) ) CAAADR ( LIST2 ) when following the declarations given above would produce the output: (K A (B C)) B a, The program is divided into several pieces which are to be assembled separately. 1. The main part of the program is a MAIN program which is to control the reading of the data cards and the sequencing of the subprograms which will individually calculate one of the LISP primitive functions. In this program is therefore all of the logic for the reading of the first part of the data deck and the construction of the defined elements and the necessary tables so that a reference to the name of an element can be translated to an address of that element. The program also contains the logic for the reading and decoding of the functions in the second part of the data. This part of the program assures that calls are placed to the function subprograms in the appropriate order and that the final result is printed. This part of the program is also the place in which the pools are defined and initialized as necessary. A very simple organization is used -- the individual data items are used from the pool in sequential order, and linking among the available data items in a pool is therefore not necessary. Whenever an available data item is used, the address of the next avaialable one may be determined by adding the length of the data item to the address of the one just used. 2. The other parts of the program are each one of the primitive LISP functions. They are called by the main program as needed. There is also a garbage collection routine that is called upon to organize the available storage into pools whenever the previously available pools are depleted. b. The following register usages rules are determined in advance of code preparation. 1. OS (1) S calling conventions will be followed and this fixes the use of register 13 as a pointer to the current save area, resister 14 as the return address for a call, register 15 as the entry point for a called routine, register I as a pointer to the parameter list, and register O as the value returned by the functions.

VII.8 2. Register 12 will be used as the base register for all control sections. 3. Registers 9, 10, and 11 will be used to cover the storage area used for the pools. (Note: the programs presented below are not complete0 Neither are all of the function subprograms specified, nor is the full text of the main program given. Rather, the partial programs are used to give examples of inter-program and inter-assembly referencirn and the use of system macros and system subroutines.) c. First assembly (MAIN program and data pools) written without macros. MAIN CSECT USING *,12 Since MAIN STM 14,12,12(13) is called by the LR 12,15 system as a LA 11,SAVEAREA subroutine, ST 11,8(0,13) it must conform to ST 13,4( 011) calling LR 13,11 conventions. LM 9,11,ADDRS establish the base registers USING POOLS9,9,10,11 for the data pools * L 1,=A(SCPMLIST) part of the data card reading L 15,=V(SCARI)S) code, showing a call to the. BALR 14,15 SCARDS system subroutine * * CALL TO THE CAR SUBROUTINE ST 3tPARM get parameter value stored L i,=A(PARML!ST) activate L 15,=V(CAR) the car BALR 14,15 function B *+4(15) accept the return B CAROKAY code and branch B CARERROR to appropriate code CAROKAY CARERROR * DATA FOR THIS PROGRAM SAVEAREA DS 18F normal save ar~eot PARM DC F holds paramete- to car PARMLIST DS OF (not really r eq uired) parm list DC X'80' (the one and only parrm) for DC AL3(PARM) (parnm's address) car function SCRMLIST DC A(BUFF) parameter list DC A(LENGTH) for DC A MODS) SCADS DC A LINENBR) subroutine (continued)

VII.9 (continued) BUFF DS CL80 area for input from SCARDS LENGTH DS H number of bytes read MODS DC F' O' special input modifiers LINENBR DS F ADDRS DC A(POOLS, POOLS+4096, POOLS+8192) LTORG * * THIS ASSEMBLY ALSO CONTAINS THE DEFINITION OF THE POOLS FOR THE DATA POOLS CSECT DS OD (not really necessary) NXTN DC A(NPOOL) pointer to next avail. node NXTP DC A(PPOOL) pointer to next avail. pointer NPOOL DS 8000C PPOOL DS 400oc END MAIN d. First assembly written with the aid of system macros. MAIN CSECT ENTER 12,SA=SAVEAREA use calling conventions LM 9,11,ADDRS establish the base registers USING POOLS,9,10,11 for the data pools * SCARDS BUFFLENGTH,MODS,LINENBR (will set up parm list) * * CALL TO THE CAR SUBROUTINE ST 3,PARM get parameter value stored CALL CAR,(=A(PARM)),VL (will also set up parm list) EXTRN CAR B *+4(15) accept the return B CAROKAY code and branch B CARERROR to appropriate code CAROKAY CARERROR. * DATA FOR THIS PROGRAM SAVEAREA DS 18F normal save area PARM DS F holds parameter to car BUFF DS CL80 area for input from SCARDS LENGTH DS H number of bytes read MODS DC F'O' special input modifiers LINENBR DS F ADDRS DC A( POOLS, POOLS+4096, POOLS+8192) * THIS ASSEMBLY ALSO CONTAINS THE DEFINITION OF T;-E POOLS FOR THE DATA POOLS CSECT 1 DS OD (not really needed) NXTN DC A(NPOOL) pointer to next available node NXTP DC A(PPOOL) pointer to next avail. pointer NPOOL DS 8000C PPOOL DS 4000C END MAIN

VI.O10 e. Note that in the previcus program, SCARlS Could also have been invoked by the coding: CALL SCARDS, (BUFF,LENG, MODS 9 LINTENBR) f. Second assembly (CAR function) with strict adher>Xnce to the callincconventions. CAR CSECT ENTER 12,SAwSAVEAREA L 3, 0(0,3) j- r) LTR 3,3 check to see that t isn't BM ERROR an atomu or a null list * VALID ARGUMENT RECEIVED L 0,0(0,3) return the car field of first node L 13,4(0,13) LM 14,15,12(13) LM 1,12,24(i3) SR 15,15 BR 14 * INVALID ARGUMENT RECEIVED ERROR RETURN (14,12) 9RC4 RC=:4 ts ha' MlAIN's code will work SAVEAREA DS 18F END g. Second assembly may be shortened because CAR doesint 1) call. any other routine and 2) use any registers exepv t3 as workk. regsist~e CAR CSECT TUSNG * 5 t;&ss k<: 5 ~:S si ~:/g;~ stre ST 3,SAVEAREA this is only one vwh-h will be dest L 3e0(0,1) pick up add.ress of the L 3,0(0,t3) list acrulent value of prm) LTR 3,3 cheek to see that it isn't BM ERROR an atom or a null list * VALID ARCUMENT RECEIVED L 0,0(0,3) return the car fleld of first node L 3,SAVEAREA res toi or Tig nal contents SR 15,15 set return code BR 14 return * INVALID ARGUMENT RECEIVED ERROR L 3,SAVEAREA restore ori4gnal coSntent LA 15,4(0,0) set ~rtur- r' ctod BR 14 return SAVEAPE.R iDS F' EN D

VII.11 h. Third assembly (CONS function) showing use of a dummy control section. CONS CSECT ENTER 12,SA=MYSAVE be conventional USING POOLAREA,9,10,11 these cover data pools LM 7,8,0(1) get the value of the L 7,0(0,7) two arguments L 8,0(0,8) L 6,NEXTNODE find out the address of the LA 5,PTRPOOL next available node in the CR 5,6 pool and make sure that BH OKAY it is really a legal node. L 15,=V (GARBAGE) If no nodes are available BALR 14,15 then call collector routine LTR 15,15 (note that it's a parameterBZ OKAY less call) and interpret the RETURN (14,12),RC=4 return codes OKAY LTR 8,8 check the type of the BM NNNLIST second argument * SECOND ARGUMENT IS A LIST LISTARG STM 7,8,0(6) put ptrs side-by-side in a node LR 5,6 save pointer to node, it's fnce value LA 6,8(0,6) update the pointer to the ST 6,NEXTNODE next available node in pool L 4,4(0,13) save function's value into caller's ST 5,20(0,4) savearea (reg 0 location) RETURN (14,12),RC=O * SECOND ARGUMENT IS AN ATOM OR A NULL LIST NNNLIST L 4t=X'80000000' if the second arg is a null CR 4,8 list then it can be handled BE LISTARG above ST 8,0(0,6 turn second argument into a list ST 4,4(0,6 composed of the single atom LR 8,6 which was original second arg LA 6,8(0,6) try to get another node in which CR 5,6 to stick the two parts of BHt LISTARG the result list. If the node L 15,=V(GARBAGE) can be found, then let the BALR 14,15 code above handle the LTR 15,15 processing. Otherwise, BZ LISTARG return error return code. RETURN (14,12),RC=4 MYSAVE DS 18F a grey flannel savearea POOLAREA DSECT this dummy control section DS OD maps out all that needs to NEXTNODE DS F be known about the pattern DS 8004C of this storage area. PTRPOOL IDS 4000C END

VIII. i AN OVERVTIW OF O.S. MACRO-ASSFM3ILFR IA NCU!AG,C 1, W. I lfamr Fent,,.Pel.r-aenguage MaeroproTranmmlng Coputin Surveys, 1, 4 (Deeember 1969), 183-196. 2. TPM Corporation. IBM O.S. Assembler nua?o c2?8-65114 3, TBM Corporation. IBM O.S. Assembler Proar...*rs Culde, GC?-63?56 IT. Maero-assemb.ber language is a special progra.mmng langpuage, eibedded in reP.ulhIrassemblerlanguage, the inst.riletons of whtich are obeyed diuri.ngr assembly and which have the effect of prlodtcing speqie-nes of assembler i nsttrvil ion:s which are later translated irvto machine instrltfc~ io d b'Pb ++tri biltes of R' manrn-ssembler lJlanuae! n eprerpl- and th<e TBM 0 versor tIn P rticul.ar,r.e, i+t i.s basieSally a symbol mns lla laI pbo rn it is a rna.sor.ably rim.mittive laneglage, w.ith nv r -t- e+ ons (not all. of which are reported he.-r) arnd very'.ittle error checki n,?. It all.ows for conditional assembly -- the ai. i+y to perfor arithmetic, logical and eharnaeter manipulatlons i.t assembly t-;I.mp in order to control the soquence of code which i.s a.ssenmbled t,. i has; speeial. eonventions for denoting variabh.os, la.bels, etc,, itnee It Is embedded i n anot her programim~ng!a.nguZ.ge * 1+ nrorma.ly lq.,used t.o write "suthoutre-s" w.h-eh q..e i nvoked duritng assembly, but tbe instruetiorns In t+.hflo'.ngv.a-gc may also fe used within the main body of the progr.am TTT, The ros. of this overvi.ew wi.ll us e +.he foll owing (TRMes Me,) t.ers, The li..st Is rot meant to be completeo -- many morp +trms are defIned in the ou1rs~ of d esussion1 - but ra.+ her t30o col7ect +tg5her Somet oeftrn ms-ed tterrn! some of whic.h, of necessity, must b used wefore they c. be f ully ar.d oroe rly deofined. Also, the definitions indicate some of the synonyms which will. utqed in the di.scussfon.. v varlable svbFolp.: these are. the h dentifie-rs of +he macro-assembler langua~ge; thgey consist, of 1-7 cha.ters, the first being alphaheti, preceded by'&', C.l.t;,tons the.mev".'rg of.ome ~..nti p flers is pr.edefned and +.hei:r rallues ar,- ar.+.ote.'.! aint;and by the system; Rall. o..-hes. bre..in w.......'.. 9. -n.d + h.~ user should rfran from using ~amos,ha.r hi ~gi.n with these eharacters.

VIII.2 o eLgne t n he l te are the la Ls of iho rsmbern F -~.e r!anglqe; +,hov ensist; of i-7 r-8eha..aete9 rs,!th -f'r.n a7 h be. fa.t bpln pre Ced.ed by' d' S ll l raramr'i t hp, A f'ormal pa-rameters e I which rceivt e +hvl l ofZ 4; r.v ^.L -J~ t. ytlmet+.~S \a s wP o n.s. a,aere. * 21, 8sbi: lrbl wh',vh. ntbe Msih Sd, ~ vorSi bi,>d biS10TX an~e9 b]er l_ nsgt.age I f hma~ mnd art ia1 eo ~er jro7- vi ctn P1 ntF, o *-ereE aft 4d. ma ncro- def'n.itl on: thspe aro t.', - fa —. d +, p'.erlet.!.on;p * At r - ndlctea 4t; -that th, Ite r os'0, b ieB St ).6tsn h 1 alo is to,. l]:ft b].ank, V. MaenTo TDfe.rirtiont Basl.(ally ta is iS? a s~,;'t.-om,'": — Y ~ti.. Pm!-voed 1lutra4ng asrribly fry t +h ie taaTn-s i A?or ^< —v.m s 4 v*8?rt. whc h HeaSieH~ Ch 1.4 nk MA PC-). *W rot o * ~ - - y'.e...'-.'?ype. - -'*'->-' {,. - ~..d.. i'.t.',.. t-.o.. ~.q ~ ~ ~ ~ba..,rri when 4ho dpf' lrrR ~+ i')~ ~~f ) a;~Vv~r ~ e::s.,'-.....' - in,~.? - -~t'.?'.t-"~.....:.-?,* %,- -,.-g?.!-?:'"'......:'t ~.'' ~.'"; -".i" ".':. i~ ~ i: % —.,r —i? - 1"'' -.;''.";,+t -:.'-'~r~~g~!.r~ " 9'~~:` -F"' I';'''- ~..... ~.~-~~~&7Q i t~s~'"'~':rlz~i:fY* ~~rr~ ~i:~ij':~?'~! ~,'v~rd~.$\~Pq'?5

VIII.3 A COPY stas+.ment with the format hlatrk r0PY, ordinary svmbol may be used within thn body Tn oier to con oy rwrde1,5 MFXTT, MMTORv Rnd condHitional amssenbly statements and comrments Into +thp defl.nt1-fon from a file. VT, Progrsrm Strrcture, Basically, maero definitions mlay not be nested and must all appear7 first in the program. Pro~gram Outline ~ First may come any senuence nf l.sti ng controle satements (EJCT, PpTNT, SPACE, and TITLE), I.TI or TSEO st.FtQ.mnts%, and commennts, * Then comes the macro ifde t!ons i f anyr, Tn'toe.pe. sed between the macro deftin+iAonrs may'b arfr:s eninnee off!+,~.,, control s+t..ements, TOTT statomen. s~ and fonmmtts,: Th, e.'nmels the dIl]a+~on.y o +.hb v. 1l y h. s~bos S f iT.t rlohKal ones and t hepn Ie oval o>s, whlc7h e-g1- 1 t?d w it inr the hMl.el statefments f. d onnd t; nio sn.l aonni e v astatemnn;ts appammriro withihn thfe mwaI nhoty dftbof she r-rom;ram Filna.lly eom nens the aiAn body of thpe p rorm neldl.ng +.he mancro i.nstru+ctS. ons, model statetmerntas, and condltional. assembly t9tem.en+.Jmps, * Not.e. +he macro-assemb].e3r lnrga-rtge fa l. tetl ma..y IB ised w*-thin thes main bodriy of the p.rogwa as w.l] as w+tin +tho mlac',o doefirn.+,ors. Macero defi niti+ons may appesar w+i.thin ~q macro 1library (,inder MPS, the l.brary Ais )ooked in by asslgntnf t It to DSN 0,) nefrn.t.ons. pnpe..rIng in 4nbe;rno.ras m are. sarnned fi.rst d.d +tank. nP.ctedke novr any dAn 4nitions, whIch have t he same name ateari.n-rg in the 1 4i brary. VTI, Tn toking Macrn DeffIn+.ont' Mnas r rle'tpt% onrs ar. "e.al.ed" durfing Rssembly k vISe of a. maero I.t.rti.eitl on. The a.aro Inss+,r,_+.4on sr>se.f.es a set of ar,.nien-+t wh.ch. a. r passted onver to the CeorrerPorndInp symbolioc pnarate. s.t thp tfime of i nvoeat+Ion * The -nrototype, 4 n the maero def4nltic n of the Invoked nicro syecifies t+,gh ft.ma:t of the me:orto Instric'toion which, mvay- ber sed, to I.nvoke the defni4n4,tio-n, The formt. of' the proto+type I,, [sy mbolif' parmeter] nrsme praimp tger iistj fconument] Wher.. the name.Is any orI.~narV sywbo]. whicrh.s not alr.ady the ~name.mof!n ssssembler opco-'ne7., the naraemtedr list is' conmst-Xl.s f & )9d)OQ sv r'>i]ic

VIII.4 * +the eomrer+ may not anr:ar..her A,n rameter ist o the rraet,r list a.rid'.m.nty m''. leaved + on P i 7vor t Snst~P)~I.Ica~t. fr to h. asei g 1 g*.. -ner >* rir as- theh charac-ter nt.- Iiri&naa valzt.rs The for.mat+., of a ma.ro strw t.n kiN, lord Irarv sVTnipt Ofl mr C ntt where s * the operand.list' and e omren+m, m-y ri in'.erteaved on su tcessiveS l ns:'s -- s.. tha matnra.1 f~or Jet.Lsa;S!_I * the comment mai not. a f& nCi;swA 04''i 7f% n nt anpear them oTrpers,nd.i.is+. is r, W -mat.r -90 o'p,:.nd eaeh of which Is a s.tring, of 0-255 e.q a,?% r",;er, wh ornforms to the following rules: It mniv not 3be a rvwvn. r wyrolit must -ornr -r.to the i l,)'ThsDI -() h- 4vlng apostroephies within a mintoed. th.: s,-trt ir' n * Yprert+hese muast e. i ttr x wtl t h.n a qlioted charace'ter strlng the hact~; % j-'nre- <I e, 8 tsited o'f ~mU..e, ad?,..st+, i..'...... ~ -inside ~' 1 * as td ev 0 n Ptrer mimber *-t'y sopn e8... tr;<d utmm ~d V~ f V P1 te n nr1br pitr'f that aa 1r.,P,nmsrserd MiX it>'N the fit Cha, aetPr * eomMa~ mao, arP* o-'Y P Ir sr!!:,'mhl a ut)ho..d harat,, er stri.ng or w i.+, n bTlahn erd pw oint hwter. blanIk ray appn okry w~:qh s.p r ol'i en-. Taa.ceter strAin g * Argument value.ss iSng. WEbpn, ma. <.ro d Itv.fll Itsn is'tnvoked. M, - ma,.ero l.nstruiet,.~n the values:f 4,he.K-,rmo l- a, +- ord rr'+ et.,+trl ng val ias of the eotrt.d a nor - ilsr,,b.fl.' r Wt"a.'t,, I I', r+, tyre osf t.he miac8re d.ef.initi.ons, Posi+..tional r..o'-._.rr,snoni,: ~b 1:t A!:,, e,1,+ eaa,=, whb'ech +h~9 e+.1b sy- bolt' e,,._,, ~t..,+: Ya,-4r.?, t"'',ai:. "71tfie ~:- t +ak. e on thp v'alu,,'9t. the i+, h I. o>:w. and _ ~.i o t. r ]..'rs+4.Any operand ma;y b +.,'1:' ttd a.,d 54+~ +-nij5].::'t V t alsPobeo i.. -.,.. n * iE. 9*.F.r ~m, yi r...........'.............:t....-... N-M....:n.i,..' 7

V' t3: I I 4 3? U \.st I -lf a poritlotna oo r'r n i Is o! i ttedr ther tP-h cv)rresp O, i8I nr syp)olie I rwra # t r; give? t c rf) } strin g as its. va'T.1,., * Keyword cos-rrsP lnte nre, I T hT +.l'a r 4,nr,,:, * rave of' +le -'r.m \bol:ie param*ete s i -h is t o reet eP-r o i; p P t l n1s c-vt v I q Pa4c fC t int% t heonIerand lli st. a - l''T Ot'Li t f rA.inesg 1 te cT re t vi Y I i n the ordepr of th)o J:-Znr- T-p ts 3;fc* p1t rIS3 M3 r O-: T of the syibo ] i e an + rh er w:e. * An elemrntS of +h pa he" t whPsas tq r Kr1; t Wn vhmbo e m n-mtco -. y. l, f,,, Phbv) a v..c ft,^' x J ),n 43 - w c tl'" B + 3 * An e1* m fn — v * t.r rq.ra I "h t 4 ~ol'. s; l r~ 1as, > a,. I. 1..,. wher.n? ne i'! t', Ts;r hta +., r h r.? yr. i si- t hasV thoe sam'e f, r, rf 1~'- -, r'... Tf. An)m.m+ of t%.a..,:. the v.e. t lip o' h, m.3 to ~ r -rt, -.':...i,.. v t ir t Pt,:,.. TI' j i dth +I lip,*~.< 0 of2 4~73eo *h *y).15 ft4>-. v~nsa..'.,;?...' j t..l t +2'i t v f 3-g ctarerP +er OtrI ru *,,.. M,..; ( p'... 3., M,.: p t-!, P'c 54".?i i 4, ~ -Trr.,.t r T j,,r 9~llp~hF~s~.~ft~t l~td ) m P P +:nsl $ etd a'tn-n *.. e r',.,.,r +?:.,., ]' t.,'t"-.i......... 3,i1'.lr.s a.:p ] _*;', m mqy be iia tn y ~' V."1 "-in. The forya.b cO."" I mvbo ].'

VIII.6 * sequence symbol * the eoneatenation of an ord.inary symbol with a va-ri.a.b!, symbol or a variable symbol with one or more acdditlional variable symbols. N.B. Concatenatotno may suallt y _y At dneoted. by juxtapos tion. But if the se iet t + m n th ~ concatenation beg.ins with a.lettgr dti', < (V C g', then the twoe items mt tt, t be r...,t.. by. a concatenation operator whleh I.s a' ~ name mny not appear when the operator i5 either ACT~2, COPY, END, TCTL,, TSEQ, or OPSYN * operator may b any of the following:. a reqular assembler opco4e any assembl.er pseudo-opcode except ENDO IC>, IS.EQO OPSYNor PRINT the name of another macro definition; variable symbol * operands is a string composed of-, ordinary symbols -or variable symbols o or odi.nary and variable symbols cone.at.eated together (The'*' concatenation operator must be used when an ordinary symbol beginning with a l.eter, a digiht.'(, or ~ follows a variable symbol ) TX. Some s.mplp examples. Figures 1, 2, and 3 show thre versIons of a simple entry poInt macro, f'rst with positional paramete, then with keyword parameters, and finally with a mixture. Figure 4 shows examples of concatenation. FIgure 5 shows the same macro as in Figue 4 except that it has been peppered with comments, Note that. ordinary comments generate a copy of themselves whenever the ma ro is invoked. * a comment pr.eceded by' *' in nolumns 1 and 2 does not!>nerte. anything., i.t. Is a comment wi.thin the macro-assembler T.hP:'te e o comments gfven~ at the end o. model statements a.ppar in the assembler statements generated from tahe model.+7tt-eet a *. variable symbol aarng in aparn ny comment is never't )laced by its value.

L 0"JC i JBJE CODE ADD R I ADDPR 2 STMT SOURCE STATEMENT 1?'ACRC 2 6L BURBAC K &RlqR2,fRC 3 &L L 13,eti,1 3) 4.* BOGUS USING AND DROP -- BELIEVE ME FOR AWHILE, IT'S CORRECr 5 BR&SYSNDX EQU 0 6 USING 6R& SYSNDX1 3 7 LM &,&R2,8 aR SYSNDX+12i-4*(($R1+2)-(( r1*2)/l616fl 8 CROP 13 9 LA 15 &RC.(C, 0) 10 BR 14 11 POE ND 12 * 13 EXIT ERBACK 15.7,0 2Arn;S C%1~:4 flit~U5 i3D 0004 C004 14+E[XIT L 1.3 t4V (3 13) 1s5+BPcOo EQU 0 164 LSING EROOOI,13 iY)0 0' )EF7 jOlo 00010 1 7+ LM 15,7,o 0 BR 1+1 4 2 *(4 152 ( 2 () - 15 +2) /1)) 18+ DROP 13 0 J3J6 41F0 0900 00000 19+ LA 15t0(0,0) )7F)r F 20+ BR, 14 21?2 EXITI BRBACK 4,9,4 O1~~33f0DL 5 00004004 23+EXITI L 13t,4(,13)'3 i 3 3 24+BROO02 ECU 0 0 i i L'i 25+ LSING B 0 10,0 3 j Uc1? 9 3 d c1 2't 00)24 2 6 L 4i 9 t' 2 + 1 2 0 4 ((4 *2 ) 4 + 2 )1/6 6)) 27+ O P P 1,3 j ~ 3 3 1 IL 0004 OGO Q:'r i~ O L~- Ci 8 1~ 4 Z~s f,.. 64 Z ~2 83 + A ) 4 r -I A1I\ U7 TC ER 1 4 30* 3 1 E N P ~~Q ~~~~x:)

LJC OBJECT CODE ADDRI AODP2 STMT SOURCE STATEMENT 1 MACRO 2 &LAB SAFECALL &OPD1,ECPD2,&CALL 3 &LAB STM &OPD1 &OPD2,&SYS ECTSVSNDX 4 N1VOKE &CALL 5 LM &OPDI,&OPD2t&SYSECT&SYSNDX 6 B JkSYSNDX 7 &SYSECTESYSNDX DS 16F 8 J&SYSNOX EQU 9 MEND 10* LI POAC RO 12 ~LAB INVOKE &TARGET 13 ST 13v&SYSECT&SYSNDX 14 LA 13,tSYSECT&SYSNOX+4 15 BAL 14t&TARGET 16 L 13,&SYSFCTESYSNDX 17 8 J&SYSNOX 18 &SYSECT&SYSNDX DS 19F 19 JSYSNOX EQU 20 MEND 21 * )3 CC" 22 ONE CSECT 23 LSING *,15 24 SAFECALL 14,12,BOGUS OJJa~rhJ 9)E7 FO6C 0006C 25+ STM 14t2, ONEOOOI JM0004 500D F018 00018 26+ ST 13,UONEOO2 li u2'Ji 41U2) Fr)IC 0001C 27+ LA 13, ON[00 OC2+4 Q) 4u.'ie FOAC OCCAC 28+ BAL 1 4,v B O';US ATe I 58L) F018 00018 29+ L 13,ONEOOO2 5 Cj'i 47F) F064 00064 30+ 8 JOO2 Allen, 8 31+ONE0002 DS 19F O3~~cb ~ &324J0002 EOU C) C23 a -j L F06C 00060 33+ LM 1't,12,ONEOCOI QCOk&8 47F) FOAC OOOAC 34+ 8 J0OOD 0 a 0 Li 5 G" 35+ONEOOl ODS 16F )Z4ZOAC 36+jOCO1 EQU )J 00AC 37 BOGUS EQU 38* PTUIJRE 7:i Use of the &SYSECT system variable and an example of the use of F~t,)7 k~C~YCWPIII ~nrJ Rr~Vr~Fil~T w~+h4mn oaa i v mrrrn e% 3 + + ^nt

330B3 39 TWO CSECT ]33563 40 USING *,15 41 SAFECALL 10,3,BOCUSI 003300 90A3 F06C OOllC 42+ STM 10,3,TWO0003 J330-t 5D03 FO18 000C8 43+ ST 13,TW00004 D3Oa.8 41 tD FOlC OOOCiC 44+ LA 139TWo0004+4 ) 3 3'C 45E) FOAC 0015C 45+ BAL 14,O B US1 3)J0CD 5800) F018 00C8 46+ L 137 TWD.0004 i0O33)C. 47FJ FO04 00114 47+ B J0004 ) ) 3"' C 3 48+ TWO0004 DS 19F O3 O011 49+JO004 EQU * J3 )211 93A3 F06C OOl C 50+ LM 10,3,TWOCO03 )) 0i8 47F3 FJOAC 0015C 51+ B J0003 oO 31 1C 52+TWOOO0003 DS 16F 33315C 53+JO003 ECU * 0001 5 C 54 BOGUS1 EQU 55 * 56 END FTnIRE?:.. contl nued.

VIII. 16 XI T L.tt9 of'' iParamete. t Is freqiu.ntly eonven1ntpt to t hink of sever..3 a._m._mentr, to a macro.lnvoeatI n a.s fo!.nr g an o-eri Td aollee+1r. on,* The pogs1%blitr r.r havit. a vari ablp sied. eol1etion ~s the most. interesating a..tn+, more on +.ha.+ T.ter, The tormntnPr a groii p4' n a rnas1. w o 9'd t^ n p.,ontpheese ts arrnd,von as nre olement 1-n the orn.-v wd 1rt- rt nrr +-tl mwt re. nn. only7 on-e T..v1 of group1fr ~ all a ), 1 s t v t Y..........1a. T.....-. t r - n &!n P ~n o'mnt of n. )> tt s?The.en...!.pord. qpar.~,metr9 /t,l.- +~r,1 o kao.yn~ ser fves3 ac. na mm fnr +he frt!rh. l. s,,, + Id'AIvid eim,on-+,rt, f th-fe list may be srlTectrd by a s.1nle ~txrer'- a.t',ed ~i.c ~rcSrt enclosed in parentheses, Tf the s,a&rpri t?, val.e ~n pn.stv.e a.rr cr.!ee+ts as nex!,stert element then the.nvl.7. 1hs'r-+a.e+,.r t+.rinf value.is use~.d., Tho: e.~"+ir. Apott.on,, pnrti.on f' a.n o:3.r~id!._it i.my,.. refe. ne.Ped as,a i. st by ln a +_,th..t.em vqariah!lt,;:Sl: T. T FrP * A singlr, -lhs-rip~p tI e &.fT TSTTP(? n sAc. t, the.t+ go? * +i' na.+.!.al i3,a,:'~m,'+,, * A dourlp. ase-br'ut, t, eo M secYTSs Ithe mt+h.e.impnnt of tbhe let+, which.-'.*s:, rn, ~h.. ",th osito tral..g.s're 8 s, and Q grve examol9es

'C OUBJELT A ADORI ADDR2 STMT SOURCE STATEMENT 1 MACRO 2 &L 8RBACK ~RS, ~RC 3 (L L 13,4( 13}) 4 -* STILL HAVE BOGUS USING AND DROP -- KEEP THE FAITH 5 3R&SYSNDX EQU 0 6 USING BR&SYSNDX, 1 3 7 LM &RS 1 RS(2),BR&SyS NDX +12+4* ( ( ( 1+2 - RS( 1+2/1*'6*16)) 8 DROP 13 9 LA 15,&RC (CO0) 10 BR 14 11 MEND 12 * 13 EXIT BRBACK (15,7),0 )'] 58D]3 0004 00004 14+EXIT L 13,4{(313) )00J 1 -15+ BROOOI EQU 0 )090 16+ LSING BR0001,13 )O0' 98F7 DOiO 00010 17+ LM 15,7,BR00C1+12+4*(1 5+2)- (15+2 2)/16*I6)) 18+ DROP 13 >-38 41FO 00 0000000 19+ LA 15,0(3,0) ]0%] 07F_ 20+ BR 14 21 22 EXI T1 BRBACK (4,9),4 333E 58D) DO04 00004 23+EXIT1 L 13B,4(0,13}) 0 03 24+BR0002 EQU 0 D3DO 25+ USING BR0002,13 301_ 9.543 4 )024 C0024 26+ LM 4,9,BROOO2+12+4*( 4+2)-t(4+2)/16*16 ) 27+ DROP 13 0 16 41FO 0004 00004 28+ LA 15 4 (9,0 301A J7FE 29+ BR 14 30 * 31 END FT4T1RE 8: Llsts as arguments to an invoca+tion.

[ TtJ EC ADDRI ADDR2 STMT SOURCE STATEMENT 1 MACRO 2 EL ePBACK 3.* CAN'T PUT A COMMENT IN THE COMMENT Ft ELD OF THE PROTOTYPE SINCE 4.*THERE ISN'T ANY PARAMERTER LIST -- HAVE TO PUT IT HERE 5 EL L 13,4(0,13) 6.* BOGUS tSING AND SAVE -- DONE BETTER IN LATER EXAMPLE 7 BP. SYSNDX EQU 0 8 USING- BR&SYSNDX,13.9 LM CSYSLI S r (.1 ),1 ~ SYS LSTI S ( 1, 2, BRCSYSN DX+12+4* t ( (SYSL IS rf ( 1, 1}+2 }-{ ( SYSLIST ( 1,1 )+2 /16*16) 10 DROP 13 11 LA 15,&SYSLIST (2). (0,C 12 BR 14 13 PIEND 14 * 15 EXIT BRBACK (15,7),0 Jj 580D) D004 00004 16+EXIT L 13,4(0,13) 3 %a17+000 ROOO1 ECU 0 D3!18+ LSING BROOO 113 ~ 98F1 OtOl 00010 19+ L 15 7,BRO01+12+4* 1 15+2)- (( 15+2)/1616)) 20+ DROP 13 A8 41FO 0000 000co 21+ LA 15,0(09,0 3, 07FE 22+ BR 14 23 * 24 EXI T BRBACK (4,9)t4 E 58D3 D004 00004 25+E XITI L 13,4(3,13 J3 26+ 8P.002 ECU 0 27+ LSING BR0002,13 12 98 4 D0'24 00024 28+ LM 49, BR00 O 2 + 12+4*t (4 + 2 ) -(4+2 /16*1 6} 29+ DROP 13 15 41F 0004 00004 30+ LA 15,4(0C0) l 4 07FE 31+ BR 14 32 * 33 END FITrTJRE 9: UTse of the &SYSLTST system variable,

VIII,19 XITW COJnditiona Aembi Sm.atrrrt.;.. T..e,.t... l o ~...... ar~t~h'?+1e,} 10510-al asnd ehaarart#r +rwlniw4l%.e Ne t r*srrVlr I.;.t4L not on e...,' h.a. ~rel the'n~n yreY st e. rr -orf' i -n i 1 S I i A r — e'sr P flt a + p rflar Itr +ho 3Th.-bn b p tahe t -n er Wnf + r T-f n gnag~13 on * The typ o f a SF;ma e — * ar.t. + (.f.or S A -, SEAL t.] ~ w...h.. -.... r _+.. r.. r *, inarrl.or ra.. hr. P..]r, rl" t;mwv,>l _..... f....r..... Y...t.-t. 0'..fo.r f..se, or I1 ("or tr'.... hrr.ae.ta r f Or. SETC+ s -.Mboi.s) w. Ath a. -e rSoar.> ro twh~ rb h h.,-s at mott o r-., n, &r tee * Cnversio ao n, t'.. ~ he +.v...i doe. he..y, _.t,,..r.; -....1?.... J.. and rirlil.es +he.a.e o. td t- i.tltl t A,] her!A-+ h.t o+ fl.,. YThsmb +l ts I. t s snore wh h mab pr A I + Ir' * Tonal ho OP Is dr'nfe ci; 4 U> nrngra'n ew t (e.h. a.......w.at._;ro:.-...,..f. i... ". P,,.. r oIr.,here I. s de.larped and Its n~Wtt;bqj?'~ (wW I-t t tthr?.r +t 110 <3, l t p %n~* r-l ~, +,%r>, -; rp rrg Ho r rC, rrn tt.-> tf -.>v -tEp er +fi 4 C! e -... -....t..d.t$.... ft t -..a...ri. lv whir4n. i s + b... t..,a rnasv..o,~+, dfvt,+, owhi.i +h. ~vnkc+d wo~! r fol t. ]_ *.. ~: _, ba - th. ra@' t-* l, ~ -f odwth nvr, sgm wher. I.t. ~ de lard ard I ts irA 1 vs I so o> rnr'o r+ 4k. grrinn.l o-f of' + st~Mv Ibn.r +Wp to rrv gin np s u r ed tnst t r t o Ate ~. was'' f ~ Tha fla1 aitlk;nted of a SFI-asyne 1 wa t, -tsrb, i. r< tr tntl. n VS FM or o dlm. si, nede vortha'].e, Tf i,. ~..~ ri d-ter-s~'nAe? j I on1y a s - ng Th dtentio.. ims a i, S owd-, l it a'ioz mwt.x. b.',.tween 1 axn 2n 00 P) eia. r,.n. a ni, on. SEt-,r-v..syvb *il 1. N~rb~l-dn r> ot'*nD,,+4, rO TOT>' T f; f3 JlTC2, > 13.d. n A A, on +.hp p O-rm t..n~e type of the.var DOh ~,., M. p.......... ~:._. ~. ~..... gr-,,-~ - q zr m,:,t ).'

VIII.20. glob.l SF-syimbos are deeslarod wthikn e~eh nror.ram segment whic'h wants to rpeferenre the h r val o bBy an nStr,'etdon of the fo.: lank g-d'e1on ne mel i st.5 where nameit a.St i a s def'i#oR a~ote St d flo ~te l.~ g~er CtLA, IG3TB, or CBGLC depend.ing on +the typ, nof ~+he varl.abls bP..ng..f +th; SET-symbol is to be dimni.one +.Ihen t..p.iars in t he namne]ist o1tf its decalarat+,ion with 1t, s ii~ze,. iven a.s at. int,eger nonsta.nt, enelosed.in.aren+theses fol.lowImn,+, Tf othe SW.symbol I s global then every declaration of At mit ustt iloite the,same siZe, * mn. any sst of de&iarmt!.ons, the one.'or glo.l. SFT — smbo..s muf preered +~hose for l ocal SF-symb ]1 fttr7ibotps.~ These ar'e.sse'te.1~, v rtredeftred 4,ino+ti.ons whiTh may..... u ~sd to-e O)Ier-v q!.1rh s tvt s i % P,,t.. h.. ealn.... of SET-symbols,.md.l.nary ~y.ho].sa. nId sym boli c..m+,Pcsb * The attri bu +^s of a. gyi3 m fparaetr >bea avre t "ose I $4h t.ronm 4:,.orr.pond. l, i. p...gr.i ii+,, The a+.ttibt1+es of a l..st are, reraril thrse of' +, fh ist item!. the ist.* *'The Rvia.Va. be at.,rlbrvtft ar- e T - retitirns n s~lre ol a.otier de,not + thp -+v; 2A Indloates an A-+,yne. addMrss oon staO t. B haInd!dcart.es a bi.nary oonsta.nt C l nd.a I.+tosa M eharater constan;, I' pt t+,.ns an t!+,erer num,''F r A.t.det,'f.n-t the um.iNr of.bytes alloena+:ted +t i. e sym i.. ~ W' - *sea.le Ffaetor of -+h Svm..ol - T' - w.dt1h of +.he ln+.,nge~ f- ]d r,'h.b sS.. bo -r I 1 So F 5 Pd D T -.,d * X S 3 * ~oat~.s n~ T,. o*( (t 1~, r () -,.q'. - Paked: *r S' - * K' n- t.ober ci"f oh., arTo.r, * a — a. et. wSh, -the.a -umen+. $ i a [.~+. ~.ha +.he courJt -. nelude' oa'rentheses * s ~nomm~

VIII.21 N' - number of items n n a list * K' and N' may be lsed only ti.,sde mar; o definitions. Opersti nons on SETA-symbols.a]. evalu.tion, i..s done in 32-b+it signed ~nteger a ithmietir * charaeter strlngs,are nonverted to nn+egerr If p reesssar-y i.f the stringP does not represen.t an l.nteperh then an error Is rai sed ~ whan a SETA-symbol] 4s sed in a rode.l s, +a+~men+.,, +t. a.bsolute value is reonve.rted to ai str. ng and lead ing bl.ank, are del e+nd * the asisTnment, statement, for set ti1ng: v a I of1 FT.A -ym bo h.s's the fom SETA —sv bnt STA Pn3ol S ar where t+,he.nressnon I -.om'rosm.d of v4a-zipn,]t. v.mv~Y.o.'I a.o_, pd by +.he operat or4 ~, s - at / w-+ - a l o wA.. ef.d r rav4ni a 4t 1. o.t r ngoverrfl' 1o t nof H-f ePill r't A ~.oe r4t.r-ln +wa f fir nal., 4, +be tRwR~ p J'.AO'.,r t, +,vse?)iMIes n fi rsl t an c.. Em-st?h. ]. + ith g'1 n - a-nd mi. S-obal s'

L CC OBJECT CDOE ADORI ADDR2 STMT SOURCE STATEMENT I MACRO 2 &LABEL BRBACK &R=(1412),&RC=03.* NOW WE CAN DO IT RIGHT 4 LCLA &OFF 5 &LABEL L 1 34(01 3) 6 LOFF SETA 12+4*((&R(1)+2)-UE&Rf1)+2-)f6/ ) 7 LM &R(1),&R(2),&OFF.(13) 8 LA 15,vRC.(C 9) 9 BR 14 10 MEND 11* 12 BOTTOM BRBACK RC=-,R=(71I2) )OJCLJ 58s0 -)O4 00004 13+BOTTOM L 13,4(0,13) )3 0 U 987% Y 330 00030 14+ LA4 7, a12,'8( 1 3) 0030L0 41F) 0004 00004 15+ LA 15,4(090) &03U3~ OT7F 16+ BR 14 17 * 18 ROCK ERBACK R=, 9),RC=4 0 30 5aDo )fU04 00004 1i9+ RCK L 1394(3,13) 3030,12 9349 I024 OC024 20+ LM 4,9, 36 (13) 33DI~~ 41F) 0004 00004 21+ LA 15,4(0,0) OO3hIA G7FE 22+ OR 14 23 * 24 END FIcUJRE 10: Use of SETA symbols.

LOC OBJECT CODE ADDRI AUL)R2 STMT SOURCE STATEMENT I MACRO 2 &LAB BRBACK ~RC 3.* THE RIGHT WAY AGAIN, BUT THIS TIME USING GLOBAL SYMBOLS TO 4.* PASS SCMF OF THE ARGUMIENTS 5 GBLA &RLER2 6 LCLA &OFF 7 SLAB L 13 t,4(O, 13) 8 &OFF SETA 12+4*( (&R1+2)- ((&Rl2)/16*16)) 9 LM &R1I&R29&OFF.13) 10 LA 15,&RC.(O 0) 11 BR 14 12 MEND 13 * 14 GBLA LR1,&R2 15 * 16 &RI SETA 7 17 &R2 SFTA 12 lB BOTTUM BRBACK 4 000300 5800 0004 000C4 19+BOTTOM L 13,P4(013) C00004 987C 0030 00030 20+ LM 71,1248(13) C00008 41FO 0004 000C4 21+ LA 15p4(0#0) OOOOOC 07FE 22* BR 14 23 * 24 &R1 SETA 4 25 &R2 SETA 9 26 ROCK BRBACK 4 GOOJOO 5890 D004 00004 274ROCK L 13,4(0,13) 000012 9849 9024 30024 28+ LM 4,9,36(13) 000016 41FO 0004 00004 29+ LA 15,4(0,0) Q000A W7FE 30+ BR 14 31 32 END FTCURE 11: The example given in Figure 10, redone with the use of some global, variables.

VIII.24 Ope-ra+ 4ons on SEIfT-,ymbo1s n* roncateratlo.o n Is performed a-' w v're'xst( —apiptio opl r normal.y bT tsed, but t+he.'' ooncatenat' on o.~.+.nr mtust. be, sed whenever t he,second. item I the eronratratton begins with a le+tetr, dig.lt.,(, r' for the rest of +his rd3 IsusXsSir'n we nped the. fo1lowirt' Hp -cInltln:ow A pchnranct %ter expression l a rird osf orn+- +ha gn 255 characters enencosed in prenthesn,, wh ch i.s composed of ordinarv and variable svrnbois (be.*-. s.bo]~.e pa.smetere and S.T-sym.bols). nn^atentatedl +tv.,e+ther; any Tnstanee of a variable ymbhol. wl11 b r. laced by the val,..l of the variabl]e symbol, o a subs-tring selection operation may be performed by Usi.n:e charateer-ex presp oI (n. +_ l ngt a )h where first and length may n'o+ express35 orns and must evaluate to integer valTles: note tha+ the subhscript.spl&.ctors may only beon. applied. to har.actr expresesions and thatt the nuimbering of the haraeter positIons in a character expression beFIns wt.+. 1 * the asgnme~+ statemer+ for se+tting vautes of'STC- symboIs ha.; the form: S_- s vmbol SET(C c-,xr r where c-expr.s the concatenation of one or more character expr!essions and slubstring selecntIonhs, F rigur~e 12 gives a, simnDe example of the ulsse of SETC-rsymbols; 1i.ds admIt.r.edl]y ad hoe (better exap]Th.PS will follow) but t+, shows most of t+he opera ions mentif oned aboveF

LOC OBJECT CODE AUDRI ADDR2 STMT SOURCE STATEMENT I MACRO 2 &LAB ADHOC &PRE,&SUFS 3 LCLC ES1,&S2,&bOGUS 4 LS1 SETC'&SUFS (1,1).5 ES2 SETC'&SUFS (2,1) 6 &BO(GUS SETC'&PRE.123''1&S2&S1I 7 EPRELS1I DC C &PRE&S1' 8 &PRE*E S,2 DC CeLPREES2' 9 &PRE DC CI&BOGUS 1 0 MEND 12 LI ADHOC F iAB 000000 C6FIC1I 13+FIA DC C' FI' 000003 C6F1C2 14.+F IB DC C'F L B 000006 C6F1FIF2F3C2C1. 15+F1 DC CIF1123BA' 16 * 17 L2 ADHOC IAB QOQOOD C1 18+A DC CMAI GOOOQO C2 19+8 DC C#13 QOOQOF FlF2F3C2Cl. 20+ DC C'123BA 21 * 22 L3 ADHOC F3,ABC 000014 C6F3C1 23+F3A DC CIF3A' 000017 C6F3C2 24+F38 DC C~'FF38 I Q000QA C6F3F1F2F3C2C1. 25+F3. DC CIF31238A' 26 * 21- L4 ADHOC F4,A *** ERROR *** 000021 C6F4C1 28g-F4A DC C'F4A' 000024 C6F4 29iF4 DC CI'F48 000026 C6F4FlF2F3CI 30+ 4 DC C'F4t123A' *** ERROR *** 31 * 32 END DIAGNOSTICS STMT ERROR COUE MESSAGE 27 ASMG0671 EXPRESSION I OF SUBSTRING GREATER THAN LENGTH OF CHARACTER EXPRESSION. 30 ASMG0231 QPREVIOUSLY DEFINED NAME. FIGURE 1?: illustrations of the use and misuse of SETO symbols.

VIII.26 Operations I nvolving SETB-syrmbols o the value of a SETB-symbol. is either 0 or 1, havi.ng the meaning false o r true respeetively * thebse v $l)es are produced by * the comparison of arithmetic or character vait.els by iusing the comparison operators EQ NE, ILT, GT, TEt and GE * the combination of SE B-symbols, O's, l' s, and comparisons b: using the logical operators NOT, AN), and OR * these operators muxst always be preceded and f ollowed by at least one break character (bl.nk, parentheses, or sIngle quote marks) * conversion is do ne as necessary and as -posssiblee wi.th the. intit ively expected resul.ts, the ass ignment of a value to a SETF-symbnol is accomplished by a.r. tnstrcetli.on of the form, SETB-symbol SETB (l1-expr) where ].-expr i.s either a ln.osical cons+ta-,nt (0 or 1), a SETRsymbol, a comparison, or a logical expression formed. from any of these by f using the by n he logical operators SFrT~-symbo]s and logical va.lu.ed expressions are most natural ly used in the control s+tatements which are taken up next -- examples of their use are therefore delayed until after that d iscussion

VIII.27 Condition al Transfer and Iteration - the final set of instructions in the macro-assembly language are those for effecting conditional transfer and iteration.. the ANOP instruction has the form sequence symbol ANOP blank and serves exactly the same function as the Fortran continue statement. the AGO instruction has the form [sequence symbol] AGO sequence symbol and is used for unconditional transfer of control * the AIF statement has the form [sequence symbol, ATF (l-expr)sequence symbol where l-expr Is as defined on the previous paeget the instruction may be used to effect the conditional transfer of control * there are no instructlons for the direct expression of iteration and loops must be programmed by )sting the conditional transfer statement. There is one instri.etlon for use in controlling the number of times a loop is travers.ed, but it is designed for error checking rather than iteration. It has the form blank ACTR expression where expression is a SETA expression as defined in a previous section. Tit is used to set an upper limit on the number of AIF and AGO instructions that should be executed local to the appearence of the ACTR instruction, i.e. within the same macro definition or within the main program -- the default value for this limit is 4096. When that lI.mit is reached, transfer is automatically made to the next program instruction following the macro instruction at the highest. level of currently nested macro instructions -- if the 1!mit is reached within the main program rather than within a racro definit+ion, then transfer is made to the END statement. Note that the limit is a local value and follows all the rules for such. * the MEXIT instruction has the form sequence symbol] ME!X IT blank and is the same as a Fortran return statement the MNOTE instruction has the form

VIII.28 v eqarvabe s~.ymbnSl MgrNOTMF [ ] Charact..er,.r,M. vanl alll b1 symbnI a where h Fnar ter-strlrpo l, ~s def fl ned in the setenton on SFPTC Vsnt.mols -and r'ode Is a nulme-r betwee.n 1 and?<55 (1 ain d n, e sndo. i., om ~nted) or ain, When t.h],.+ru+.+o$n is noe(oriint+eri w-thirn a ma^y- definitlrn' (.rnd'+ ra'r t, -" omna, w!r4+,~., ~a.t~.o de..n-+ro.-.., ~...,+<-^>- ^ +tt$~|S1 <s.,epld 4 s figured into the running account of the severity of the err.ors (wh.^,h af.fects th%.,bsel lat?rneesin pf +.he rt', af +'r a. eTmbly is finished) x:nr wheI) h.r e i * in which ~82Sa',.'r%' mMoif r.ed nh at.+p s.trinv r~ v+ — r+, i a a +t'mnt,, thp, remm-ilinirg flgiirps 11.11o:+,Jtratr, t^ - fA~ In nf r5tri- is ons.'rr!ze 1'~ nhows a mtaro -or a 1ed rt9<oe-5> shrarter.-po.t n a.rd iilrst t +h- + thse nsn o thp iti. on1.tr7Tnf ins~,...tA on:. F~.guires 14, 15,nd I 1 tie three vers.ions -f'. m..rno fr.l n l'.la.t,i.ng t.he fa~torll of - n.m),,bert fr.ft by constrtt. n.ode. to do.S. t. eitna. l hn.bNr h. -..cr.;h:. o,.;13 1atant-;aetasn^rl olvy tl"Iet1 wi+ h in 4rtr a,1< 0 ort7hg ar, r?17 b'y doln the e.Rlt,+,,,SztnP +z~ tr,a rl; rn,1 v^ ager hr,.z

LOC OBJ FCT CrU0D ADOVfa 1 AIPR1tSK2 ST I STECLRCE STATFYENT I?" A C R C 2 CLABEL NCVEVE T C r C V 3 LCLA ~L F N tf'CT R F, )FF 4 LC L3 C0CGNL 5 M11 N CT E,'GE E N A IILED MOVE CHARACTER' 6 ELAEL EQU * 7 ** FIRST CHECK THE LEGALITY OF THE: OPERANDS A I F (T'&T.O0 EQ'C'). F)K 9 ~ ~ 1N'NTt,'ITC IS NOT A CHARACTER FIELD' 10 MEXtT 11.FCK ALF (T'&FRCM EQ'C' ).SOK 12 f"NCTE'&FRCM IS NOTT A CHARACTER FIELD' 13 (VEX IT 14.4 THE NUMBER OF CHARACT1ERS 10 BE MOVEd IS THE LENGTH OF THF 15 ** SHEPTER CF THE TWC FIELDOS IA 6.SCK ALE(L't&TC;T L'&FRJM).FLEN 17 ~LEN SETA L'&TC 18 AGC SCONT 19.FLEI\ ANEP 2C FLFN SE T A L'&FRC 21 SCCNT ANP 22 N. NE1 LA Y 0 DG,4 N T H E APPRI PRIATE NUMBER OF 2.3. 4 t C I N S TR UC T I CNS 24 ECTR SETA 0 25.LCCF ANCP 26 EC C N C SET1 (&LEN L 256) 27 AfF (&CrNO).LAST 28 ECFF SRTA CT P *2 56 29; IVVC FT04-UJ 0FT *(256),&FROM 30 ECIR SETa FCTR+1 31 FL.EN SETA &LEN-25f6 32 AG. L CP 33.LAST ANCEP 34 rCFF: S ETA &CT Q 5f'25 35 IV VC &T U + F, C F F, (LLENbE FROM 36 i;E N 1 FIGUJRE 13: A generalized move-character macro illustrating the use of conditional macro-assembler statements. continued....

37 3)')OQ 35q nUSNG I, i 5 4.C F[I. cVF STPRA$STRP 41 *,GENERALIZED MO, VE CHARACTER 00 O 42 +f R5S T EQl 3000 D2FF F61 2 F2C6 COCti2 tC2C6 43+ fVC ST P A+O (256),STR )0, 02 D F2 112 F2C6 0iCl I 312 2C6 444+ VC ST RaA+256 (44),STRB 45 * 46 SFC C ) NCVF STRPBSTRC 47 *, GfNERAL ZED MOVE CHAR ACTER, 0 0C 4+ SECCr.C EQU * OOOC 21.3 F206 F58A 002Ct- 0C58A 43+ t'VC STRB+0 (20),ST'RC 51 TH! Rr NCVF- ST RCNCTAS T R 52 *,GENEFkRALIZtD) Mf1VE CHARACTER 0 12 53+THI PC ECUJ 54 NOT AST R IS NOT A CHARACTER F IEL 55 * 56 * 0012 57 STRA DS CL500 0206b 5 P STR. CS% 3CL300 05 >1A 5q STRC [3S CL20) 05 AOC 6C N 0IIR IS TP SD 61' 62 ErND DI AGNOST I CS T I'T ERR. UR CtUF t! t;E SSAt;F 54 ASMCqO.?7 1 MNITfE STA TE M Fl T I STATEMENT FLAhGGED F) THI S ASSEBLY F FIGURE 13: *,.,continued

L.'IC 06bJ FCT Cl) D F- ADODP I AtI4DhR2 S T 1 T SCRiJCE STA EM ENT 1. pACRO 2 fLA3E L. FACT N PFC 3 7L A &TCMP 4 LCA &FV ENN C CO LCL b &TIS EVEN 6 * 4 GtIT AN EVEN-Cf)D REGISTER, PAIR 7 U SE VE N S[TEi (UREG/2*2 EQ &REG) S, FEV~F SFTA &PFG A I F E. I S EV EN)N.SK PI IC &E dFN SET A EV EVN+ I U I*SKI P A tC P 12 EC., SETA F.EkI EN+ I 13 IV'N UTF *, LEVEN AND FW000 ARE USED FOR CALC'S 14 *~ $ CCNISTPUICT COODE FOR CALCULAT TOi OF THE FACTORIAL 15 f L A I EL LA f &O1)0DD, I 1L6 LA FT E:P,&Nt &N 1 7 C TEEMP, =F-lOo IS f3E F.SYSNCX 19 LCSYSINCX V R E V &EV tEN EM P ~C r13 CT Z, T F M Pt,,S YS rl OX 2 1 EF.SYSNOX L R &PEGICFICV 22 9FN~) FIUIJRE 14: A macro which constructs the code f or the calculation of n continued., (p*

23. 24 G3LA GTEMP 000000 25 US I NG *,15 26 27 TEt:P SETA 2 2 3 FACT 6 t3 29 *,4 AND 5 ARE USED FOR CALC' S 000.00 415'0 3C() 0OCC1i 3C+ LA 541 000004 4120 0)COf 00 CCo s 31+ LA 2,6 00O00C i)P 5920 F03 C CCC3C 32+ C 2,=F'O' 0000C)C 47 80 F O 1 C 1 6 3 3 + BE FOO) l 000010, C4 34 + L OOL1 AR 4 2 00001 32 4620 FC1( COOC 35+ BCT 2tLOOOI1 00 016 1835 36+EOOOL LR 3,5 37 4' 38 ETEIFP SETA 5 39 F ACT 7,2 4= vf,2 ANC 3 ARE USED FOt) CAL C' S ~ 0() 18 4130' OCO I 0 0 1 + LA 1 OOOO1C 41 50 0007 O3CC 7 42+ LA 5,7 00 02'0 59 50 F C30 CCC3C 43+ C 5, F'O 000024 4790 FO2E CO02F 44+ BE EOO02 0000)28 1C25 45+L0002 VR 2,5 OO)?A 4t 7 65 F- C28 00 C02 46+ 8CT 5 LJ)U02 0Ji)032E 1823 47+0002 LR 2,3 48 * 4S END 00';)0030 0;)C0000000 50 =Fl'O FIGURE 14: ~...continued (A

LOC OBJ ECT CODE ADDR I AI3PR2 SP#T CKLRCE STATEMENT 1 ~~~~~MAC, R 2 &LABBEL FACT N R E C 3 * DMCNE BY AN ITERATIVE ALGORITHM 4 LCLA F,&CT R 5 &F SETA 1 6 &C TR SETA &N 7.LCCP A I F (FCTR EQ 0).END 8 EF, S E'T A FF*&CT P 9 &C TR SETA &CT R-1 10 AGC OLOOP 11.E NiD ANCP 12 ELABEL L &REG1=f1&FO 13 rPEND 14 4 900000 15 USING 4*,5 16 * 17 FACT 6,3 000000 583C F008 00008 18+ L 3,=F'7201 19 4 2C FACT 7,2 0000O4 5820 FOOC C)COCC 21= L 2,F-'5040' 23 END 800008W 00000200 24 =F'72O' OOOOOC 00011380 25 =F"5040' FIGURE 15: A macro which calculates no using an iterative algorithm.

L DiC JBJELT COEDE ADDRI 4DDR, 2 STMT SOURCE S T A T E M E N T 1 IMA CR 2 CSLABEL F A(C T piN, P RE0 3 ELA3EL FACTI 1 I E.', &;F, PIE 4 PEND 5 4t 6 VACRO 7 &LA3EE FACT] &ACCUM &N,REG 8 LC L A NEXT,&PPOD 9 AlF (&N EQ C),END 10 &P UO SETA FACCUPIE. 11 U'JNE XT SETA &N-1. 12 $LABEL FACT1 &PROD, NEXT &REG 13 ME XIT 14 EN'D ANJP 1 5 &LA3EL L &RES,=F'F &ACCUM' 16 MEND 17 * 003003 18 LSIN G *5 19* 20 FACT 6,3 J030iD 533)3 F'3C8 ( % 21+VLABEL L 3= F' 7 2 C 22 *~ 2-3 FAC T 0,5 )30004 5653 FOOC OCOOC 24+ L 5,=F I 25 * 26 END 3)0003 Co332DQ 2772 3 00Q C000 3( 1 28 FIGURE 16: A macro which calculates n! using a recursive algorithm.

IX.1 \ AtY2 (,.At., yt 7t \, >I& t i P- d~ * LVSW RI ) ~-A, (4 t>' 4 n, C)\ ) _r> tPjiw) K 7 C S. Rj?342 P ~~ i, zQi. Ci, L > -". V\, V.. -7t,~` ert or S s, y j" tcxt Ct;> ooc k' & 4 c(e: "\i t~1, C eS _ p X ) _-_; tiCe 9 V7S I )e 1.1ft4 i4;. B ID-Tl N Ba L-Ptv vIO < \ a^ b ----

IX.2 S FATUS SWITCHING: CPU STATES: Problem/Supervisor PSW bit 15 = 1/0 - privileged instructions executed only in supervisor state (I/O,'direct control, LPSW, SSM, SSK, ISK, DIAGNOSE) - state change requires whole new PSW Wait/Running - in wait state: - no instruction fetch, but timer runs - unmasked interrupts accepted - state change requires whole new PSW Masked/Interruptible - system mask PSW bits 0-7 I/O & external interrupt masks - machine check mask PSW bit 13 masks all system machine checks - program mask PSW bits 36-39 masks for fixed point and decimal overflow, exponent underflow, significance - in all cases, a bit = 0 indicates "masked off" - state changed by new PSW, or: SSM changes system mask SPM changes program mask Stopped/Operating (no PSW bit) - stopped state entered by machine malfunction or manually; no instruction fetch, no timer update, no interrupts accepted; left only by manual control - in operating state, instructions are executed (if not in wait state) and interrupts accepted (if not masked) Storage Protection: - each 2048 byte block of storage has 5 bit protection key: bits 0-3 store protect bit 4 fetch protect - operation: - store reference: PSW/channel key compared to storage block key (4 bits); store is permitted if: 1. keys match, or 2. PSW/channel key is zero storage unchanged on mismatch and protection interrupt generated - fetch reference: fetch bit = 0 fetch not monitored fetch bit = 1 fetch permitted if storage keys match (as above) - CPU/channel generated addresses not monitored (PSWs, CSW,... ) - may protect against store or against store-a-fetch, but not against fetch only - storage key set by SSK & may be inspected by ISK

IX.3 Interrupt System: When interrupt occurs and CPU is masked: a. I/O and external interrupts remain pending b. program and machine check interrupts ignored When interrupt occurs and CPU is not masked: a. current instruction completed, terminated, or suppressed b. current PSW stored in old PSW for interrupt class c. new PSW for interrupt class becomes current PSW for CPU - new PSW is effective immediately and is not checked until actually used by CPU Interrupt classes (by priority): class old/new PSWs interrutcode machine check 30/70 model dependent SVC 20/60 X ooii' ii from SVC program 28/68 X'ooop' p=l...F external 18/58 X ooee ee=80-timer I/O 38/78 X'ocdd' j c channel dd device for I/O interrupts, additional information is also stored in the CSW (channel status word), location 40, for the interrupt routine to peruse permanently allocated storage: 0 dw initial program loading PSW 8 dw initial program loading CCW1 10 dw initial program loading CCW2 18 dw external 20 dw SVC old PSWs 28 dw program 30 dw machsine check 38 dw I/O 40 dw CSW (channel status word) 48 fw CAW (channel address word) 4C fw unused 50 fw Timer 54 fw unused 58 dw external 60 dw SVC new PS new PSWs 68 dw program. 70 dw machine check 78 dw I/O 80 - diagnostic scanout area

IX.4 Sorftware responsibility: 1. set up new PSW locations with appropriate mask bits and instruction addresses 2. load and prepare interrupt routines at specified addresses 3. set current PSW to appropriate value Integral Timer: - 32 bit word at location 50-treated as'signed integer - low resolution timer - bit positions 21,23 reduced by 1 every 1/60 sec, or bit positions 21,22 reduced by 1 every 1/50 sec. - resultant resolution = 1/300 seconds - updated between instructions when access permitted - may be delayed or omitted under certain conditions - high resolution timer: - bit 31 reduced every "L 13 vsec - counts at 300 cps in bit position 23 - bits 24-31 in backup internal storage-location 50 updated periodically - may be delayed or omitted under certain conditions - in either case: 1. external interrupt generated when timer goes negative-timer keeps ticking 2. store/fetch reference to location 50 sets/gets full timer value 3. to change timer without losing tick: - put new value in fullword at 54 - MVC bytes 50-57 + bytes 4C-53 - timer has new value; old value at 4C

X.1 Input/Output (I/O) Storage ino._ ~ Channels CPU(s) control A * CU control unit,t CPU(s) I/O devices CPUs: execute I/O instructions initiate asynchronous I/O activity monitor I/O activity receive interrupts for I/O state changes Channels: at most 7 - numbered 0 thru 6 multiplexor/selector channels direct info flow between devices and storage - permit concurrent CPU & I/O activity provide standard I/O interface converts CPU control info to proper signal sequences assemble/disassemble data provide registers for channel program execution - decode and control channel commands may be one or more control units hooked to given channel - they share common bus Control Units: provide logical capability to control and operate I/O device(s) interprets channel sequences for devices controls data transfer timing over I/O interface provides device status to channel - control info to device one cu may attach to 1 or 2 channels cu may attach one or more devices I/O Devices: many of these: terminals, discs, drums, data cells, printers, readers, punches, other computers, etc. each has unique 16 bit address: 0-3 zero 4-7 channel (0-6) O = multiplexor 1-6=mpx or selector 8-15 cu and device (and subchannel on mpx channel) each path to device has unique address contiguous address sets required for shared subchannels or shared cu s addresses set by physical connections

X.2 Start I/O Instruction: SIO Do(B,) rightmost 16 bits of D,(B1) taken as I/O address CAW (location 48) provides key and channel program address: 48: key CW ddres s 0 34 78 31 Key: channel protection key CCW address: address of first (or only) CCW to be used CC setting: 0 I/O in progress 1 CSW stored (bits 32-47 only) 2 channel or subchannel busy 3 not operational Once started, things continue until: channel end (ce) device end (de) control unit end (cue) error or unusual condition All of these are signalled via an I/O interrupt (or several of them) program procedure: 1) establish CCW program 2) turn off I/O interrupts 3) set CAW 4) set new I/O PSW, if necessary 5) issue SIO 6) test cond code - if nonzero,...... 7) restore I/O interrupts system operation (simplified): 1) CPU executes SIO 2) CAW, first CCW -+ channel 3) proceed if path available 4) device address -+ all cus on channel 5) addressed cu logically attaches and returns its address 6) first command code - cu 7) device status byte + channel 8) SIO terminates - CPU freed 9) subchannel continues responding to cu/device service requests and executing CCW program 10) finally will receive ce and de (sometimes cue, also), possibly along with status bytes from device and channel

X.3 Other I/O instructions: TIO D (B!) test I/O tests status of selected path; sets cc as for SIO HIO DI (B/) halt I/O stops current operation on specified path, if there is one; sets cc to indicate effect and status TCH DI(BI) test channel tests specified channel only and sets cc; cu and device status ignored

X.4 Channel Commands (CCWs) each command (except TIC) initiates or continues I/O operation max info transferred = block, as defined by device I/O op terminates on block or byte count CCW format: DATA ADDR FLAGS COUNT CODE 0 7 8 31 32 36 37 39 40 47 48 63 DATA ADDR: address of first buffer byte COUNT: true byte length of buffer (>0) FLAGS: 32 CD=1 + data chaining 33 CC= - + command chaining 34 SLI=l + suppress incorrect length interrupt 35 SKIP=1 + suppress info transfer (input only) 36 PCI=l + give program controlled interrupt when CCW used COMM CODE: last 2 bits (ifO0), or last 4 bits, determine command all 8 bits + cu and device and may be used tihere as modifiers commands recognized: READ mmnmmm 10 sets channel for input and initiates read at device READ BACKWARD mmmmll100 as for READ, but backwards, if device supports it WR ITE mmmmrmmO 1 sets channel for output and initiates write at device CONTROL mmnmmnmll 1 channel set up for output flow and control op set up at device - control function specified by modifier bits or by data transferred to device TIC (transfer in channel) xxxx 100 next CCW fetched from data address - channel not informed - cannot TIC to TIC or have TIC as first CCW after SIO SENSE mmmm0100 sets channel for input and initiates sense op at device; device returns detailed status info unique to device and cu, one or more bytes; status is that at end of last I/O op on device

X.5 for most devices, first 6 bits of sense info are as follows: 0 command reject 1 intervention required 2 bus-out check 3 equipment check 4 data check 5 overrun Assembler CCW instruction: [symb] CCW CC,DA,F,C CC abs exp = command code DA exp = data address treated as AL3(DA) F abs exp = flags bits 37-39 must be set to 0 assembler zeroes bits 40-47 C abs exp = true byte count command is assembled in CCW format and aligned on double word - skipped bytes (if any) are zeroed Examples: For these examples, we assume: a. the device is similar to an IBM 1050, which is a typewriterlike device used in most System/360 systems as the operator's console b. the I/O address of the console is X'009' c. the device commands of interest are: READ (X'OA') reads EBCDIC bytes from the console followed by a carriage return; input lines are assumed to be variable length up to 100 bytes WRITER (X'09') writes EBCDIC bytes on console followed by carriage return WRITEN (X'01') writes EBCDIC bytes on console and leaves carriage at line end (no carriage return) d. the proper masking and unmasking of I/O interrupts is provided by surrounding code e. the following symbols are defined as shown in the assembly: READ EQU X'OA' WRITER EQU X'09' WRITEN EQU X'01' CDATA EQU X'80' data chain bit CCOMM EQU X'40 comm chain bit SLI EQU X'20' suppress length bit CAW EQU X' 48' CAW location OPCONS EQU X'009' op cons address f. the storage key for all I/O is 5

X.6 Example 1: read line from op console to AREA MVC CAW(4,0),MYCAW SIO OPCONS (O) BZ OK MYCAW DC X'50O',AL3(COMM) COMM CCW READ,AREA, SLI, L'AREA AREA DS CL100 Example 2: as above, but put first 10 bytes read in AREA and rest in BUFF MVC CAW(4, O),MYCAW SIO OPCONS (0) BZ OK COMM CCW READ,AREA,CDATA, 10 CCW READ,BUFF,SLI,90 MYCAW DC X'50',AL3 (COMM) AREA, BUFF definitions Example 3: write the string TOO MANY TASKS STARTED on the operator's console: MVC CAW (4,0), SETC SIO OPCONS (0) BZ STARTED SETC DC X150',AL3(CCW) CCW CCW WRITER, STR, 0, L' STR STR DC C' O3 TOO MANY TASKS STARTED' Example 4: write the string prefix MOUNT TAPE: with no carriage return, followed by a read from the console; prefix is string stored in PREFIX MVC CAW (4,0),MYCAW SIO OPCONS (O) BZ GOOD MYCAW DC X'50',AL3(COMS) COMS CCW WRITEN,PREF IX,CDATA, L' PREFIX CCW WRITEN,MESS, CCOMM, L'MESS CCW READ, BUFF, SLI, 100 MESS DC C'l MOUNT TAPE: 0' PREFIX, BUFF definitions

X.7 CSW (Channel Status Word): location 40 part, or all, of CSW is filled with I/O information during: 1. SIO, TIO, HIO if cc = 1; info pertains to addressed device 2. I/O interruption; info pertains to device whose address is in interrupt code portion of old I/O PSW (bits 16-31 of double word starting in location 38) CSW format: Key o0000o cad status count 0 3 4 7 8 31 32 47 48 63 key channel protection key cad address of last CCW used +8 count residual count from last CCW = CCW count - # bytes transferred status status information: 32-39 device and cu status 40-47 channel status unit status bits: 32 Attention - Asynchronous signal from device; may accompany de or come during SIO 33 Status Modifier - indicates cu and/or device cannot give status 34 Control Unit End - provided by shared cu if it was interrogated while busy, or by cu presenting unusual condition after ce 35 Busy - device/cu is either busy or has pending interrupt - operation not started 36 Channel End - subchannel now free; arises after last CCW releases channel normally 37 Device End - arises at completion of I/O operation by device; may accompany or follow ce 38 Unit Check - device/cu has sensed unusual condition; may or may not be an error; should issue SENSE command to device to get more info; this is a summary bit 39 Unit Exception - device has detected specific unusual condition (EOF, for example); only one such condition for each type of device; usually not an error condition channel status bits: 40 PCI - (Program controlled interrupt) - CCW has been fetched by channel with PCI bit = 1 41 Incorrect Length - storage area length not same as # of bytes requested or presented by device - suppressed by SLI bit in CCW

X.8 42 Program check - channel has detected programming errors; examples: - Invalid CCW address - Invalid CCW or CAW (bad command code, count, data address,...) - Invalid CCW sequence (TIC to TIC,...) 43 Protection check - store or fetch protect by channel on data/CCW reference - 44-46 Channel and interface equipment error indicators 47 Chaining Check - channel overrun during input with data chaining

DYNAMIC ADDRESS TRANSLATION: XI.1 VIRTUAL O 11 12 19 20 3 ADDRESS JSN PN. 8 ASSOCIATIVE REGISTERS CONTROL REGISTER 0 0 7 8 31 STL STO 0 11 12 19120 31 36-38 s- I PE IN 1 J IINTERRUPT: 1 SN TOO La RGE o 7 8 30 31, TL | PTO PTA I SEGMENT TABLE. I INTERRUPT: - P\ TOO IRGE ROR PTA - 1P'l r~INTERRUPT&............ ON T PAGE BOUNDARY PAGE TABLE

XI.2 DAT C,-LRT SYMBOLISM: VIRTUAL ADDRESS: SN SEGMENT NUMBER; - 15 OR 0 4095 PN PAGE NUMBER; 0 255 D DISPLACEMENT; 0 - 4095; USED AS RIGHT HALF OF REAL CORE ADDRESS CONTROL REGISTER O: STL SEGMENT TABLE LE\GTH IN UNITS OF 16 EN- IES STO SEGMENT TABLE ORIGIN; BITS 26 -31 MUST BE ZERO SEGMENT TABLE: MUST BE LOCATED ON 64 BYTE BOUNDARY; THERE WILL BE 1 SEGMENT TABLE FOR EACH USER; THERE WILL BE ONE SEGMENT TABLE ENTRY FOR EACH USER DEFINED SEGMENT. PTL PAGE TABLE LENGTH (IBM LENGTH) PTO PAGE TABLE ORIGIN - MUST BE HALF WORD ALIGNED IF IN REAL CORE PTA PAGE TABLE AVAILABILITY; IF 1, PAGE TABLE NOT AVAILABLE PAGE TABLE: MUST BE LOCATED ON EVEN (HALF WORD) ADDRESSU THERE WILL BE ONTE PAGE TABLE FOR EACH USER DEFINED SEGMENT (I. E, FOR EACH SEGMENIT TABLE ENTRY); THERE WILL BE 1 PAGE TABLE E-.NTRY FOR EACH AGE ALLOCATED TO THIS SEGMENT. FPBA PHYSICAL BLOCK ALDRESS LJFT-NaMOST 12 BITS OF!EAL CORE PAGE ADDRESS PA PAGE AVAILABILITY; IF 1, REAL CORE PAGE IS NOT AVAILABLE CB CONTROL BITS RESERVED FOR IBM; MUSST BE ZERO ASSOCIATIVE REGISTERS: SN SEGMENT NUMBER FROM A VIRTUAL Af1)DRESS PN PAGE NUMBER FROM A VIRTUAL ADDRRSS PBA PHYSICAL BLOCK ADDRESS FROM A PAGE TABLE ACB ASSOCIATIVE CONTROL BITS BIT 36 SET TO 0 WHEN CRO LOADED; SET TO 1 WHEN AR LOADED BIT 37 SET TO 0 WHEN CRO LOADED AND VNHEN 8TH AR LOADED; SET TO 1 WHEN AR LOADED AND WHliEN AR USED IN DAT BIT 38 MAY BE SET TO DISABLE, THI AR; SET BY DIAGNOSE INSTRUCTION DAT ALGORITHM, GIVEN VIRTUAL ADDRESS (VA) OF SN-,PN-D: 1o SEARCH ARS FOR ONE WITH BT 36 = 1 Ai?) SN-PN MATCHING THAT OF VA; 2, IF NO SUCH AR, GO TO STEP 4; 3o SET AR BIT 37 TO 1; COMPUTE ADDRESS USING PR& FROM AR AND I FROM VA; END OF DAT; 40o ADD SN FROM VA TO STO FROM CR0 TO GET ADDRESS OF SEGMENT TABLE ENTRY; 5, ADD PN FROM VA TO PTO FROM SEGMEINT TABLE ENTRY TO GET ADDRESS OF PAGE TABLE ENTRY; 6. CONCATENATE D FROM VA WITHI PBA FRONF IAGE T.ABIE ENTRY TO GET E L ADDRESS; 7. PICK LOWEST AR WITH BIT 37 = O AND ENTF? THE SN, PN, AND PBA USED INTO THE AR; SET AR BIT 37 TO 1; SET? BIT 36 TO.g MID OF DAT~

XI.3 VIRTUAL MEMORY (VM) USING DAT: 24 BIT ADDRESSING: 4096 PAGE VM COMPOSED OF 16 SEGMENTS OF 256 PAGES EACH; TOTAL VM IS 16,777,216 BYTES 32 BIT ADDRESSING: 1,048,576 PAGE VM COMPOSED OF 4096 SEGMENTS OF 256 PAGES EACH; TOTAL VM IS 4,294,967,296 BYTES COMMENTS ON DAT: 1. DAT APPLIES TO PROGRAM GENERATED ADDRESSES ONLY - IT DOES NOT APPLY TO CHANNEL ADDRESSES OR TO HARDWARE GENERATED ADDRESSES 2* FOR INSTRUCTION SEQUENCING, INTERNAL REGISTER KEEPS THE REAL CORE ADDRESS OF THE NEXT INSTRUCTION TO BE EXECUTED - DAT NEEDED ONLY WHEN CROSSING PAGE BOUNDARIES OR WHEN BRANCHING OR STATUS SWITCHING 3. FOR MULTIPLE CPUS, EACH CPU HAS ITS OWN DAT HARDWARE 4. CPU ADDRESS PREFIXING IS APPLIED AFTER DAT 5. DAT TIMING COSTS: a. FOR DAT USING AN AR, TRANSLATION ADDS 150 NANOSECONDS TO EACH STORAGE REFERENCE bo FOR DAT USING SEGMENT AND PAGE TABLES, EACH ADDRESS TRANSLATED REQUIRES 2 STORAGE REFERENCES (FOR PAGE AND SEGMENT TABLE REFERENCES) PLUS 750 NANOSECONDS, PLUS THE DATUM REFERENCE ITSELF AFTERIARDS

XI.4 REAL CORE SHARING: SHARING OF REAL CORE BETEEN TWO USERS (FOR RE-ENTRANT ROUTINES, FOR EXAMPLE) MAY BE DONE IN ONE OF NO WASE WITH THIS SEGMENT-PAGE TABLE STRUCTURE. IN THE FIRST WAY, EACH USER USES HIS OWN SEGMENT AND PAGE TABLES TO REACH THE SHARED REGION. IN THIS CASE, THE VIRTUAL SEGMNT AND PAGE NUMBERS USED BY EACH USER MAY BE THE SAME OR DIFFERENT. IN DIAGRAM, THIS SITUATION I AS FOLLOWS: USER 1 USER 2 VA1 VA2 NOTE THAT IM THE ABOVE CASE INDIVIDUAI REAL PAGES MAY BE SHARED IN ONE OR MORE USER SEGMENTS, THE SECOND TECHNIQUE FOR SHARING RFL PAGES IS TO SHARE PAGE TABLES o HERE, EACH USER HAS HIS OWN SEGMENT TABLE, BUT SOME OF THE PAGE TABLES ARE JOINT BETWEEN THE USERS SHARING REAL CORE. BY DIAGRMs, THIS SITUATION IS AS FOLLOWS: USER 1 USER 2 ST —---- ST IN THIS CASE, THE TWO USERS MAY USE DIWR ENT SEGMT S, BUT THEY WILL USE THE SAME PAGE NUMBERS TO REFER ID THE SAME REAL PAGE~ HERE, HOWEVER THEY MUST AISO SHARE THE WHOLE SEGMENT RESPRTEDTT BY THE SH1AIIE PAGE TABLE. ON TE1E OTHER HAND, IF THE RE& PAGE IS PAGED OUT T HRIS ONLY ONE PAGE TABILE TO MODIFY.

XI.5 EXTENDED PSW FORMAT: BITS INTERPRETATION 0-3 SPARE - MUST BE ALL ZERO 4 DAT ADDRESS MODE: 0 a 24 BIT VM ADDRFESSES; 1 32 BIT VM ADDRESSES 5 DAT CONTROL: 0 = NO DAT; 1 = USE DAT ON PROGRAM GENERATED ADDRESSES 6 I/O SUMMARY MASK: 0 = ALL CHANNELS MASKED; 1 = SEE CR 4 7 EXTERNAL SUMMARY MASK: 0 = ALL MASKED; 1 = SEE CR 6 8-11 PROTECTION KEY - SAME AS FOR STANDARD PSW 12-15 AMWP - AS FOR STANDARD PSW (ASCII MOPE, CPU MACHINgE CHECK MASK, WAIT STATE, PROBLEM STATE) 16-17 INSTRUCTION LENGTH CODE (ILC) - AS IN STANDARD PSW 18-19 CONDITION CODE 20-23 PROGRAM MASK - AS IN STANDARD PSW 24-31 SPARE 32-63 NEXT INSTRUCTION ADDRESS (VM ADDRESS) INTERRUPTION CODES: IN EXTENDED PSW MODE, INTERRUPTION CODES ARE NOT STORED AS PART OF THE OLD PSW DURING INTERRUPT PROCESSING. RATHER, INTERRUPTION CODES ARE STORED IN MEMORY AS FOLLOWS (HEXADEC IMAL ADDRESSES): EXTERNAL E-F SVC 10-11 PROGRAM 12 -.3 MACHINE CHECK 1L4-15 I/O 16-17 EXTENDED INTERRUPTIONS: SPECIFICATION INTERRUPTS (CODE = 6): 1. EXTENDED PSW BIT 4 = 1 AND 32-BIT OPTION NOT INSL 2 EXTENDED PSW BITS 0-3 NOT ALL ZERO 3. CONTROL BITS 13-15 OF PAGE TABLE ENTRY NOT ALL ZERO DATA EXCEPTION (CODE = 7): GENERATED IF BITS 26-31 OF CONTROL REGISTER 0 (THE SEGMENT TABLE REGISTER) ARE NOT ALL ZERO SEGMENT TRANSLATION EXCEPTION (CODE = HEX 10): 1. SEGMENT NUMBER IN VIRTUAL ADDRESS TOO LARGE (32-BIT MODE ONLY) 2. BIT 31 OF SEGMENT TABLE ENTRY (PTA) IS 1 PAGE TRANSLATION EXCEPTION (CODE - HEX 11): 1. PAGE NUMBER IN VIRTUAL ADDRESS GREATER THAN PAGE TABLE LENGTH (PTL) 2, BIT 12 OF PAGE TABLE ENTRY (PA) IS 1 FOR BOTH THE SEGMENT TRANSLATION EXCEPTION AND THE PAGE TRANSLATION EXCEPTION THE OFFENDING VIRTUAL ADDRESS IS STORED IN3 CONTROL REGISTER 2 AS PART OF THE INTERRUPT PROCESSING.

XI.6 CONTROL REGISTERS: 0 SEGMENT TABLE REGISTER FOR DAT 0-7 SEGMENT TABLE LENGT DI MULTIPLES OF 16 8-31 SEGMENT TABLE ORIGIN 2 1:TRANSLATION EXCEPTION ADDRESS REGISE - VIRTUAL ADDRESS IS STORED HERE WHEN A TRANSLATION EXCEPTION OCCUiL DURING DAT 4 EXTENDED I/O CHANNEL M&SKS: 0-6 I/O MASKS FOR GCTINES 0 1HIROUGH 6 7 SUMMARY BIT - SET TO IF BITS O-6 ALL ZERO 8-14 I/O MASKS FOR CTMA S 7 THROUGH 13 15 SUNMARY BIT - SET TO IF BITS 814 ALL ZERO 16-31 RESERVED - CURRENTLY UNUSED 6 EXTENDED INTERRUPT MASK BITS: 0-1 MACHINE CHECK MASK EXTENSIONS FOR CHANNhEL CONTROLLERS 2-3 RESERVED 4-7 UNASSIGNED 8 EXTENDED CONTROL MODE X- I'ETENDED PSW MODE 9 CONFICGURATION CONIROL BIT DEF TN-ElE VHEN PARTITIONING MAY OCCUR 10-23 UNASSIGNED 24-31 EXTERNAL INTERRUPT a&S&ES, 24 TR 25 INTERRUP Y ~M26 ~,....,FONC TION ALERT CP 1U 1. 27 YMAL`tUJNCTION AIFRT 9C PU 2 28 R'P1ER RV E1 29 RFiV 30'JER.NL Nl'iRUPT 31 RESERit1 D 8-14 PARTITIONING SENSING REGISTERS OR READING CONFIGURATION CONSOLE NOTE: IN THE ABOVE, "UNASSIG-. I' MEANS NOT L 74PIENTED,; "RESERVED" MEANS IMPLENENTED BUT NOT' YET ASSIGNED SPECIFIC NCTON CONTROL RISTERS 1, 3, 5, 7, AND 15 ARE UN 9S IGNSo NOTE: A CPU MAY RUN IN STANDARD PSW TDE OR N EL'TENI3 PSW MODE - THIS MODE IS DETERMINED BY BIT 8 OF CONTROL RXIS TER 6e IF RUNNING IN EXTENDED PSW MODE, THE CPU MAY OR MY NOT USE DT THIS IS DETERNED BY BIT 5 OF THE EXTENDED P5W, FNATJjY IA Y S: JUTSG i'THEM VIRTUAL ADDRESSES MAY BE 24 OR 32 BITS IN LENGT, AS...i.-. M ED BY BIT 4 OF THE EXTEIMED PSW.

XI.7 IBM 2846 CHANNEL CONTROLLER (CC): THE 2846 CC IS USED IN 2067-2 CONFIGURATIONS AND PROVIDES: 1. CPU-CHANNEL INTERFACE 2, PROCESSOR STORAGE UNIT-CHANNEL COMMUNICATION INTERFACE THE CCS 1. SCANS ATTACHED CHANNELS AND PROVIDES STORAGE CYCLES WHEN NEEDED 2 PROVIDES PREFIXING ON CHANNEL GENERATED STORAGE ADDRESSES 3. MONITORS PASSAGE OF I/O INTERRUPTS AND RELATED INFORMATION BACK TO A CPU 4. MONITORS SELECTION AND INITIATION OF CRANNEL OPERATIONS A 2846 CC MAY INTERFACE WITH: 1, UP TO TWO 2067-2 CPUs 2, UP TO EIGHT 2365-12 PROCESSOR STORAGE UNITS 3. UP TO SEVEN PHYSICAL CHANNEIS (ONE 2870 MULTIPLEXER CHANNEL AND UP TO TWO 2860 SELECTOR CHANNELS) 4o ONE 2167 CONFIGURATION UNIT IBM 2860 SELECTOR/2870 MULTIPLEXER CHANNELS: DATA IS TRANSFERED IN ONE BT WIDTH BE'tW I/O DEVICES AND A CHANNEL AND IN EIGHT BYTE WIDTHS BETWEEN CHANNELS, CHANNEL CONTROLLERS, AND STORAGE UNITS, A 2067-2 MAY HAVE UP TO 14 CHANNELS, 7 ON EACH OF 2 CHANNEL CONTROLLERS. 2860 SELECTOR CHANNEL: SUPPORTS RATES UP TO 1.3 MILLION BYTES PER SECOND; CHANNELS OPERATE WITH MINIMAL INTERFERENCE DUE TO OWN REGISTERS; UP TO 8 CONTROL UNITS PER CHANNEL, WITH AT MOST ONE ACTIVE AT ONCE. 2870 MULTIPLEXER CHANNEL: AT MOST ONE 2870 MAY BE ATTACHED TO EACH CHANNEL CONTROLLER; BASIC MIULTIPLEXER CHANNEL: UP TO 192 SUBCHANNELS; CAN ATTACH UP TO 8 CONTROL UNITS AND ADDRESS UP TO 192 I/O DEVICES; CAN OVERLAP OPERATION OF SEVERAL I/O DEVICES IN MULTIPLEX MODE OR OPERATE SINGLE DEVICE IN BURST MODE; AGGREGATE DATA RATE IS 110 kbo AUGMENTED MULTIPLEXER CHANNEL: UP TO 4 SELECTOR SUBCHANNELS MAY BE ADDED, FOR A TOTAL OF 196; EACH SELECTOR SUBCHANNEL MAY ATTACH UP TO 8 CONTROL UNITS AND ADDRESS UP TO 16 I/O DEVICES SELECTOR SUBCHANNELS 1-3 HAVE MAXIMUM DATA RATES OF 180 kb, WHILE THE FOURTH SELECTOR SUBCHANNEL HAS A MAXLDUM DATA RATE OF 100 kb; SELECTOR SUBCHANNELS MAY OPERATE CONCUlRRENTLY WITH EACH OTHER AND WITH THE MULTIP F CHANNEL9 BUT MAY OPERATE AT MOST ONE DEVICE AT A TIME; ADDITION OF SELECTOR SUBCHANNELS REDUCES THE MAXIM DATA RATE OF THE BASIC MULTIPLEX{ER SUBCHANNEL, BUT NCREASES THE OVERALL DATA RATE OF THE MULCTIPLEXER CHANNEL,

XI.8 CLANNEL ADDRESSES AND PRIORITIES CHANNEL ADDRESSE ON EACH CHNNEL CONlO.. OffItR 0 2870 MULTIPLEXER d N'~T 1-6 2860 SELECTOR CHANNES MUST USE CONSECUTITE ADDRESo ES S TARTINTG AT 0 OR 1 COMPLETE I/O ADDRESS IS 16 BITS TI I ENGTH AS FOLOWeS:e 0-3 CHANNEL CONTROLIR ADDTSS (0 9 o1) 4-7 CHANNEL ADDREiSS (o00o46) 8-15 DEVICE ADDRES ON C!At s.l ON 2860: 00 THROUGH F ON 2870: 00-B ON BASIC J1ULT TIPI 2R CHAN CO-CF ON SE!CTwOR SUBCHANNE1, 1 DO-DF ON SC;C SC: T....UBCHALhNI 2 EO-EF ON SEJ YtOR S;JB C'i ]TEL 3 01~-]F UCTO R SJB CHANK PO-FF ON SUi'0t{ $'J4CHANN, 4 CHANNEL CONTROLLER SERVIC iz AT'xTV{iD' GIA1tN9 ACAOPi JG TO EIR DDRESSES IN THE PRIORITY ORDER OF 02. 0i- "',9 05 O06, 00 STORAGE UNIT SERVICES CHANNEL CON0TRO.IRS.t ORDE0TR OF ADDRESSES 00, 01; CPUs SERVICED WHEN CHAMM:S NOT QUf,3TYT-3ING SERVICE DURING PROCESSING, ACTUAL DATA RAE%!).) DPFNDI) UPON: 1. CHANNEL PRIORITY 2 * NUMBER OF CIHANMElT S VoA'. ~'J. L,,UW -C.T_ LY U 3. SPEED OF THE IT/O DEb lC'Eo I Ol: JihTRA.G C,.GONOCURRENTLY ON THE CHANNELS 4. TYPE OF CHANNEL PR(OGRAfI.....l US IBM 2365-12 PROCESSOR STORAGE: UP TO 8 2365-12s MAY' BE ATT.AC.IED O T A Y2C9 <. SWT;' 2365 HAS BASIC STORAGE CYCLE OF 750,l4ANOSE o ONDS AND ACCESES 8 BYT IN PARALLEL EACH 2365 CONJTAINS 64 PAGE= 2PAE,;>1t 1 62 fSt IM OF STORAGE HOUSED IN 1WO INDEPENDENT STORAGE ARRA$) OF 32 P.A01i <.CH, ALL EVNa DOUJBLE WORDS ARE IN ONE ARRAY AND ALL ODD DOUBLE WORDLS ARPE I' TE OTHER ARRAY; EACH 2365-12 CAN ATTACH TO UP TO FOUR STO)RATAE tjSE 90DS ONE FROM EACH CPU AND ONE FROM EACH CHANNEL CONTROLLR IN THE 3DUPtEX STvs'[STF AT EACH 2365, THE CHANNEL CONTROLLEiLR ACLOSES1T TO IT GETS FIRST PRIORITY, AS DOES THE CPU CLOSEST TO IT''TH lERBF0ORJ PRIOR 1IT71? AT EACH STORAGE UNIT MAY NOT BE THE SAME ORDERING OF CCs AI0 CP$s; IN1EREAVING OF SUCCESSIVE DOUBRTF VO4WT0 R0 C,)TECSTS ITROM A GIVEN STORAGE UNIT IS POSSIBLEB, REEDUCING ACCES'LflEA, TO 3?75 NtulNOSECONDS IN SUCH CASES, AND DEPENDING UPON OTHER CONFlICTTNG RQUT Q-TS$ STORAGE KEY IS 7 BITS IN LENGTH ANID COVERS 204.8 BYTE BLOCKS: 0-3 STANDARD STOREE PROTECTION!(T' 4 STANDARD FETCH PROTPCTT.IN B 5 REFERENCE BIT: SET TO i,l&ACH Ti lE ( CORRESPONDING STORAQ E BLOCK IS REFERENCE S(STORE OR., 2FeTC,,3, 6 WCHANGE BIT: SET " I TO i qJ'"sw hX PONDING STORAGE B.OCK RECEIVES A STORAoGE REE2.:NE (12 E, IS,8 CSNG I})

XI.9 IBM 2167 CONFIGURATION UNIT: 2167 IS REQUIRED IN A 2067-2 CONFIGURATION AND PROVIDES MANUAL SWITCHES FOR THE FOLLOWING FUNCTIONS: 1. PARTITIONING: ONE SWITCH FOR EACH CORE STORAGE UNIT INTERFACE, ONE FOR EACH CPU INTERFACE TO A CHANNEL CONTROLLER AD OE FOR EACH CHANNEL INTERFACE ON DUAL-CHANNEL-INTERFACE I/O CONTROL UNITS; 2, PREFIX ACTIVATION: ONE SWITCH PER CPU; 3. DIRECT CONTROL ACTIVATION: ONE SWITCH PER CPU; 4. PROCESSOR STORAGE UNIT FLOATING ADDRESSING: ROTARY SWITCH FOR EACH 2365-12 STORAGE UNIT IN THE SYSTEM; SWITCH PICKS THE STARTING CORE ADDRESS FOR THE UNIT; EACH UNIT CONTAINS 256K CONSECUTIVE BYTE ADDRESSES STARTING WITH THE ONE INDICATED BY THE UNIT'S SWITCH; TOTAL SET OF ADDRESSES IN THESE SWITCHES MUST BE CONSECUTIVE STARTING WITH ZERO; 5. CHANNEL CONTROLLER FLOATING ADDRESSING: ONE ROTARY SWITCH FOR EACH CPU; MAY BE USED TO ASSIGN THE CHANNEL CONTROLLERI TO BE USED BY THE CPU IN STANDARD PSW MODE. STATUS OF SWITCH SETTINGS NAY BE SENSED BY EITHER CPU BY STORING THE CONTROL REGISTERS; CONTROL REGISTERS 8-14 CONTAIN THE STATUS BITS REFLECTING THE SWITCH SETTINGS. ALSO, BIT 9 OF CONTROL REGISTER 6 MAY BE USED TO PREVENT SWITCH CHANGES EXCEPT WHEN ACCEPTABLE TO THE CONTROL PROGRAM. PROCESSOR STORAGE UNITS (2365-12) CC 0 CC 1 CPU 1 CPU 2 -{

XI.O1 INSTR"i2TIONS MODIFIED UNDER EXTENDED PSW MODE: iJHEN BIT 8 OF CONTROL REGISTER 6 IS 1, THE CPU OPERATES IN EXTENDED PSW MODE. IN THIS MODE, SOME INSTRUCTIONS ARE MODIFIED IN THEIR EXECUTION, AS FOLLOWS: BAL, BALR IF DAT IS ON, THE RIGHT-MOST 24 BITS OF THE VIRTUAL ADDRESS ARE PLACED IN THE SPECIFIED REGISTER, AND THE FIRST BYTE OF THE REGISTE IS SET TO THE ILCO, CC, AND PM OF THE PSW BXH, BILE IN 32 BIT DAT, AN ADDRESS IN ONE OF THE AFFECTED REGISTERS M&IX APPEAR TO BE A NEGATIVE NUM3ER RATHER THAN A POSITIVE ADDRESS EDMK IN 32 BIT DAT, THE ADDRESS INSERTED INTO GPR 1 IS A FULL 32 BIT VIRTUAL ADDRESS ISK A 7 BIT STORAGE KEY IS TAKEN FROM BITS 24-30 OF THE SPECIFIED GENERAL REGISTER LA A VIRTUAL ADDRESS IS PLACED IN THE SPECIFIED GENERAL REGISTER; IN 24 BIT DAT, THE FIRST BYTE OF THE REGISTER IS ZEROED; IN 32 BIT DAT, THE FULL 32 BIT ADDRESS IS PLACED IN THE REGISTER LPSW THE DOUBLE WORD LOADED AS THE NEW PSW MUST CONFORM TO THE FORMAT OF THE EXTENDED PSW SSK THE STORAGE KEY IS PLACED INTO BITS 24-30 OF THE SPECIFIED GENERAL REGISTER SSM SETS BITS 0-7 OF THE CURRENT PSW; THIS IS NOT THE SYSTEM MASK, HOWEVER, IN EXTENDED PSW MODE; CAN BE USED TO SET THE DAT ADDRESS MODE (BIT 4), DAT CONTROL (BIT 5), I/O SUMMARY MASK (BIT 6), AND EXTERNAL SUMMARY MASK (BIT 7) SVC THE IMMEDIATE FIELD FROM THE SVC IS STORED IN LOCATIONS 10-11 (HEX) INSTEAD OF WITH THE OLD PSW TRT IN 32 BIT DAT, THE ADDRESS INSERTED INTO GPR 1 IS A FULL 32 BIT VIRTUAL ADDRESS NEW INSTRUCTIONS PROVIDED ON THE MODEL 67: BASR,R 2 IF IN 32 BIT DAT, THE FULL 32 BIT VIRTUAL ADDRESS OF THE NEXT INSTRUCTION IS PLACED IN R1l OTHERWISE, A 24 BIT BAS RigD2(,B2) REAL OR VIRTUAL ADDRESS IS PLACED IN R1 AND THE FIRST BYTE IS ZEROED.* THEN BRANCHING OCCURS. LMC ) PROVIDES MULTIPLE CONTROL REGISTER LOAD/S TORE. REGISTER[ R1,jR3vD2(B2) LOADED FROM/STORED INTO CONTIGUOUS FULL-WORDS STARTING STMC I AT THE SPECIFIED ADDRESS. REGISTER WRAP-AROUND WITH 0 FOLLOWING 15. CRS 8-14 CANNOT BE LOADED. POSSIBLE PROGRAM EXCEPTIONS INCLUDE M, A, S, AND P. LRA R,D2( X2,B2) COMPUTES THE REAL ADDRESS (TRANSLATED ADDRESS) CORRESPONS TO THE SECOND OFERAND AND PLACES IT IN THE SPECIFIED GENERAL REGISTER. CONDITION CODE IS SET: 0 SUCCESSFUL TRANSLATION 1 PTA = OR SEMENT NUiMBER TO LARGE 2 PA 1 OR PAGE ME TOO LARGE TRANSLATION EXCEPTIONS ARE MASKED DURING AN Ia POSSIBLE PROGRAM EXCEPTIONS ARE M, A, AND S.

XII.1 MTS Manual, Volume 3, Excerpts The following pages are excerpts from the MTS Manual, Volume 3. We have provided here copies of that Volume 3 information of greatest use in each of the two courses. This does not include all possible information of interest to the courses, but the need to reference the IMTS manual should be considerably reduced. Needless to say, students are encouraged to peruse Volume 3, and other MTS manual volumes, to gain a better understanding of the many facilities provided by this system.

IT S 3 SU DROUTi".. _ 1N C ACR D - T CPTIO USING UBEO:>. L BRARIES lThe Co pu L-ing Center mnaintains a nu:Z.nr of subrou'i -: n -, _i..C f les. Ii addition the user can constarcC- and use nis ow -n - two -: ost common iib rries, *i.... LY and LCSY s u.. su:i. ticu in s 3, are automatically searc-. If, after -'.'.C -... 4ect'modu'es C0e o leC- u1 v e e d e x t-a s-..Ct Csv-e. <lo.& sT SCas L'IBRA IE ando L.:. v.... _1Cift 1 3jf,,I LCS v,,,,., I';S n lbrary sa ca. s st'Ii'.' -' -at no. v -.... —. tc o c fie na.e w.a ti.-e pr o r n is ru. eI: C (Ii.ts Scientific Subroutine Package) with a FORTRAN progr2am,.tN s 3us been compiled, one might specify $RUN -LOADe +*SSP In thia case the loader goes through the following szeps: 1. The object modules in the f ie -L OAD are oaec; ae-' n..e toet her. 2. Then object modules are selectively loaden:rom SSP (since it ib5rary) to resolve external symbols (i.e., subroutine names) io 3. i-nally, if there are still unresolved exte-nai svbcs, -i and L~CSY:SBOL are searched for tahe appropriate object Z-ou'es.,tre nhatv this concatenation can be imolicit as welL as ex:s-cic. instead of saying $RUN OBJ+*SSP one could put $CONTINUE WITH *SSP in CBJ as the last line and then merely say $RUN OBJ to get the same effect. 10

;.:S 3: SLi_ b.'Z'' AN i:;.i'C SC;....liC-'* June 197C'ac v L' I'.he following public files contain subroutine libraries: * L I A R', 3 1 2X t- t, v i e S: ard t;C2, a i t i rCn~_i::(:s a,i describea in this volue. See "iE:: Sy'-te-.?'!C''i'!:'-' Library: Math e atical and Service Subpro; raz,, f orm C28-01c, for descriptions of the others. *SSP *SSC P M 1 H *SSPS TAT SSQP'I'[ and'4'SSSS"i T conti t ac a' sa's'c routi ne, respec C ti, c S''C.cs C I _ Tr and *SSP con.ains the one line $CCNTINUE N I T'i S S:'iATHE+SSPST AT The subroutines contained in the >C' - _'_..> moented in the IBL rubl icatc n "t Syste,/36c S cientiic Uu Lrou>, C;I Package, (360-A-CM-03) Ve'rsion IIi, Pzogra'rer's a:nuai", r H20-0205-3. Somheof the furctions performed by S% zodules a - I by subroutines availaCire in *LIEEhARY. in general te. versions are both faster and saller and are ice-e.. - recommended for use in preference to the co rers or'n S - routines. See the description of these su routines i volume. * PI1LIB This contains subroutines that say re invokec bV PL/I c'_ code. For details, see "IBEM System/36U ) S SL/I [7 Prco.. mer's Guide", form C28-6594, and LTlN Syste'/36 CS L,' Library Computational Subroutines", form C28-6590. *PL3601IB 1his contains subroutines to support the externaJl prcecCu-c READ, WRITE, PUNCiH, and PAGE for PL30O prograns. Fura-.'information may be found in the "PL360 User's Guide" in Vclu:~ 7 of the MTS Manual. *SLIP The SLIP (Symmetric.ist Processor) subroutine pr c c' i.; implementat ion ot Joseph Weinenau's 1L. 7590 SLI iA lu:g'i. A ccmplete description of tihe language may e toun.;;' Comruni c ations cf i-'ne _ACf, 1963, vol. 6, rp p!'454. So, the "SLIP User's Guide" in Volume o of the MTS Manuul. Subrcutine.s

' 3: SUESGUTINE AINiD MiCiRO DBSCRiPTIC"1S joe -evise d,ay 1972y 9a 7'2 C ); S T I - f C. 3 5 St,'il c!cadets lliarary:aciiL cn'st c 7DIi LCC'- L" 0T- and rIR recorus!nad bn... ec-o...;.. r'N ra.:spetive1iv in coiCTus 2 to 4 of un eccvd' T'l,,. cc,-a c.:oaz ~:'v:i b ot 9ls awhich are refere-ce but not r e eie o t" D -o' om a in-c^c: ~tali if they exist th-er Te O ~ ecor loaS se'e7 t'Vl'; <;: t-,~ z — c ie~, ic e fo1lows it or to wh ii t he Li ac c d - c n 6. \A:-u a.: as- ee reierencced but no-t yet d _ -e't c,i'- c or... A. "a _nce.,s an:uitiia e i F t os n _ _;j-_::sz C X < X _. * ai^ e I _- _ OAC 0 o5USO ci CC1 ~... 1..r:;:-(n. KTrie DE record: s u o f-a h! —'' -::-' _eadDC eors cnb fu iCe a Load.c.. in., t ug h t5e. - user c a c os. r d suf'-, *,!:~-, ~ia e;.i: ran-d' re ccrds ir moth-, ha_, e Sc- roe-i.....c; eve JLir. id!e en oug iti ar''s'a: - - 4- 4-. -::N z -ieCe w ith a 1l LIB.nd RIP records. A description o r i..,'lliTM IS given in -lue e T: S,lan n uai ueai s'......'''a'. I P and LIR records can be found in "7The Lyn oaLic Loader- S~'n'. iue 5..',

MTS 2: PUBLIC FILE DESCRIPTIONS April 1971 Page Revised May 1972 *GENLIB Contents: The object module of the library-generating program. Purpose: To generate a loader library from object modules. Usage: The program is invoked by the $RUN command. Logical I/O Units Referenced: SCARDS - input objeQct modules and/or libraries. SERCOM - listing of diagnostics for conversational users. SPRINT - listing of diagnostics and library modules. Parameters: Only the first character of each parameter need be given. Only -onre of the parameters SEQL, POIN t, DIE, and LINE can be specificed. The parameters must be separated by either a comma or a blank. XRiEF - Specifies that a complete cross-reference listing _NCXREF of load modules be produced. This will consist of three parts: load modules with entry points (if any), load modules with external references, and external references with load modules. SEQL - Specifies that LIB records are to have no pointers so that the loader must proceed in the sequential order. The output library may be any kind of file or output device such as *PUNCH*, or magnetic tapes. The first record will be a COM (comment) record with the date and time indicated. Each load module follows its appropriate RIP records and LIB record. The parameter SECL should be specified only for output devices, since the loader must process every record, and hence takes more time than for other types of libraries.,POINT - Specifies that LIB records are to have note-point information. The loader proceeds in sequential order, but skips over unneeded load modules without reading them. The output library must be a sequential file. POINT should be specified when a program loads many load modules from the library.!DIR - Specifies that a DIE (directory) record be constructed. This record consists of 12-byte entries, an 8-byte defined symbol name and its 4-byte pointer referring to its first record in the library. Since the DIB record can have no more than 32767 bytes, there can be no more than ~GENLE 155

rS 2: PUBLIC FILE DESCRIPTIONS age Revised May 1972 April 1971 2730 different defined symbol names. Licrary load modules folcow the EIR record.. The DIR record his a pointer pointing to immediately after the last lcad modulie The loader does not proceec inr sequential order, bu t }licks- ioan. modules as needeL from the library. hI h cutput library must be a sequential fi e T he D ri parameter shoul d be specified w'(1aen only a few load modules need he loaded from the li.erary LINE - Specifies that LE rleccrds are to have line nunbar pcinte, Ers he output librar-y rust be a line file. The line number zero will be date-star:ei. a;e ne cess ary RIP ad LI records f'cllow. Load modules s tart a t elie no nu Nb e -999% for each succes sive r eco5:d e l,..ine numte,~; i.s incremenet cc by 1 00 The LINE paramL tei has o ad vantt aes: (1) it s gene r a all y ast w rh en.lo (ding f r om a s al l ].ibra- r y (2) one;an asil.' - i nsert patches in. co th e!.ibLa-:y,! many Ian otd:.l e are to be lcaode, the lading i.i.cel is s i io si e t he loader must use numeros:ildexed ead red f operae ions on the rile, amwles: $RU'N *GENLIB SCARDS=SQUASH S'P{NCH=LI9 $RUN *GENLIP SCAIRLS-A.J+iC SPAUNC- S CLtB PARX -XREFP PONT $ RUN *GENLI B SCAR S-L.DLIB S i N C H= NEW Tb PAR=D scription: Each input. ea d. odulie Jis anal.yed.for errorss Each modu Le must have at least one ESl record, and the last record must be an END recordo It also uust have at. ]east onle defined symbol. Ii e library module name wil- be the one defined on the pre vious LID recod, it any or the first defined non-blank symbol in the module I f this library module name is a duplicate of an earlier name, the entire load module is skipped. If the module satisf.iess the ahove conditions, it i:; saved in the sequenthia l. Ti..J.e._ -YSUT/I when all. of the input. has been proc essed a comp Ite cross —-reference listing is produced if the XR.E parameter is specif.ied. Any dultcate or undefined sy mbois are prinedC, Theni. the output lihrary is produced, each load Mciu I;ead tie i oint- act Iro - YSUT I, Any remaining record. (suci as Ls CAS ot ifT records) immediately after t he l tast load reoduel in the input trom SCARDS are added. The Frogram then!'st,- all. ii..racy modul.e na mes Wit I the correspending line numbe:rs (if a Wplicable) on which th ey begin. F.inally'the pr oce.sin ta-me tak en'(in seconds and hundredths of. seconds) is pr:Lnted.. See "The 1 Dyna mic Loader s tec tio in orlume 5 fr the description cf t.be DI.R ~7 P,( arnd 5lt loader r eoras its: (1) The outpu: t lb rar: tle s. u,'di l e empt ied before ";GENLIE is run.

MTS 2: PUBLIC FILE DESCRIPTIONS April 1971 Page Revised May 1972 (2) To generate a new library from an old library of type I LINE, use the following: I $RUN *GENLIB SCARDS=OLDLIB(-99999,-1) SPUNCH=NEWLIB This reduces some of the indexed operations on CLDLIB and, thus, reduces the processing time in generating the new library. (3) All libraries of type DIR and POINT must be copied as I $COPY OLDLIBa-TRIM NEWLIB$-TRIM Both files must be sequential files. (4) All libraries of type LINE must be copied as I;$COPY OLDLIB(-99999) NEWLIEBI *GENLIB 156.1

NTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1 0 CALLING CONVENTIONS IN ~IODUCTION A calling convention is a very rigid specification of the sequence of instructions to be used by a program to transfer control to another program (usually referred to as a subroutine) It is very desirable altnough not always practical to set up only one set of conventions to De used by all programs no matter what language they are written in so that FORTRAN programs may call MAD programs and assembly language programs and so forth. In the MTS system the OS type I calling conventions have been adapted as the standard. A complete specification of these standards can be found in the "IBM System/360 Operating System Publication, Supervisor and Data Management Services"' form C28-6646. This description shall try to bring out pertinent details of these calling conven-tions.. Throughout this discussion we will refer to the terms cailin rq prOqram, called Rrograrm, save area, and callian s ue2nce,, The calling program is the prcgra which is in control and wants to now call another program (subrc ines). The called rogram is the program (subroutine) which -tne calling program wants to call. The save area is an area belonging tc the calling program which the called progr am uses to save and later restore general purpose registers. The save area has a very rigia format and is discussed in more detail later on. A calling sequence is the actual sequence of machine instructions which perform the tasks as specified by tne calling conventions. The facilities that must be provided by the calling conventions are: 1. Establish addressability and transfer to the entry point. dc Pass parameters on to the called program. 3. Pass results back to the caliing program. 4. Save and restore general purpose and floating point registers. S. Re-establish addressability and return to tne calling program. 6. Pass a return code (error indication) back to the calling program so it knows how things went. The remainder of zhis description will describe the OS type I calling conventions to show how they are used and how the facilities listed above are provided for. RE'GISTER AND STORAGE VARIANTS OF TYPE i CALLS The OS Type I calling conventions actua.l ly consist of two very similar calling conventions, referred to as OS (I) S rype caliing conventions and OS (I) R Type calling conventions. The two differ only in the way parameters Calling Conventions 15

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS e 1970 and results are passed between the calling and called programs. The R refers to register and the S to storagqe. The OS (I) R type calling conventions utilize the general purpose registers 0 and 1 for passing parameters and results. This allows only two parameters or results and cannot be generated in higher level languages as FORIRAN. Its advantages are that calling sequences are shorter and take less time to set up. These are very popular in lower-level system subroutines such as GETSPACE or GETFD. Fortran users needing to call subroutines that utilize R-type calling conventions can use the RCALL subroutine described in this volume. The OS (I) S Type calling conventions require a pointer to a vector of address constants called a parameter list (in register 1). Since the parameter list can be of any required length, several parameters can be passed using OS (I) S Type calling convention. These conventions are used by system subroutines such as SCARDS or LINK and are generated by all function or subprogram references in FORTRAN. Results can be passed back by giving variables in the parameter list new values or via register 0. PARAMETER LISTS As stated above, a parameter list is a vector of address constants. The parameter list must be on a full-word boundary and the entries are e —h four bytes long. The address of the first parameter is the first wor of the list, the address of the second parameter the second word of the list, and so cn. For example the parameter list for the FORTRAN statement CALL QQSV(X,Y,Z) might be written in assembly code as: PAR DC A (X) address of X DC A (Y) address of Y DC A (Z) address of Z Now this parameter list works well enough when the parameter list for the subroutine is of fixed length, but there is not enough information yet to allow a subroutine to determine the length of the parameter list ana hence accept variable length parameter lists. For this reason there are two types of Farameter lists, fixed length parameter lists as described above, and an extended form of parameter list called a variable-length parameter list which is described next. Since a standard 360 computer uses 24 byte storage addresses the left-most byte of an address constant is usually zero. Tn a variable length parameter list bit zero of the left-most byte of the last parameter address constant is set to 1 to show that it is the last item in the list. The example above then would be written as: PAR DC A(X) address of X DC A (Y) address of Y 16

1iTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June,970 DC XL1'80' turn on bit zero. DC AL3 (Z) address of Z if it generated a variable-length parameter list. As a matter of fact FOtFRAN does generate variable-length parameter lists. Note though that programs expecting a fixed length parameter list will work with a variablelength parameter list, provided it is a least as long as the fixed-length list they are expecting, since they extract only the address part when they use the parameters. REGISTER ASSIGNMENTS Of the sixteen general purpose registers, five are assigned for use in the calling conventions. The use of the general registers differs slightly depending upon whether an R or S type call is being made. Calling Conventions 17

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 The following table specifies exactly what each register is used for during a call: IRegister Number I Contents I 1 0 l..I Parameter to be passed in R type sequences. I I I I I I Result to be passed back in R and S type sequences. I I 1 I Parameter to be passed in R type sequences. I I I Address of a parameter list in S type sequences. j 2-12 I Not used as a part of the calling sequence. Must be J I saved and restored by the called program. The save I I I area is usually used for this. I 13 1 The address of the save area provided by the calling J j j program to be used by the called program. I iH- -+ —----- ---- - *1 I 1 14 Address of the location in the calling program to I t t which control should be returned after execution of J I the called program. 15 1 Address of the entry point in the called program at I the time of the call. I I I i I A return code at the time of the return that indicates I to the calling program whether or not an exceptional I I condition occurred during processing of the called 0 program. The return code should be zero for a normal I I return or a multiple of four for various exceptional I I conditions. - __,, _..........,................'[...... —-- J General Purpose Register Linkage Conventions Notice that it is the called program's responsibility to save and restore registers 2-12 in the save area provided by the calling program. There are two reasons for this. First of all only the called program knows how many of the registers from 2-12 it is going to use. Since a register need be saved and restored only if it is actually going to be changed, the called program may be able to save some time by saving and restoring only those registers which it will use. Secondly, the called program requires addressability over the area in which it will save registers upon entry, since any attempt to acquire the address of a save area would destroy some of the registers which are to be saved. Furthermore, the save area should not be a part of the called program since that would prevent it from being re-entrant (shareable). This means the calling program should provide the save area in which registers are saved and restored. And so we have the 18

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June J70 called program saving and restoring registers 2-12 in a save area provided by the calling program. The calling conventions are quite different with floating point registers. Since a large percentage of programs &o not leave items in floating point registers across subroutine calls it seems rather wasteful to always save and restore the floating point registers. So the convention has been established that the callinq program must save and restore those floating point registers which contain items which are wanted. Also, programs which return a single floating point result quite frequently do so via floating point register 0. RETURNING RESULTS There are in the OS Type I calling conventions four ways in which a subroutine can return a result. These are: 1. Value of result in general purpose register 0. 2. Value of result in general purpose register 1. 3. Value of result in floating point registers. (usually 0) 4. Value of a parameter from the parameter list changed. The r ticular method used depends upon whether the R or S type convention is u. d and whether the called program can be used as a function in arithmetic statements. The first three methods are used by R type calling conventions for all returned results. The contents of each of the registers depends upon the particular called program and are described in the subroutine description for each subroutine using the R type calling conventions. The first, third, and fourth methods are used by S type calling conventions for all returned results. The first and third methods are used by function subprograms whose calls can be embedded in FORTRAN and MAD statements. The choice of general register 0 or floating point register 0 depends upon whether the result returned is integer or floating point mode, respectively. An example of subroutines which return results in this manner are the FORTRAN IV Library Subprograms, such as EXP, ALOG, or SIN. The fourth method can be used by a subprogram. An example would be a subprogram called by the statement CALL. MATADD (A, B,C, M, N) which might add the MxN matrices A and B together and store the result in C. SAVE AREA fORMAT The save area is an area belonging to the cailing program which the called program uses to save and later restore general purpose registers. The address of the save area is passed to the called program by the calling Calling Conventions 19

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS Ju. 1970 program via general purpose register 13. The save area has a very rigid forrat and is described in the table: t Word I Displacement I Contents.....:........;......................... —---- I 1 1 0 I Used by FORTRAN, PL/I, and other beasties for I I I I many devious purposes. Don't touch! 1 2 1 4 1 Address of the save area used by the calling I | I I program. Forms a backward chain of save areas. I I I I Stored by calling program. 1 3 1 8 1 Address of the save area provided by the called I I 1 program for programs it calls. Forms a forward 4 I I I chain of save areas. i.-.I.1....- —. —- _-_. —1 4 ( 12 1 Return address. Contents of register 14 at 1 i I I time of call. I 5 1 16 1 Entry point address. Contents of register 15 1 I I 1 at time of call. i i —---....:..............1 6 1 20 IRegister 0 contents. I 1 7 24 ( Register 1 contents. I 1 81 28 ( Register 2 contents. - -l 1 9 1 32 1 Register 3 contents. I I 10 1 36 I Register 4 contents. 1 11 l 40 I Register 5 contents. 1 121 44 I Register 6 contents. 1 t., i ------—.._. 1 13 1 48 I Register 7 contents. 1-.A.' _ _ _ _ _... 14 1 52 1 Register 8 contents. I t —--- — 1 —-----... - ---— I i 15 1 56 I Register 9 contents. 1 1 16 1 60 I Register 10 contents. i ~ _ -------..........I................ _..... -... __.....................-I s ( 17 1 64 Register 11 contents.,, ---.............._...., o ntents....... -- A ( 18 1 68 ( Register 12 contents. j Save Area Format There are two things to be noted about the save area format, namely who sets what parts of the save area and how these areas might be set up. The 20

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June *,70 calling program is responsible for setting up the second word of the save area. This is to contain the address of the save area which was Frovided when the callinq program was itself called. Although this is technically set up by the calling program as a part of the call, most programs set up the save area they will provide to subroutines.they call once and leave its address in general register 13. The work then does not need to be repeated for each call. The called program is responsible tor setting up the third through eighteenth words of the save area. The called program usually saves the general registers which it will use as a part of its initialization procedure and restores the registers as a part of the return procedure. Notice that the save area format is amenable to use of the store multiple and load multiple instructions for saving and restoring blocks of registers. All of this will be made clearer in the examples at the end. Some system subroutines (notably GETSPACE, FREESPAC, and a few others) do not require that a save area be provided for them. For these subroutines general register 13 need not be set up before a call and its contents are preserved by the called subroutine. The subroutines waich need no save area are clearly marked as such in the MTS subroutine descriptions. Notice that it is all right to provide a save area to one of these subroutine; it will simply be ignored. CALLING PROGRAM RESPONSIBILITIES AND CONSIDERATIONS The calling program is responsible for the following: 1. Loading register 13 with the address of the save area and setting up the second word of the save area. 2. Loading register 14 with the return address. 3. Loading register 15 with the entry pcint address. 4. Loading registers 0 and 1 with the parameters in an R type call or loading register 1 with the address of the parameter list in an S type call. 5. Saving floating point registers, if necessary. 6. Transferring to the entry point of the subroutine. 7. Restoring floating point registers, if necessary. 8. Testing the return code in register 15, if desired. After the return from a subroutine, the status of the program will be as follows: 1. In general, the contents of the floating point registers will be unpredictable unless saved and restored by the calling program. 2. The contents of general registers 2 through 14 will be restored to their contents at the time the called program was entered. 3. The program mask will be unchanged. 4. The contents of general registers 0, 1, and 15 may be changed. 5, The condition code may be changed. Note that general registers O and 1 and floating point register 0 may Contain results in the case of R type subroutine calls or a fu nction sutFrogram. General register 15 will normally contain a return code, Calling Conventions 21

2S 3_ SJU'SROUINE AND AI}ACDO DSC;RIPTIOS(TI June 1970 inulicetirg w ei'thehr or not arn exceptional cordition occurred durin, processing oa t'he called program. CALLED RO3 GRA1 EESPG.NSS iLIPIS N' S CONSIDERTiT Z ONS,.e called program is responsin e con zle 0ollowing:. Saving t e-, contents of genenaw registes 2 t' erouch 12 e wave ac a p ro'd a tv ne callinr rehs tns neea be saves only if the calied progr am - oi- i es these n i s ters.'i S~-uuir word o! t ~e savei area w i-n * ccad ss oi -ho 3.,s - c tens t of go nnC -al registers 2 througn 4 bebore rc Lua; _I^n4 o to tie calin^g program.T ~4_tC. L 0 -. to' n rogra i as i if cha ed C L o ding general registers 0 and I or floating point nregi-aon w'tn 4 t' re sult in hi case of R type subrou tine ca lls or..c.i Ct.iO l,. to, iing general register 15 with the return code. I7.'ialnsfe-erring to the return location. E X %-[:]iC, C Li NG SEQU N CES:. -;e sctiojn wi1l describe ana give the aisseibly l]an.'uae sttg:e.: a,- os; th,_', e':i c1 c achiiie instructicns necessary to implemC nt OS Type i cl!ng CCo ri V I: - i:' On!S. A t. p.ca!l entry poCinlt might consis t o'the fol lowing s U namrment.s: USING SUBEA,12 12 wil' e a base register SUERA SUT 1, 12,1 2(13) save reg is.ers 12,:5 i2 5 set u'.2 1 s t e base c-St e r LA 1 1, SAV t.his is save area I oviedL nor otChers ST i1, (0,13) set up forward porinten ST 13,4(0,'11) set up b _kward pointer LT 13,11 set up or any calls we issue LR 11, 1 get parame-er' pointer into non-vo'atile reg. SAV: DS 18F save area we provide for others InsidC a subroutine th -at began with ti.he entry sequerce gi ven a ove, e vanie or t e secondil parameteer nI l e laraFeter lis- could be put c ino cenIera purpose register 3.wth the following sequence: I, 3,4 (0,11) pick up secondn adcon fron paraneter list - 2

~TS 3: SUBh3GOU""E A8NYD MC ROG DESCIzC; I'IONS Ju n 1 9 7 C r 0,O(Os) pick up value of parameter. s-u b trouinie — that b t egan wi e enry s,e C e t i C ar:otnet s ubroutine, SCBR3, coulo be ca iie u ing t e Co) _o';:'ing se uence. crsn,=er that registe 13 already points to thle corec- save area: LA 1, ALiST set up paraIeter list 1a'aress V (S B E) s; enty piit a d re s'ALR 14, 15 Set up) LrtLtir n aidress 1an branch to the u bt- U t i &e,'*$+4 (15) teLSt re+urnu coue via a transler Ctale i A OK R\C-O D BCD1 C=4 B BA AL RC=b ACK C — normal return to here ARaLiLST DC A (PAR1) first parameter address 0 inally, a subroutine that began with the entry sequene g >v- above coula return to the program that called it with the followino seciueZce: ZLE O,RES ULT floating point resuit to EA &. i 13,4(0,13) use bacK pointer to get right save are LN 14, 12,12 (13) restore registers. $R 15,15 indicate a zero return code (no errors) BR 14 return to what called us it snould be pointed out that altnough the above sequence are ttvca or tnhe. instruc>Ztions used to implemaent the cailng conventionss, may va'atV;a n:e aE3re +twS o sans o- mracro delin'it ohs zn&e TS Calio LC o_ nvens': Calliny Conventi:ons'

ZTS 3J SUj-OUTINE AND iAC~O BESCRiPTiONS 171C1T~~~~n 1970 CiLL, land: TUi{N; and te a acros EJTTENi and EXI'.?.e n:ose uaseu! co t.ese ->clC) a-e' NTE R, CALL, and EXI T. D(iaies ea sa o n.ac-' ss ich: aae th1 e t ra > e en r;tir calling siuccns fori, may o r nt dci.S ise. subrouti nes and IO/3650. For details, see the.acr O ares criU-o's -A. 1 s

MTS 3: SUBROUTINE AND MACRO' DESCRIPTIONS June 1970 Page Revised March 1972 IZO ROUTINES' RETURN CODES The return codes that may result from a call on ann innt or output subroutine depend on the type of the file or the device use in the operation. In general, a return code of zero means successfui cc:.letion cf the input or output operation, and a return code of 4 means end-of-file for an input operation and end-of-file-or-device for an output operation. If the file or device being used was specified as part of an explicit concatenation (and is not the last member of that concatenation), a return code of 4 will cause progression to the next element of the concatenation, and that return code will not be passed back to the caller. Thus, for example, if SCARDS=A+B then when the call is made to the SCARDS subroutine after the last line in A has been read, the file routines will signal an end-of-file, but this w'il be intercepted, and the first line in B will be read instead. Return codes greater than 4 are normally not passed back to the caller but instead cause an error comment to be printed and control to be returned to command mode. There are two ways to suppress this action and gain control in this situation. First, the subroutines SETIOERR and SICERR (see descriptions in this volume) are provided to permit a global inteccept of all input/output errors. Secondly, specifying the ERRRTN modifier on an I/O subroutine call will cause all return codes to be passed back. A description of the return codes that may occur with a particular file or device will be found in the appropriate User's Guide. In addition, a summary is provided below: Files: Input 0 Successful return 14 End-of-file (sequential read) Line not in file (indexed read) 8 Error Output 0 Successful return 4 Size of file exceeded 8 Line numbers not in sequence (SEQL) 12 For future expansion, should not occur 16 For future expansion, should not occur 20 Sequential file written with indexed modifier, or written with starting line number other than i 24 File not ina catalog (system error) 28 Hardware or system error I/O Routines' Return Codes 357

MTS 3: S -JROUTINE AND MACRO DESCRIPTIONS Page Revised March 1972 June 1970 32 Line truncated (2SP on sequential file) 36 Line padded (@SP on sequential file) Magnetic Tape: Input 0 Successful return 4 End-of-file mark sensed 8 Load point sensed on backspace control command 12 Logical end of labeled tape 16 Permanent read error (tape positioned past bad block) or improper control command 20 Should not occur 24 Fatal errors (may be due to equipment ralfuncrio.:s, fatal libel errors in which the position or t e tape is uncertain, or pulling the tape offt oAt ti ends of the reel). The tape must be rewound after any of these errors. 28 Volume and data set label errors (only or labeled tapes if label processing is enabled) 3'2 Error in sequence of I/O operations or commanids 36 Deklocking error Output 0 Successful return 4 End of tape strip sensed 8 Load point sensed on backspace control co.mann 12 Attempt to write more than tive records in eni-oftape area 16 Permanent write error or improper control command 20 Attempt to write on file-protected tape 24 Fatal errors (may be due to equipment malrunc-ions, fatal label errors in which the position of tne tape is uncertain, or pulling the tape ofz of the end of the reel). The tape must be rewound after any of these errors. 28 Volume and data set label errors (only on labeled tapes if label processing is enabled) 32 Error in sequence of I/O operations or commands 36 Blocking error Paper Tape: Input 0 Successful return 4 End-of-file 8 End-of-tape 12 Invalid control command 16 Hardware malfunction 358

MTS 3: SUEBROUTIN A"D MACRO DESCRIPTIONS Oune 1970 Page revised january 1971 Card input under HASP:'Input 0 Successful return 4 E.nd-of-file 8 Attempt to read in column bin ary mode Output 8 Attempt to write on card reader Prirted output: Input 8 Attempt to read from printer Output O Successfui return 8 Local page limit exceeded (user never gets control back for global limit exceeded) Punched output: Input 8 Attempt to read from punch Output O Successful return 8 Local card limit exceeded (user never gets control back for global limit exceeded)?Most other devices: Input O Successful return 4 End-of-file 8 Error Output O Successful return 4 End-of-file-or-device f if applicable] 8 Error I/O Routines' Resurn CodCs 359

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 IZO MODIFIERS IN TROD UCTION Modifiers are used to modify the action of a specific I/O call or a general I/O usage. Modifiers may be used in I/O subroutine calls (SCAEDS, SPR ENT, READ, etc), - in macro calls setting up the corresponding I/O subroutine calls, in calls to GETFD, or as parts of FDnames given in 1:TS commiands. Modifiers control such functions as upper or lower case conversicn, logical carriage control, machine carriage control, record timning, etc. In qeneral, there are three levels of precedence in the usnae. of mocifiers;. The first level of precedence is the modifiers specifie d on a call to one of the I/O subroutines. If the modifier is not specifiedd y bte subroutine. call, or when a user generated subroutine call is not relevant (e. q., when a $COPY command is issued), the second level of preceaeidc which consists of the modifier name as part of the FDname, applies. SNte that the group of modifiers which can only control the action of a sneci fi I/C call (for example ERRRTN and NOTIFY) are not valid at this level of preceaence. If the action of the modifier is not specified by the second level, tne third level of precedence, which consists of the defauit specifications, applies. The default specification depends upon the type of -Dnane referenced in the I/O call and the settings of global switches. These defaults are given in the explanation of modifier bits below. Modifier specifications given at the first level of precedence will overr de specifications given at the second and third levels. Modifier specifications given at the second level will override specifications given. at the third level. This precedence process is illustrated in the diagram below. Each modifier pair is treated independently in the above precedence process. level 1: Subroutine Call Modifiers Level 2: FDname Usage Modifiers - >1 level 3: Defaults -. >1 Ef- fective Modifers I/O Modifiers 361

MTS: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 The example below illustrates the three levels for controlling the TRIM modifier. CALL SCARDS(REG,LEN, 16384,LNUM) ----- (16384 specifies -TRIM) J SCARDS=FYLEiTRIM on $RUN command... A Default is TRIM for file..... -T R IM CALL SCARDS (REG,LEN,O,LNUM)......... (O makes no specification) SCARDS=FYLE-'TRIM Default is TRIM for file........... -TRI M CALL SCARDS (REGLEN, 0,LNUM)....... (O makes no specification) SCARDS=FYLE..................... Default is TRIM for file -- TRIM The action of the modifiers specified on a subroutine call is ccntrollei by a fullword of modifier bits given as one of the parameters to the subroutine. The action of the modifiers on the subrout ne call apply cnly to that specific call. There are two classes of modifiers. (1) Bits 0-7 are referenced individually and specify the options for a secific I/O call. If the bit is set, the modifier's action is enabled. If the bit is not set, the default specificaticn is used (which normally means the modifier action is disabled). (2) Bits 8-31 are referenced in pairs and specify options for a en erai 1/0 usage. For each option, one bit is used as an "ONN" bit and the otner as an "OFF" bit. If either of tne bits, but not both, is set, t e modifier action is as specified. If neither or both oi the bits is set, indicating a "don't care" condition at this level of precedence, the modifier name appended to the FDname Jo s used. If there is rno 362

MTS 3: SUBROUTINE AND MACRO DESCEIPTIONS June 1970 modifier name appended to the FDname, the default specification -s used. The normal programming practice is to leave the modifier bits zero on the subroutine call and apply the modifier names to the EDname referenced unless the program depends upon the modifier bits being set for a specific. subroutine call. Here is an example done first in assembly language and then in FORTRAN: FORTRAN is: CALL SCARDS, (REG,LEN,.MOD,LNU1M) REG DS 20F LEN DS H MOD DC X'00004000' Specifies no trimming of input lines LNUM DS F INTEGER*2 LEN DATA MOD/Z.00004000/ Specifies no trimming CALL SCARDS (REG, LEN, MOD, LNUM) Note that if the subroutine call is set up by a macro cali, the modifier names rather than the bits are used in the macro parameter list. Thus the above example would become SCARDS REGLEN,d@TRIM,LNUM'he action of modifers applied to the FDnames is controlled by the modifier name (preceded by i) appended to the FDname. The action of the modifiers appended to the FDname apply to all I/O calls referencing t at usaf of the file or device. If the modifier name is preceded with i"" or "-", the other bit of the bit pair is set, which negates the action oL i e modifier name. [The modifier applies only to the FDname to which it is attached. ] If implicit or explicit concatentation to another FDname occurs, the modifiers must be applied to both FDnames even if the FDnanes are the same. If the user at a terminal is prompted for an EDname, the vfull Fnage including the modifiers and line number range must be given with each request. The order of modifier names appended to an FDname is unimportant. Some examples are FILE1I IUC Specifies indexed and upper case FILE23-TRIM Specifies no trimming *SINK *dNO0CC Specifies no carriage control KSINK*CCC Specifies no carriage contrei RDR iBEN Specifies no BCD conversion FILE3iPFXiCC (1, 10) Specifies prefix and carr control FILE3 aPFX$CC ( 1 10) + (20,30 ) aCC Specifies prefix and carr control for lines 1 to 10 and carr control for lines 20 to 30 If the modifier action is also specified on a subroutine call, the Modifier action applied to the FDname is overridden. I/O Modifiers 363

N TS 3 SUBROUTINE AND MACRO DESCRIPTIONS June 1970 EXEIANATION OF MODIFIERS the device types discussed below in the exceptions to the default modifier bit specifications are the device types as listed in the description of "Files and Devices" in Volume 1 of the MTS Manual. The device types discussed here are: FTR Printers TTY Teletype terminals via IBM 2703 Transmission Control 2741 IBM 2741 and 1050 terminals via IBM 2703 Transmission Control 2260 IBM 2260 Display Unit PEP8 Terminals via the Data Concentrator STP 9 Track Magnetic Tape Drive 7TP 7 Track Magnetic Tape Drive SDA Synchronous Data Adaptor (Remote batch via IBM Controllers) HPTR Printed output under HASP The values indicated below with each bit specification are the values that the mcdifier word for a subroutine call would have if that modifier option only was specified. Bit 31 SEQUENTIAL, S Value: 1 (dec) 00000001 (hex) 30 INDEXED, I 2 00000002 Default: SEQUENTIAL Exceptions: None In general, the INDEXED modifier is applied only to line files, while the SEQUENTIAL modifier is applied to line files, sequential files, and all types of devices. Note that the SEQUENTIAL modifier and the sequential file are not directly related. Tae paragraphs below describe the action of this modifer pair and the results that occur when these modifiers are not used in the normal manner. With each logical unit (or FDUB) there is a current line pointer which contains the line number of the last record read or written. When an I/O operation is performed, the current line pointer is first set to the line number of the record to be read or written before the actual reaa or write occurs. After the read or write operation has occurred, the current line pointer will contain the line number of the record last read or written. I/O operations involving line files may be done With either SEQUENTTIAL or INDEXED specified. A SEQUENAIA L I/C operation occurs when the user specifies that the "next" record is to be read or written. For a read operation, "next" means the 364

MTS 3: SUBROUTINE AND LIACRO DESCRIPTIONS June 1970 record that is next in ascending line number order from the current value of the line pointer (last line read or written) of the same logical I/O unit (or FDUB). If, howevers an increment was explicity given with the FDname, the line number read is the current value of the line pointer plus the first multiple of the specified increment for which t. ere is a line in the file. For a write operation, "next" means t he current value of the line pointer (last line read or written) plus the increment specified with the FDname (defaults to 1) of the same logical I/O unit (or FDUB). An INDEXED I/O operation occurs when the user specifies the line number of the record to be read or written. As an example, consider the following FORTRAN program segment. INTEGER*2 LEN DATA MOD/2/ Specifies INDEXED 1 CALL READ(REG,LEN,0,LNR,2,&2) CALL WRITE (REG,LEN,MOD,LNR3) GO TO 1 2 CALL EXIT Tnis program will perform a read SEQUENTIAL and write INDEXED using the line numbers from the read operation as the line number specifiications for the write operation. The command (assuming compilation of the above into -LOAD#) $RUN -LOAE# 2=A 3=-B will be equivalent to $COPY A B~I which will copy file A into file B preserving the line numbers of file A as the line numbers for file B. If a series of I/O operations involving a given usage of a iine file are intermixed with iNDEXED and SEQUENTIAL operations, the SEQUENTIAL operation will begin sequentially wi h. the 1 ine following the last line specified in the INDEXED operation. INDEXED operations following SEQUENTIAL operations will use the line number given in that INDEXED specification. I/O operations involving seauential files must be none SEQUENTIALly. If the user specifies INDEXED on a sequential file operation, an error message will be generated unless the global switch SEQFCHK is OFF, in which case the operatoo n will be performed as if SEQUENTIAL was specified. Atte pting a sequential operation with a starting line number other than 1 (for example $COPY FYLE(2) ) will also give an error comment if SEQFCHK is ON. I/O operations involving sequential devices, such as card readers, printers, card punches, magnetic tape units, paper I/O Modifiers 365

MTS 3. SUBROUTINE AND MACRO DESCRIPTIONS June 1970 tape units, and terminals, are inherently sequential and are normally aone SEQUENTIALly. If the SEQUE NTIAL, nodifier is specified, the line number attached to the line is the current value of the line pointer plus the increment specified on the FDname. If the INDEXED modifier is spccified, the line number attached to' the line is the li ne numbe specified in the calling sequence. The INDEXED aodlfier is used primarily in conjunction with the PRE FIX modifier. Notte that the device will treat the I/O operation as if SEQUENTIAL were specified. Bit 29 EBCD Value: 4 (dec) 00000004 (hex) 28 BINARY, BIN 8 00000008 Default: EBCD Exceptions: None The EBCD/BINARY modifier pair is device dependent as to the action specified. For card readers and punches, the EBCD modifier specifies EBCDIC translation of the card image which means that each card column represents one of the 25d 8-bit EBCDIC character codes. The BINARY modifier specifies that the card images are in column binary format which means that each card column represents two 8-bit bytes of information. The top six and bottom six punch positions of each column correspond to the first and second bytes respectively with the high order two bits of each byte taken as zero. Thne printers and file routines will ignore the presence of this modifier pair. Other device support routines recognizing this modifier pair are: 1. The Data Concentrator routines 2. The 2703 routines 3. The Paper Tape routines 4. The Audio Response Unit routines For information on the usage of this modifier pair in specifications involving the devices listed above, see t he respective User s Guides in Volu e 1 of the MTS Man ual. The list of device support routines recognizing this modifier is volatile and subject to change without notice. Users who wish to keep their programs device independent should not specify this modifier. 366

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 Bit 27 LOWERCASE, LC Value: 16 (dec) 00000010 (hex) 26 CASECONV, UC 32 00000020 Default LOWERCASE Exceptions: None The LOWERCASE/CASECONV modifier pair is not device dependent. If the LOWERCASE modifier is specified, the characters are transmitted unchanged. If the CASECONV modifier is specified, lower case letters are changed to upper case letters. This translation is performed in the user's core reqion. On input operations, the characters are read into the user's buffer area and then translated. On output operations, the characters are translated in the user's buffer area and then written out. Only the alphabetic characters (a-z) are affected by this modifier. [Unlike IBM programming systems, MTS considers the characters ", an, d as spec al characters rather than "alphabetic extenders" and thus the UC modifier does not convert ~, ", and into a, #, and $, respectively. ] Bit 25 NOCARCNTRL, NOCC Value: 64 (dec) 000000-40 (hex) 24 CC, STACKERSELECT, SS 128 00000080 Default: NOCARCNTRL Exceptions: CC for PTR, TTY, 2741, 2260, PDP8, SDA, and HPTR The NOCC/CC modifier pair is device-dependent. This modifier pair controls the presence or absence of logical carriage control (or stacker selection) on the output of records. For printer and terminal devices, the first character of each record is taken as logical carriage control if this character is a valid carriage control character and if the CC nodifier is specified. If the first character is not valid as a carriage control character, the record is written as if NOCC were specified. For further information on logical carranea control, see the "Carriage Control" description in tnis volume. For card punches, the first character of each card image is taken as the stacker select character it is a valid logical stacker select character (0, 1, or 2) and if the SS modifier is specified. If the first character is nor valid as a stacker select character, the card i'mage is punched as if NOCC were specified. The SS modifier is intended only for those users who are communicating directly with a physical punch (normally system progra nmers) and is not intended for normal batch usage under HASP. Note that the SS and CC modifiers reference the same modifier bit and thus may be used interchangeably. I/O fodifiers 367

MTS: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 The Magnetic Tape routines also recognize the presence of this modifier pair. For this description, see the Magaetic Tape User's Guide in Volume 1 of the MTS M~anual. The file routines will ignore the presence of this modifier pair. Bit 23 Value: 256 (dec) 00000100 (hex) 22 PREFIX, PFX 512 00000200 Default: -PREFIX Exceptions: None The PREFIX modifier pair controls the pref ixing of the current input or output line with the current line nunber. On terminal input, the current input line number is printed before each input line is requested. The line number used is determined as specified in the description of the SEQUENTIAL and INDEXED modifiers. An example for terminal input is $COPY *S0URCE~*(6,,2) @PFX A (6,2) 6 first input line 8 second input line end of file indicator Note that this would have the same effect with respect to line numbering as $G ET A $NU 6, 2 6 first input line 8_ second input line xx $UNN The current (prefix) line number is not equivalent to tle file line nu aber. In the example above, the prefix line and the file line numbers were explicitly made to correspond by also specifyinq a line number range on t..e output rDna. e (the file A). On input from card readers and files, tehe PREFIX modifier has no effect. On terminal output, the current i ne number is printed before each output line is written. The line number used is determined as specified in the description of the SEQUENTIAL and INDEXED modifiers. An example for terminal output is $COP Y A ( 1 1 0) * SI NK' ( 1 0 00,, 2) aPF X 100 first output line 102 second output line 368

MTS 3: SUBROUTINE AND MACRO DESC~RIPTIONS June 1970 Note again that the current line number is not equivalent to the file line number. On output to the printer or to a file, the PREFIX modifier has no effect. If the INDEXED and PRE;'TiX modifi'ers are given together for terminal output, the line numbers referenced by the INDEXED modifier will be the same as those produced by the PREFIX modifier. As an example, consider the following FCRTRAN program segment: INTEGER*2 LEN DATA MOD/Z00000202/ Turns on INDEXED and EREFIX 1 CALL R E AD(R E G L EN,,LR, 2,&2) CALL WRITE (REG,LEN,M OD,LNR,3) GO TO 1 2 CALL EXIT This program will perform a read SEQUENTIAL and a write INDEXED and PREFIX. The command (assuming compilation of the above into -LOAD#) $RUN -LOAC# 2=A 3=*SINK* is equivalent to $COPY A *SINK*@I8PFX which is also similar to $LIST A with a slightly different formatting of tie line numbers. Bit 21 Value: 1024 (dec) O00000400 (hex) 20 PEEL, GETLINE#, 2048 00000800 RETURNLI NE# Default: -PEEL Exceptions: None The PEEL modifier pair has two functions depending upon whether it is specified cn input or on output. On input, if the PEEL (GETLINE#) modifier is specified, a line.nu er is extracted from the front of the current input line, The line number is converted to internal form (external valu ti.es 1000) and returned in the liine number parameter during t;e read oper ation. See the subroutine description of SC.ARS and READ. The remainder of the line is mnovel into th~ input region specified. As an example, considaer the fociowing FORTRAN program segment: I/O Modifiers 369

MT S 3 SUBROUTINE AND MACRO DESCRIPTIONS June 1970 INTEGER*2 LEN DATA MOD/2048/ 1 CALL SCARDS(REG,LEN,tiOD,LNR,&2) Read with PEEL CALL SPRINT(RZG,LEN,0,LNR) GO TO 1 2 CALL EXIT The program will read an input line, extract the 11ne nunbe:, and write out the line without its line.numbe. The following sequence (assuming corpilation of the above into -LOAD ) $RUN -LOAD# SCARDS=*SOURCE* SPRINT=ABC 10AAA 12BBB is equivaient to $COPY *SOURCE*~GETLINE# ABC 10AAA 12BBB Listing the file ABC will produce $LIST ABC 1 AAA 2 BBB If the PEEL modifier is specified in conjunction with the INDEXED modifier, the line number of the input line can be used to control the destination of tne line during output. For example: I N'TE. GER*2 LEN DATA MOD1/2048/, MMOD2/2/ 1 CALL SCARDS(REG,LEN, MOD1,LNR,&2) Read witn PEEL CALL SPRINT(REEG,LEN,MOD2, LNR) Write iNLEXLED GO TO 1 2 CALL EXIT This prograui will read an input line, extract tne- ine number, a0ncL write out the line with the extracteda irne numoer as the line number specification for an izndexed write operation. The tollowing sequence (assuming compilation of the above into -LOAD#) $RUN -LOADt SCARDS=-SOURCE* SPRINT=ASiC 10AAA 12BBB is equivalent to 370

MTS 3: SUBROUTINE AND MACRO DESCIJTi UONS June 1970 Page revised JOnuary 1971 $COPY *SOURCE* GETLINE# ABC I 10AAA 12BBB which is also equivalent to $GET ABC 10AAA 12BBB Listing the file ABC will produce $LIST ABC 10 AAA 12 BBB On output, if the PEEL (RETURNLiNEW) modifier is specified, the line number of the current output line is returned in the line number parameter of the subroutine call during the write operat on. See the subroutine descriptions of SPRINT, SPUNCH, SERCCM, and WRITE. The line itself is written out and is unaffected by the presence or absence of this modifier. The modifier is used on outout to aid the programmer in recording the line number of the current line written out. Bit 19 Value: 4096 (dec) 00001000 (hex) 18 MACHCARCNTRL, MCC 8192 00002000 Default: -MCC Exceptions: None The machine carriage control modifier pair is devicedependeont. T he MCC modifier is used for printing output (via printers or terminals) from programs producing cutput in which the first byte of each line is to be used as the command code in the Channel Command Word (CCW) used for output to a 1403 (or 1443) printer. If the MCC modifier is specified and the first byte of the output line is a valid 1403 CCW command code, the line is spaced accordingly and printing starts with the next byte as column 1. If the first byte is not a valid 1403 CCW command code, the entire line 1s printed using single spacing. Spacing operations perf-ormed by machine carriage control occur after the line in isc printed (as opposed to logical carriage control in which the sPacing is performed belore each line is printed). Host programs do not produce output using machine carriage control.. f ew programs that do (such as *ASM1G and the TEXT360 programs) internally specify HCC for their output assuming that is bound for a printer. Hence HCC need not be specified. if the user directs the output to a file, when the fie is printed, fCC will have to be specified. For example: I/O Mo....rs 371

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS Page revised January 1971 June 1970 $RUN *ASMG SCARDS=A SPRINT=B SPUNCH=C $COPY B TO *SINK*~MCC The MCC modifier pair is ionored for files and all devices other than printers or terminais. For further information on machine carriage control, see the "'Carriage Control" description in this volume. Bit 17 Value: 16384 (dec) 00004000 (hex) 16 TRIM 32768 00008000 Default: -TRIM Exceptions: Line files, sequential files, and HPTS The TRIM modifier pair is used to control the trimming of trailing blanks from input or output lines. If the TRIM modifier is specified, all trailing blanks except one are trimmed from the line. If -,TRIM is specified, the line is not changed. A trimming operation does not physically delete the trailing blanks from the line, but only changes the line length count. Bit 15 Value: 65536 (dec) 00010000 (hex) 14 SPECIAL, SP 131072 00020000 Default: ~-SP Exceptions: None The SPECIAL modifier pair is reserved for device-dependent uses. Its meaning depends unrz —ite particular device type with which it is used. The device support routines recognizing this modifier pair are: 1. The File routines (sequential files only) 2. The Data Concentrator routines 3. The Paper Tape routines 4. The Audio Response Unit routines For information on the usage of this modifier pair in specifications involving the devices listed above, see the respective User's Guides in Volume I of the MTS Manual. The list of device support routines recognizing this modifier is volatile and subject to change without notice. Users who wish to keep their programs device-independent should not specify this modifier. 372

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 Bit 13 Value: 262144 (dec) C0040000 (hex) 12 IC 524288 00080000 Default: The setting of the IC global switch (usually ON) Exceptions: None The IC modifier pair controls implicit concatenation. if the IC: modifer is specified, implicit concatenation wili occur via the $CONTINUE WITH line. If -IC is specified, ilicit concatenation will not occur. For example, $LIS -ROCG'A,'-'IC will list the file PROGRAM and will print $CONTiNUE WITH lines instead cf interpreting them as implicit concatenation commands. The use of the IC nodifer in I/O subroutine calls or as applied to FDnames will override the setting of the implicit concatenation global switch (SET IC=ON or SET IC=OFF) for the I/O operations for which it is specified. Bit 1 ERRRTN Value: 1073741824 (dec) 40000000 (hex) Default: -'ERRRTN Exceptions: None If the ERRETN modifier is specified (bit 1 in the nodi fier word is 1) when an I/O call is made, and if an I/O. error occurs when no SETIOERR/SiOERR interception has been established, the error return code is passed back to the calling program instead of printing an error comment. This nodifier may be used only with an I/O subroutine call. Tt may not be used as an attribute cn an FDname. Bit O NOTIFY Value: -2147483648 (dec) 80000000 (hex) Default: -'NC1TFY Exceptions: None If the NOTIFY modifier is specified (bit 0 in the modifier word is 1) when an I/O subroutine call is made, on returr GRO is set to a value indicating what has happened: 0 = no unusual occurrence 1 = new EDUB opened and no I/O done 2 and above, reserved for future expansion A new FDUB is opened if implicit concatenation occurreld, if a change to the next m.ember or an explicit concatenation is effected, or if a -replacement FDlname is requested. This modifier may be used only with an I/O subroutine call. It may not be used as an attribute on an FDname. I/O Modifiers 373

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 CARRIAGE CONTROL INI ODUCTION The term carriage control refers to the user's ability to conttol the vertical spacing of his output. Carriage control is used mainly for output to a terminal or a printer. It may also be used to specif y ccntro operations for magnetic and paper tapes. See the appropriate Users' Guuies in Volume I for details of usage. If the user has specified carriage control, the first character of every record (if output to a p-rinter or a terminal) is interpreted as a carriagqecontrol character. For a descriplion of the carriage control modifiers, see "I/O Modifiers" in this volume. The carrtiaqe control character determines the vertical positioning of the output paqe and is not part of the printed text. The control character is stri red tfrm the output record and printing begins with the second charactLer rah r than replacing the first character with a blank and starting t le eri n. with the blank. If the first character is not one of the legai ccdes for the particular device being -used, a default option of single space is assumed, and the first character is printed as part of the output text. e cn aracter codes are independent of the source language used oy the prcqr-a mmer. iMTS supports two types of carriage control —logical and machine. Both are used in the manner described above, differing only in the iegal carriage control characters and their effects. Logical carriage control 1s the Iore comimon, and, in general, the user need not be concerned with.acahi3.e carria ge control. MTS supports the machine type because several progra s (r.otably the assembler and TEXT/360) produce it. In most cases in whichn car:riaqe control is desired (such as output to printers ana terminals), the default for logical carriage control is on. To select eitier machine carriage control or no carriage control, the appropriate niodifier must be specified. LOGICAL CARRIAGE CONTROL The following table describes the logical carriage control characters and their effects. Carriage Control _75

MTS 3; SUBROUTINE AND MACRO DESCRIPTIONS June 1970 Char- i Effect Before t Exceptions t ] acter Printing 1 - -- t tl I Printer Q Terminal: Ti erminal: I I t I 1 IBM Data Con- j I I t I Controller I centrator I l blank I single space t ] I 1 { I I I I t o0 double space 1 i l I t I t i -I triple space i I A 1 I t I I I 1 I + I overprint previous line — I I ssI i undief2! I print without spacing first I l I I I I A i i I I & i suppress carriage return I undef I I t I after printing I i i I i 3 t i I I t 9 I single space and suppress I i ss I ss I t overflow3 I I &t i I t 1 I 1 t skip to top of next page4 t I skip 65 i skip 6 1 I' It I 1 1 2 I skip to next 1/2 page6 t I skip 6 I undef 1 A I i I! 1 i 4 I skip to next 1/4 page6 1 A skip 6 I under 1 i I I I I 1 6 I skip to next 1/6 page6 1 A skip 6 1 urder A & I I t 1 1 1 8 I same as 6 I f skip 6 I undef A t I! - I! I; I skip to top of next physical A I undef i undefr A page (at perforation) t A I I t A A I t I A < I skip to. bottom of physical I I undef A undef t A A page (at perforation) A [ A 1 ss = single space. 2undef = undefined, in which case spacing defaults to single space and the undefined character is printed as text. 3Normally, the printer automatically skips the first and la~t three lines of a page. A logical carriage control character of "9" supresses this skip, causing these top and bottom margins to be i gnored. 4 "Top" is physically three lines down from the perforation because of the automatic margin mentioned above. $skip 6 lines. 6%ne Icgicai page is divided into two halves, four quarters, ana six sixths. A loqical carriage control character orf 4L will, for example, position the page at the next quarter block even if this may in fact Le the top or the middle of a page. 376

?ITS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 Page Revised March 1972 READ SUBROUTINE DESCRIPTION Purpose: To read an input record from a specified logical I/O unit. Location: Resident System Alt. Entry: READS Calling Sequences: Assembly: CALL READ, (reg,len,mod,lnum,unit) FORTRAN: CALL READ(reg,len,mod,lnum,unit,&rc4,...) PL/I: See the IHEREAD subroutine description. Parameters: reg is the location of the core region to which data is to be transmitted. len is the location of a half word (INTEGER*2) integer giving the number of bytes read. mod is the location of a fullword of modifier bits used to control the action of the subroutine. If mod is zero, no modifier bits are specified. See the "i/O Modifiers' description in this volume. lnum is the location of a fullword integer giving the internal representation of the line number that is to be read or has been read by the subroutine. The internal form of the line number is the external form times 1000, e.g., the internal form of line I is 1000, and the internal form of line.001 is 1. unit is the location of either a fullword integer giving the logical I/O unit number (0,...,19), a leftjustified 8-character logical I/O unit name (e.g., SCARDS), or a fullword FDUB pointer (as returned by GETFD). rc4_._.. is the statement label to transfer to if the corresponding non-zero return code is encountered. Return Codes: O Successful return. 4 End-of-file. >4 See the, "I/O Routines' Return Codes" description in this volume. READ 193

MTS 3: SJBBOUTINE AND MACRO DESCRIPTIONS Page Revised March 1972 June 1970 Description: All five of the above parameters in the calling sequence are required. The subroutine reads a record from the I/O unit specified by unit into the region specified by req and puts the length of the record "(in bytes) into the location specified by len. If the mod parameter (or the FDname modifier) specifies the INDEXED bit, the inum parameter must specify the line number to be read. If the mod parameter specifies the SEQUENTIAL bit, the subroutine will put the line number of the record read into the location specifiec by lnum. There are no default FDnames for READ. There is a macro READ in the system macro library for generating the calling sequence to this subroutine. See the macro description for READ in this volume. Examples: This example, given in assembly language and FORTRAN, calls READ specifying an input region of 20 fullwords. The logical I/O unit specified is 5 and there is no modifier specification made in the subroutine call. Assembly; CALL READ, (REG,LEN,MOD,LNUM,UNIT) REG DS 20F LEN DS H MOD DC F'O' LNUM DS F UNIT DC F'5' or READ 5,REG,LEN Subr. call using macro. FORTRAN: INTEGER*2 LEN CALL READ(REG,LEN, O,LNUM,5, 630) 30 This example sets up a call to READ specifying that the input will be read from the file FYLE. Assembly: LA 1,'C'FYLE CALL GETFD ST O,UINIT CALL READ, (REG,LEN,MOD,LNUM,UNIT) REG DS 20F 19g

?iTS 3: SUBROCUTINiE AN}D;iAC0 EESCRIPTiCOS June 197 0 Pagj ~Rev'iXsed U ay i972 ~~CL EC F'O' UNiT DS? FORTRAN:, XTll V- L GETFD INTEGER*4 AERCF,UNIT CALL, CALL (GETFD, 2, O,ADICF('FY) tU iT) CALL READ (AREG,LEN, 0,LNU M,UNI T$3' 3) 30 v N- 95

XTS 3: SUBROUTINE AND nACRO DESCE PTIOINS June 1970 SCA R DS SUBROUTINE DESCRIPTION PurFose: To read an input record from the logical I/O unit SCAEDS. Location: Resident System Alt. Entry: SCARDS# Calling Sequences: Assembly: CALL SCARDS, (reg,len,mod,lnum) FORTRAN: CALL SCARDS (reg,len,mod,lnum,&rc4,...) Parameters: req is the location of the core region to wic' data is to be transmitted. len is the location of a halfword (iNT.EG G ) -teger giving the number of bhtes to be transmlinte. mod is the location of a fullword of Modi ier its used to control the action of the subroui nle. T ~c iS zero, no modifier bits are spec fiec. See e "l/O Modifiers" description in this volume. Inum is the location of a fullword integer giving internal representation of the lne ne nuber tzt ns to be read or has been read by the subroutine.?ee internal form of the line number is the exte ral form times 1000, e.g., the internal torm or line 1 is 1000, and the internal form of line.001 is 1. rc__4,,._. is the statement label to transfer to in the corresponding non-zero return code is encountere. Return Codes: 0 Successful return. 4 End-of-file. >4 See the "I/O Routines' Return Codes" description in this volume. Description: All four of the above parameters in the calling sequence a-e required. The subroutine reads a record into the re gio specified by req and puts the length of record _(in btes) into the location specified by len. If the miod paranCter ( r the FDname modifier) specifies the INDEXED bit, the 1 n. parameter must specify the iine number to be read. If the rmod parameter specifies the SEQUENTIAL bit, the Is Inoutie will put the line number of the record reaa into tne location specified by lnum. SCARDS 2c03

M TS =: SU"5Ti iI AN-D MACRO DESCRIL"TiONS June 1970 The default FDname for SC;RDS is *SOURCE*. There is a macro SCAP DS in the system macro Li -rary -fo genierating the caililng: —.ecuk.?nce to this subzouziln.. See toe macro description for SCARDS in this volume. Examples; T his examp e, given in assezmbl' language an. FO2?',iA.;, calls SCARDS specifying an input region of 20 fullwords. C here is no modifier specification made on the subroutine call. Assembly: CALL SCARDS, (REG,LEN,,' 0OD,LNUM) REG DS 20F LEl DS H MOD DC F'0' LNUM DS F or SCARDS REG,LLN Subr. call using macro. FORTRAN: INTEGERS2 LEN CALL SCARDS (REG,LEN,0,rLNUM,&30) 30 204

ETS 3: SUEROUTINE AND MACRO DESCRIPTIONS June 1970 Page revised July 1971 SD U P SUEROUTINE DESCRIPTION Purpose: Ic produce a dump of any or all of the following: (1) general registers (2) floating point registers (3) a specified region of core storage Location: Fesident System Calling Seguencc:s Ascembly: CALL SDUMP, (switch,outsub, wkarea,first,ias+) Parameters: switch i s the location of a full uo d containinc switches that govern the contert and fornat oi the dump produced. The switches are assigned as follows: bit 31: on if hexadecimna conversion of the core region is desired. 30: on if mnemonic conversion of the core region is deslred 29: on if EBCDIC conversion of the core region is desired 28: on if double spacing is desired; off if single spacing is desired 27: on if long output records (130 characters) are to be formed; off if short output records (70 characters) are to be formed 26: on if general registers are to be dumped 25: on if floating point registers are to be dumped 24: on if a core region is to be dumped 23: on if no column headers are to be produced outsub is the location of a subroutine (eg., SPRINT) that causes the printing, punchirg, etc. of the output line images formed by SDU~'?. wkarea is the location of a dcoubielword ali d area 400 bytes that may be used by SDU3i as a work area. first is the location of the first byte of a core SDUPr 237

MTS 3: SUEROUTINE AND MACRO DESCRIPTIONS Page revised July, 1971 June 1970 region to be dumped. There are no boundary requirements for this address. last is the location d6f the last byte of a core region to be dumped. There are no boundary requirements for this address; however, an address in last which is less than the address in first will cause an error return. Note: The default case for switch (all switches off) produces a dump as though bits 24, 25, 26, and 31 were on. Furthermore, if bit 30 (mnemonics) is on, bit 31 (hexadecimal) is implied. Note that bits 24, 25, and 26 spFecify what is to be dumped, bits 27 and 28 specify the page format, and bits 29, 30, and 31 specify the interpretation (s) to be placed on the regicn of core specified. Bits 29 through 31 have significance only if bit 24 is on. Return Codes: 0 Successful return. 4 Illegal paramEeters. Description: Cut ut Formats Registers: General and flcating point registers, if requested, are always given in labelled hexadecimal format. The length of the output record is governed by the setting of bit 27 of the switch. Core Storage: Although any ccmbination of switches is acceptable, the appearance of the dump output for a region of core storage is determined as follows: 1. If, and cnly if, the mnemonic switch is on, the unit of core storage presented in each print item is a halfwcrd aligned halfword. 2. If, and only if, the mnemonic switch is off and the hexadecimal switch is on (through intent or default), the unit of core stoage presented in each print item is a fullword aligned fullword. 3. If, and only if t the mnemonic and hexadecimal switches are off but the EECDIC switch is on, the unit of core storage presented in each print item is a doubleword aligned doubieword. 208

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 Page revised July 1971 In all cases, the output includes (1) the entire core storage unit (iialfword, fuliword, or doubleword) in which the first specified core location (parameter first) is found, (2) the entire core storage unit in which the last location (parameter last) is found, and (3) all intervening storage. Thus, the first and last printed items of a core storage dump may include up to a maximum of seven core bytes more tnan actually requested in the parameter list. If mnemonics are requested and SDUMP discovers a byte that cannot be interpreted as an operation code, then instead of a legal mnemonic, the cr.aracters "IXXXX" appear directly below the hexadecimal presentati lcn of the halfword in core that should have contained an operation code. When this occurs, the mnemonic scanner jumps ahead as though the illegal operation code specified an RR tyFe instruction (two bytes) and tries to interpret the byte at the new location as an operation code, etc. Any mnemonic print line that contains the "XXXX" for at least one of its entries is also marked with a single "X" directly below the line address that prefixes the hexadecimal nresentazicn of that same region of core. (The mnem.onic conversion routine includes the Universal irstruction Set and those instructions exclusively used by the Mcdel 67.) To facilitate tne location of particluar items in the output, line addresses always have a 2z-c-o in'the least significant hexadecimal position. Colurn headers are provided which give the value of the least significant hexadecimal digit of the address of the first byte in each print item. A line of dots is printed to indicate that a region of core storage contains identical ites. The core storage unit used for comparisons is haifwcrd, fullword, or doubleword depending u +on the type(s) of conversion speciried. In all cases, the core storage unit corresponding to the last item pri tecd efore the line of dots and the core storage unit for the first item after tane line and all intervening core storage units have identical contents. The last line is always printed (even if ail of its entries exactly match the previously printed line). SDUJP 209

MTS 3: SUBROUTINE AND MACRC DESCREITIONS Page revised July 1971 June 1970 E ExamFle: Assembly: EXTEN SPRINT CALL SDU MP, (SW, SPRINT,WK, FIRST, FIRST+3) WK DS 50D SW DC F'0' FIRST DC X'FlF2F3F4' 7 he above example will cause SDUMP to print the hex string'E 1F2F3F4'. 210

MTS 3: SUBROUTINE AND MACRO DESCRIPETIONS June 1970 SPRINT SUBROUTINE DESCRIPTION PurFose: To write an output record on the logical I/O unit SPRINT. Location: Resident System Alt. Entry: SPR I N T# Calling Sequences: Assembly: CALL SPRINT, (reg,len,mod,lnum) FORTRAN: CALL SPRINT (reg,len,mod,lnum, &rc4,.. ) Parameters: reg is the location of the core region from which data is to be transmitted. len is the location of a haifword (INTEGER' 2) integer giving the number of bytes to be transmitted. mod is the location of a fullword of modif ier bits used to control the action of the subroutine. If 0to is zero, no modifier bits are specified. See the "i1/ Modifiers" description in this volume. lnum (optional) is the location of a lullword intLercr giving the internal representation of the i ne number that is to be written or has been wri tten by the subroutine. The internal Iorm of the line number is the external form times 1000, e.g., tne internal form of line 1 is 1000, and the internal form of line.001 is 1. rc4.. is the statement label to transfer to if the corresponding non-zero return code is encountered. Return Codes: 0 Successful return. 4 Output device is full. >4 See the "I/O Routines' Return Codes" descripFion in this volume. Description: The subroutine writes a record of length len (in bytes) fzom the region specified by reg on the logical I/O unit SZ PIX2. The parameter lnum is needed only i the nood Daraaetre specifies either INDEXED or PEEL (RETURNLINE#). f I SX" ED is specified, the line number to be written is specified i lnum. If PEEL is specified, the line number of the record written is returned in inum. SPRINT 247

MITS 3. SUBROUTINE AND MACRO DESCRIPTICNS June 1970 The default FDname for SPRINT is *SINK*. There is a macro SPRINT in the system macro library for generating the calling s-acurnce to this subroutine. See the macro description for SPRINT in this volume. Examples: This example given in assembly language and FORTRAN calls SPRINT specifying an output region t. 30 bytes. No modifier specification is made in the subroutine call. Assembly: CALL SPRINT, (REG,LEN,MOD) REG DS 20F MOD DC F'0' LEN DC H'80' or SPRINT REG,LEN Subr. call using macro. FORTRAN: DATA LEN*2/80/ CALL SPRINT (REG,LEN,O) 248

.TS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 Page revised July 1971 S 1 D DP SUBROUTINE DESCRIPTION Purpose: 7c dump a region of the usergs virtual amemor irn the MTS standard format. For dumping registers, dum i ngj with mn'emcnics, and other ortions, see the SDUMP subroutine description in this vclume. Location: Resident System Calling Sequences: Ascembly: CALL STDDMEE, (switch,outsub,wkarea,first,last) Farameters: switch is the location of a fullword of in-ormation. The first halfword of sw3' tch is ta'en as the storage index number that will be orinted out in the heading line. The remairner of switch is taken as a group of switches as follows: bit 20: (Integer value = 2045) 4 3OLIf set, the call wiil be c o eed if LOADINFO declares that the regio- of storage is part of a library subroutine. 28: (Integer value = 8) D30U3B S 2 CE If this bit is set, the lines o- t e dump will be double spaced. hW- _ese the normal single spacing will occur. outsub is the location of a subroutine that will be called by STDDMP to "print"' a line. This subroutine is assuned to have the sane calling sequence as the SPRINT subroutine. wkarea is the location of a 00-word (fullword aligne ) region which STDIDMP will use as a work area. first is the location of the first byte of a core region to be dumped. There are no boundary requirements for this address. last is the location of the last byte of a core region to be dumped. There are no boundary requirements for this address; however, an address in last which is less than the address in first will cause an error return. s i^ Vo D w; 2 3

MTS 3: SUEROUTINE AND MACRO DESCRIETIONS Page revised July 1971 June 1970 Beturn Codes: 0 Successful return. 4 Illegal parameters. Description: 2his subroutine uses the same calling sequence as the subroutine SDUMP, but only looks at the bits and parameters as specified above in the calling sequence. For each call, this subroutine "prints" (calls the output subroutine specified in outsub) the following: 1. Blank line. 2. Heading giving information about the region of storage. The subroutine LOADINFO is called to obtain the information. 3. Blank line. 4. Dump of the region, with 20 (hex) bytes printed per line. To the left of the hexadecimal dump is the actual hex location and the relative (to the first byte of the region) hex location of the first byte of the line; to the right of the dump is the same information printed as characters. Non-printing characters (b4t combinations that do not match the standard 60 character set of printing graphics) are replaced by periods, and an asterisk (*) is placed at each end of the character string to delimit it. The lines "printed" are 133 characters long. Example: Assembly: EXTRN SPRINT CALL STDDMP, (SW, SPRINT,WK,FIRST, FIRST+3) WK DS 50D SW DC F'0' FIRST SC X'F1F2F3F4' The above example will cause STDDMP to print the hex string'E1F2F3F4'. 254

MTS 3: SUBROUTINE AND MkCRO DESCRIPTIONS June 1970 Page Revised March 1972 WRITE SUBROUTINE DESCRIPTION Purpose: To write an output record on a specified logical I/O unit. Location: Resident System Alt. Entry: WRITE# Calling Sequences: Assembly: CALL WRITE, (reg,len,mod,lnum,unit) FORTRAN: CALL WRITE(reg,.len,mod,inum,unit, rc4,...) PL/I: See the IHERITE subroutine description. Parameters: Erg is the location of the core region from which data is to be transmitted. len is the location of a halfword (IN EG ERG2) integer giving the number of biytes to be transmi te. mod is the location of a fullword of modifier bits used to control the action of the subroutine. If ncd is zero, no modifier bits are specified. See the "I/C Modifiers" description in this volume. lnum is the location of a fullword integer giving the internal reoresentation of the line number than iS to be written or has been written by the subroutine. The internal form of the line number is the external form times 1000, e.g., the internal for:m of line 1 is 3000, and the internal form of line.001 is 1. unit is the location of either a fullword irneger giving the logical I/O unit number (0,...,19), leftjustified b-character logical I/O unit name (e.g., SPRINT), or a fullword FDUB pointer (as returned by GETFD). rc4_..... is the statement label to transfer to if the corresponding non-zero return code is encountered. Return Codes: 0 Successful return. 4 Output device is full. >4 See the "I/O Routines' Return Codes" description in this volume. RI TE 2 c 7

tiTS 3: SJBROUTINE AND MACRO DESCRIPTIONS Page Revised March 1972 June 1970 Description: The subroutine writes a record on the logical./0 u:it specified by unit of en gh L e.! ( i bytes) fro, he. re g ion specified by reg. The paranmeter lnu is used only it 4- e 1od parameter specifies either INDEXED or PE'EL (RTURNL iUNL, ift ItNDEXED is specified, the line number to be written is specitied in Inum. If P:EEL is specified, the line numbezr or the record written is returned in lnum. There are no default FDnames for WRITE. There is a macro WRITE in the systei nacro iir rL) roI generating the calling sequence to tihis subroutine. See the macro description for WRITE in this volume. Examples: This example given in assembly language and FORTR AN calls WRITE specifying an output region or 60 bytes. The logical I/O unit specified is 6 and no modifier specification is made in the subroutine call. Assembly: CALL WRITE, (REG,LEN,MOD,LNUM,UNIT) REG DS 20F ~MOD DC F'0' LNUM DS F LEN DC H'80' UNIT DC F'6' or WRITE 6,REG,LEN Subr. call using macro. FORTRAN: DATA LEN*2/80/ CALL WRITE(REG,LENO0,LNUM,6) This example given in assembly language sets up a call to WRITE specifying that the output will be written into the file FYLE. Assembly: LA 1,'C'FYLE' CALL GETFDr ST O,UNIT CALL WRITE, (REG, LEN, NOD, LNUM, UNIT) REG DS 20 LEN DS H MOD DC F'O' 268

M TS 3: SUB R O UTi NE A.D i CRO DESC I P TI S Junre 1970 Page Revised Ptarch 1972 LNU. DS P UNIT DS F FORTRAN: EXTERNAL GiE?FD INTEGER*4 ADROFUNIT CALL RCALL(G-ETFD,2,0, ADRO ( t(FYLE ), 1,UNIT) CALL WRITE (REG,LEN,0, LNUY, UNiT, F 3 0) 30''Ri'T 269

MTS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1970 USING MACRO LIBRARIES 2he Computing Center maintains a number of macro libraries in p ublic fiIes. In addition the user can construct and use his own macro lihraries. Any macro library to be used when assembling a program must be exF icil y mentioned when running the assembler. Up to five macro libraries nay be used for one assembly. A macro library is specified by attaching it to one of logical units 2, 3, 4, 5, or 0 when running the assembler. For example, SlhUN *ASMG SCAR'DS=SOURCEPGM SPU NC=-OBJ O=*SYSMtAC will use *SYSMAC as a macro library. The macro libraries are searched for a definition in the order of 1. Nacro library attached to logical unit 2 lacro library attached to logical unit 3 3. Macro library attached to logical unit 4'4. Macro library attached to iogical unit 5 5. Macro library attached to logical unit 0 so that $SiUN *ASMG SCARDS=IN SPUNCH=OBJ 2=MYMACLIBR 0=$SYSMAC will cause a macro to be expanded from M1Y1ACL B if it is the-re,, otherwise, from *SYSMAC. Note that any macro definitions suprli ed wii I Ae assembler input will take precedence over definitions in a macro library. Ihe following public files contain macro libraries: *SYSMAC *SYSMAC is the system macro library. These macros are described below. *OSMAC OSMAC contains the macro library from IBS's Operatig} 3yst.e.s It is designed to enable the assemblin.- of OS progr 1a-s u1nder 4MTS. The programs so assembled rust not be run undr- iS. Descriptions of these macros are found in "1B Sy!st 7c/So Operating System Supervisor and Data Managemenz'acroInstructions", form C28-6647. 280

MTS 3: SUBROUTINE AND M'CRI DESCRIPTIONS June 1970 *1 contains a set of macros to impleIrent the *1 list prccessing language. *1 is a low-level list language similar to L6. For a complete description, see the "*1 User's Guide" in Volume 7 of the MTS Manual.'acros 881

MTS 3: SUBROUT:INE AND MACRO DESCRIPTIONS Ju n e 19 70 CONST R iUCT I NG A MACRO IBRA RY As described below, a macro library ihas a rather simple structure. S mall macro libraries can be easily constructed by hand. For constructing.arger macro libraries, the program *MACGEN is available. Structure 0o a Macro Lib r.ary A macro library is a line-file containing both a directory of t macr cs and the macro definitions themselves. A. The directory: 1. Each entry of the directory contains the name olf.acro in cou 1ns 41-8 and t e line-number of the m acro mde - ni — on h ead er of the corresponding macro in columns 10-16. ot.- the nae- and the linie-number must be left justified with tr"ail g aiaks. 2. The line-number of the first entry in the directory ust. be 1 3. The terminating entry in the directory is a string of ig ht zeros in columns 1-8. B. The macros. 1. The line..number of the macro-definition header or each macro must be a positive integral number. 2. The first macro follows the last entry in the director'vy Example: $NUMBER 1 1I BASR 10 BAS 20 00000000 $NUMBER 10, 1 I AC RO &LABEL BASRE GREG I r, REG2 L ABEL BAL. 3 T G 1 EREG 2 M E NV D $NUMBER 20. 1 [i A C R O &LABEL BAS R EG ZLOC SLABEL BAL &RE 1 iLOC?END 282

.M TS 3: SUBROUTINE AND MACRO DESCRIPTIONS June 1 970 M ACG.EN The,ublic file *MACGEN contains a program to construct a macro I' iary. Before the program is run, the macro def initiols should be put in n file starting at some relatively high positive line numbiter. The?4A'..' J. ie of each definition must occur cn an integral line number Then. is run tc construct the directory, which must start at line 1 of trh.e ile. *MACGEN reads the definition via SCARDS and writes the directory via SPUNCH. An example might be $RUN *MACGEN SCARDS=FILE(1000) SPUNCH=FILE (1) if the definitions begin in line 1000 of FILE. Ihe following would produce a macro library from the same macros as the previous section: $SCUEATE MAC $N M 3 E R 1000 MACRO'LABEL BASR &REGI,&REG2 &LABEL BALR &REG2, &REG2 MEND MAC RO &LABEL BAS &REG1,&'LOC &LABEL BAL R EG1, &LOC MEND $UNNUMBER $RUN *MACGEN SCARDS=MAC(1000) SPUNCH=MAC Macros 283

MTS 2: PUBLIC FILE DE SCBITIONS April 1971 *MACGEN Contents: The object module of the macro library generator Frcgram. PurFose: To generate a directory for a set of macro definiticns. Usage: The program is invoked by an appropriate $RUN ccmmand. Logical I/C Units Referenced: SCARDS - the file ccntaining a set of macro definiticns. SPUNCH - the file which will contain the directcry. Example: $RUN *MACGEN SCARDS=WATM~AC(1000) SPUNCH=WATMAC Description: An MTS-formatted line directory is Froduced on SPUNCH icr the set of macro definitions read through SCARDS. Entries in the line directory occupy integral line numbers beginning with line number one (1). The directory terminator is inserted after the last macro definition has been read. *~ACC-E 197

MTS 3: SUBROUTINE AND?ACRO DESCNIPTO1CS June 1970 MACRO DESCRIPTION Purpose: To generate prolog code for the entrance to a subroutine. Locaticn *SYSMAC Prototype: f label] ENTER reg[,SA=savarea][,LENGTHI-Ien][,TREG=tep reg Parameters: is the regis-ter t-o be es ablisea es a s ase register. It should not be 15savarea (optional) is a keyword param.eter specif yin, location of a save area to use. f sava:- c Ocitted, a call to the GETSPACEE subro uine s made to get a save area of length s;eci i z yv len. len (optional) is a keyword parameter speci....- tthe length of the save area to be obtained if savarea is omitted. If len is oait ed, 72 is used. temnpreg (optional) is a keywvford pE arametr spec yring the temporary register to be used in the frolog code. If o.mitted, G 15 is used. te- eT s houid not be the same as }ci. Description: ENTER causes code for the foilowing to be produced: 1, Generates USIING *, req 2. Establishes req as the base regist er. 3. If savarea is omitted, a call to GETSPACE is made to get a save area of length len. 4. Establishes forward and backward links between save areas. Examples: SUBR ENTER 12 F ENTER 9,SA=SAVAREA G ENTER 11,TREG=12 ENTER Facr 305

MTS 3: SUBROUTINE AND MACRO DESC LIPTIONS JunD 1970 EXIT MACRO DESCRIPTION PupFose: To reestablish the calling program's save area and tc return with a return code in GE15 and an optional returned value in GRO. iocat i on: *SYSMAC Prototype: [label3 EXIT rc ][,rval ],MF=fs] Parameters: rc (optional) is a self defining tern or the location of a fullword return value to be loaded into Q1 S. If rc is omitted, the return code is zero. rc may be expressed as a register number in parentheses. rval (optional) is a self defining term or zhe location of a fullword return value to be loaded i no 3 O. It may be expressed as a register nu ber in parentheses. fs (optional) specifies that the save area pointed to by GE13 is to be released by calling REES-PAC. Description: This macro requires that the save area be properly linked or entry to the subroutine as is done by the ENTE macro. If the ENTER macro is used and it obtains space via the GETSPACE subroutine, this space can be released by specifying MF=fs. Examples: EXIT 4 OUT EXIT 0, (0) Return value is in GRO. EXIT 0,4 Return value is 4. LABEL EXIT O,RVAL Return value is in RVAL. EXiT,acro 309

MiTS 3: SUBROUTINE AND MAC7iO DESCRiTI0 ONS June 1970 IOHZ/360 acros MACRO DESCRIPTION Purpose: To generate calls to IOH/360 to perform formatted i.p ut and output. Location - *LIBRARY Prctotype [ label] RDF3T fmt[, (par,...) [labe l] PRFMT fmt[, (par,...) ] [label] PCFMT fmt[, (par,...) 3 [label] WRFiT fmt[, (par,...) 3 [label] S.RFMT fmt[, (par,...) 3 [label] GUSFMT fmt[, (par,...) 3 Parameters: fmt specifies the location of the IO1i/360 format. This must be given as a symbolic expression. See the "I nt rod uc tion to IOH/3601" in this volume for a description of the format language. par specifies one simple or block parameter giving rbe location to be read or written. a si ple parameter is desired, this must be specifie as a symbolic expression. If a block parameter is desired, tais must be specified as two symbolic expressions separated by ",..,"; for exaxmple, A,...,A+20 Description: The above macros are used to call 1OiH/360 Ioz asVeniJ language programs. This description covers or I a elementary usage omitting many additional paraletzes,nlcn may be specified, and several other related macros. cr a complete description of IOH/360, see the "I /3o0 Lser's Guide" in Volume 5 of the MTS Manual. When one of these macros is executed, IOH/360 wi be called to perform input or output according to thLe format gi ven by fmt into or from the locations specified by par. Arny raber of simple or block parameters may be specified, and mint or output will continue until a parameter specified as "'" is encounterea. For this reason, the last _ar snould be grven as "0" to terminate input or output. By using some of the more advanced features of these m acros, it is possible to compute dynamically the paraet ers to be used, specify parameters relative to base registers, etc. Those users who need the advanced reatures shoulc see the "IOH/360 User's Guide" in Volume 5. 10H/360 ~8acros 319

,1 3: SUBROUTTNE AND MACRO DESCRIPTZONS June 1970 Examples: RDLBL RDFM T INEMT, (CNT,A,.., A+ 1 Q 4, 0) INFMT DC C'I, 11WF*' CNT DS F A DS 11E This example will read one fullword integer and 11 ful1word floating-point numbers in free format. PRLBL PRFMT OFMT, (NUM,RESULT,C,...,C+5*4,0) NUM DS F RESULT DS E C DS 6E OFMT DC C""-CASE ",I5, "RESULTS ",7WF6. 2* This example will print one fullword integer and 7 fullword floating-point numbers plus the two cQmments in the format specification. 320

X TS 3: SUBROUTINE AND MACRO DESCRP. IO NS June 1970 RETURN MACRO DESCRIPTION Purpose: To return control to the calling program and to signal normal termination of the returning program'. Locaticn: *SYSMAC Prototype: [label] RETURN [ (rl[,r2]) ][,T][,RC=codeJ Parameters: r1,r2 (optional) is the range of registers to be restored from the save area to which the address in GR13 points. The registers should be spec>fied to cause the loading of registers 14, 15, 0 through 12 when used in a LM instruction. I r is not specified, only the register specified by the rl operand is loaded. If the operand is emitted, the contents of the registers are not altered. T (optional) causes the control program to flag the save area used by the returning program. A byte containing all 1's is placed in the highorder byte of word 4 of the save area after the registers have been loaded. code (optional) is the. return code to be passed to the calling program. The return code should have a maximum value of 4095; it will Ab Ilacce right-adjusted in GR15 before the reu rn is made. If RC=(15) is coded, it indicates that the return code has been previously loaded inte GR15; in this case the contents of GR15 are not altered or restored froam the save area. (if this operand is omitted, the contents of GR15 are determined by the rl,r2 operands.) Description: The return of control by the RETURN macro instruction is always made by executing a branch instruction using the address in GR14. This macro can be written to restore a specified range of registers, provide the proper return code in GR15, and flag the save area by the returning program. See the "Calling Conventions" description in this volume for a further explanation of save areas and their formats. X"ISEM System/360 Operating System Supervisor Data Management and Macro Instructions", Form C28-6647. RETURN Macro 333

UNIVERSITY OF MICHIGAN 3 9015 02826 3716 M4TS 3: SUBR~OUTINE AND M~ACRO DESCRIPTIONS June 19710 Vxamples: LABi RETURN (14,"12),RC=4 LAB2 REU~N (5.,10),T LAB3 RETURN (5,10),rTRC=(15) 334 ~ LB RTR