ibm assembler mannual.doc

Upload: shantanu-kumar-dash

Post on 07-Jul-2018

242 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 IBM Assembler mannual.doc

    1/118

    IBM 370 ASSEMBLY LANGUAGE 1 / 118

    IBM 370 ASSEMBLYLANGUAGE

    BASIC COURSE

  • 8/18/2019 IBM Assembler mannual.doc

    2/118

    IBM 370 ASSEMBLY LANGUAGE 2 / 118

     

    CONTENTS

    1. Introduction2. Basic Concepts3. Instructions

    4. Symbols, literals, expressions, Constants and data areas, locationcounter 

    5. Integer operations6. ecimal operations!. "loating point operations#. ata trans$er and %ogical operations&. Bit manipulations1'. Branc(ing11.  )ssembler irecti*es12. +C% aspects 

    13. Subroutines, linage 24 bit mode14. -acros and conditional assembly15. -S system -acros16. S)- -acros1!. %inage Con*entions, 24 / 31 bit addressing, mixed mode

    addressing issues

    References1. High leel !sse"#ler f$r M%S & %M & %SE' (r$gr!""ers G)i*e M%S & %M e*i+i$n,. High leel !sse"#ler f$r M%S & %M & %SE' L!ng)!ge Reference M%S & %M e*i+i$n3. M%S (r$gr!""ing Asse"#ler Serices g)i*e

    -. M%S (r$gr!""ing Asse"#ler Serices reference. M%S !sse"#l/ l!ng)!ge #/ Mc)illen !n* (rince. Asse"#l/ l!ng)!ge 2r$gr!""ing f$r +he IBM370 !n* c$"2!+i#le c$"2)+ers #/

    Mich!el . 4)*lic5.

  • 8/18/2019 IBM Assembler mannual.doc

    3/118

    IBM 370 ASSEMBLY LANGUAGE 3 / 118

    IN6ROUC6ION  back 

    What is Assembly Language

    ⇒ %o0estle*el o$ programming on a system

    ⇒ Symbolic $orms o$ representing mac(ine language instructions⇒ sually represents a single mac(ine instruction

    ⇒ -ac(ine dependent

    ⇒ -ore i$$icult to use t(an a (ig(le*el language

     Advantages over high-level language

    ⇒ ery e$$icient and tig(t code can be de*eloped

    Disadvantages

    ⇒ )pplications de*elopment time is more

    ⇒ )pplications are mac(ine dependent

    ⇒ i$$icult to learn and understand

     Advantages over machine language

    ⇒ se o$ mnemonic operation codes (elps remembering t(e instructions

    ⇒ Symbols can be used

    ⇒ -acros can be used to generate repeated codes

    ⇒ Conditional assembly enables tailoring t(e code generated

  • 8/18/2019 IBM Assembler mannual.doc

    4/118

    IBM 370 ASSEMBLY LANGUAGE 4 / 118

    BASIC CONCE(6S  back 

    IBM370 MACHINE ARCHI6EC6URE

    • -ain storage )ddressed by 24 bits or 31 bits

    • ne single address space contains code and data

    • Byte is t(e least addressable unit• Instruction execution is $aster i$ data is aligned on a $ull 0ord boundary

    • Instruction categories

    ⇒ "ixed point )rit(metic,

    ⇒ ecimal )rit(metic,

    ⇒ "loating point )rit(metic,

    ⇒ %ogical perations,

    ⇒ Branc(ing,

    ⇒ Status S0itc(ing,

    ⇒ Input utput

    • rogrammer accessible ard0are egisters are

    ⇒ rogram Status 7ord 8S79 64 bits 0ide

    ⇒ :eneral urpose egisters 8:s9⇒ "loating oint egisters 8"s9

    ⇒ Control egisters 8Cs9 '15 eac( 32 bits 0ide

    ⇒  )ccess egisters 8);S9 '15

    • S7

    ⇒ 64 bits in lengt(

    ⇒ Contains t(e Condition Code 8t0o bits9

    ⇒  )ddress o$ t(e next instruction to be executed.

    ⇒ S7

  • 8/18/2019 IBM Assembler mannual.doc

    5/118

    IBM 370 ASSEMBLY LANGUAGE 5 / 118

    ASSEMBLY STATEMENT FORMAT

    1 10 16 72

    • "ixed "ormat. Can be c(anged only t(roug( IC=% )ssembler irecti*e

    • Blan lines are in*alid

    • "ields in a statement are separated by one or more blans

    • >ame ? label $ield i$ present must start in column 1 and maximum # c(aracters in lengt(

    • =o continue a statement to next line, type a non blan c(aracter in column !2 andcontinue t(e next line $rom column 16

    • Comment lines start 0it( c(aracter 8;A;9 on column 1

     NAME FIELD OPERAION FIELD OPERAND FIELD REMAR!S " SE#UEN$E

  • 8/18/2019 IBM Assembler mannual.doc

    6/118

    IBM 370 ASSEMBLY LANGUAGE 6 / 118

    INS6RUC6IONS #!c5TYPES OF !ST"#$TO!S 

    • mac(ine instructions

     )ssembler instructions 8directi*es9• -acro instructionsE8!"2le 9

    I>= >:>=S=1 CSC= )ssembler irecti*e

    S=- 14,12,128139 -ac(ine instructionB)% 12,' -ac(ine instructionSI>: A,12 )ssembler irecti*eS= 13,S)4 -ac(ine instruction%) 13,S) -ac(ine instruction-C )=)1,)=)2 -ac(ine Instruction

    =-S: 7= ;message; -acro instruction% 13,S)4 -ac(ine instruction%- 14,12,128139 -ac(ine instruction

    S 15,15 -ac(ine instruction  B 14 -ac(ine Instruction)=)1 S C%1'' ata e$inition)=)2 S C%1'' ata e$initionS) S 1#" ata e$inition

    > )ssembler irecti*e

    INS6RUC6IONS :UNAMEN6ALS

    • =0o, $our, or six bytes in lengt(

    • S(ould begin on a (al$0ord boundary

    • "irst byte normally contains t(e operation code. In some instructions it is t0o bytes.

    • peration code speci$ies t(e $unction o$ t(e instruction

    • perand designation $ollo0s t(e operation codeO2er!n*s

    • ntities t(at are in*ol*ed in operations de$ined by operation code

    • perands can be eit(er implicit or explicit

    • "our types o$ operandsRegis+er $2er!n*

    E8!"2le  ) 3,2i""e*i!+e $2er!n*

    E8!"2le -I )=),D;"1;S+$r!ge $2er!n*

    E8!"2le % 3,"I%1I"2lie* $2er!n*'

    E8!"2le %- 14,12,S)

    REGIS6ER O(ERAN

    • Identi$ied by $ield in t(e instruction

    • Speci$ies eit(er : or "

    • perand access is $aster 

    • xample ) 1,2

    IMMEIA6E O(ERAN

    • Contained 0it( in t(e instruction itsel$ 

  • 8/18/2019 IBM Assembler mannual.doc

    7/118

    IBM 370 ASSEMBLY LANGUAGE 7 / 118

    • ig(t bit *alue

    • Sel$ de$ining term or an absolute symbol can be used

    • E8!"2le 9  -I )=),B;1''''''';

    S6ORAGE O(ERAN

    • esides in memory

    •  )ddress is not speci$ied explicitly• Base and 12 bit o$$set 0it( 8in some instructions9 index register is used

    • rogram can be relocated

    • I$ egister ' is used as a base or index register its contents are ignored

    • 12 bit displacement

    • B)% instruction is used to load base register 

    • I$ symbols are used assembler resol*es it to base displacement $orm

    • $$ecti*e address E 8base register9 8Index egister9 12 bit displacement  8note t(at some instruction $ormats do not support index register9• base register s(ould be made to contain t(e base address at run time

    • SiFe o$ storage operand is implied by t(e instruction $or some instructions

    • "or some instructions %engt( $ield8s9 is?are embedded in t(e instruction

    • Storage operands can be speci$ied in implicit $orm as a relocatable expressionE8!"2le % 3,)=)

    % 3,)=)4• Storage operands can be speci$ied in t(e xplicit $orm

    E8!"2le % 3,481,29xplicit addresses are o$ t(e $orm 28D2,B29or 28B29or 28%2,B29or 18%1,B19or 18B19

    •  )bsolute addresses are also assembled in base displacement $orm.  o0e*er t(e *alue in t(e base register 0ill not c(ange on relocation• Implicit addresses are t(ose 0(ere a single relocatable or absolute expression is speci$ied

    E8!"2le % 4,)=)% 3,)=)4%) 2,1'''

    ..

    )=) S "

    IM(LIE O(ERAN =(e instruction implies t(e operand

    E8!"2le == 18%,B19,28B29egisters ',1 participate in t(is operation

     

  • 8/18/2019 IBM Assembler mannual.doc

    8/118

    IBM 370 ASSEMBLY LANGUAGE 8 / 118

    INSTRUCTIONS CLASSIFICATION

    RR FORMAT

     0 8 12 15

    RRE FORMAT

     

    0 16 24 28 31

    RX FORMAT

      0 8 12 16 20 31

    RS FORMAT

    0 8 12 16 20 31

    SI FORMAT

    0 8 16 20 31

    S FORMAT

     

    0 16 20 31

    SS FORMATS

      0 8 12 16 20 32 36 47

    0 8 16 20 32 36 47

    E;AM(LES 9

    RR type instruction ) 2,3 reg 2 GEE reg 2 reg 3RS type instruction

    BD 1,3,28B29 reg 1 GEE reg 1 reg 3I$ reg1Hreg3 t(en branc(

    R; type instruction% 1,28D2,B29 reg 1 G EE memory re$erenced by 82 D2 B29

    S type instruction%S7 28B29

    SI type instruction

      FIRS %ALF &ORD SE$OND %ALF &ORD %IRD %ALF &ORD

    OP $ODE R1 R2

      OP $ODE R1 R2

      OP $ODE R1 '2 B2 D2

      OP $ODE R1 R3 B2 D2

      OP $ODE I 2 B1 DI

    OP $ODE B2 D2

      OP $ODE L1 L2/I3 B1 D1 B2 D2

      OP $ODE L B1 D1 B2 D2

  • 8/18/2019 IBM Assembler mannual.doc

    9/118

    IBM 370 ASSEMBLY LANGUAGE ( / 118

    >I 18B19,I2Storage type instruction

    -C 18%,B19,28B29)C< 18%1,B19,28%2,B29

  • 8/18/2019 IBM Assembler mannual.doc

    10/118

    IBM 370 ASSEMBLY LANGUAGE 10 / 118

    SYMBOLS' LI6ERALS' CONS6AN6S' A6A AREAS' LOCA6ION COUN6ER    back SYMBOLS

    •  ) seuence o$ one to eig(t c(aracters as speci$ied belo0 under I>)J,)I)B%,SK>C symbols

    •  )bsolute *alue assigned to a symbol by using ;K; assembler instruction 0it( an absolute*alue operand

    •  ) relocatable *alue is assigned to a symbol by using it in t(e name $ield o$ a mac(ineinstruction• Symbols can be used in operand $ields to represent registers, displacements, lengt(s,

    immediate data, addresses etc.E8!"2le 9%)B%''1 -C S1,S2

    B KI=KI= B 14S1 S C%1''S2 C C%1'';= KIC< B7> "D;C>= K 1'

    Ordinary Symbols

    • ptional

    • used in t(e name and operand $ield o$ mac(ine?assembler instructions

    • p to eig(t )lp(anumeric c(aracters )L,M,N,/,'&

    • "irst c(aracter must be alp(abetic )L

    • est can be alp(anumericE8!"2le  )BC'''1

    %ariable Symbols

    • "irst c(aracter must be an ampersand

    • second c(aracter must be alp(abetic

    • p to six alp(anumeric c(aractersE8!"2le /)BC'''1

    Se&uence Symbols

    • "irst C(aracter must be a period

    • >ext C(aracter must be alp(abetic

    • p to six alp(anumeric c(aractersE8!"2le .)BC'''1

    A*!n+!ges $f s/"#$ls

    • asier to remember and use

    • -eaning$ul symbol names instead o$ *alues

    • "or address t(e assembler calculates t(e displacement

    • C(ange t(e *alue at one place 8t(roug( an K9 instead o$ se*eral instructions

    rinted in t(e crossre$erence table by t(e assembler

    S/"#$l Leng+h !++ri#)+e= S C%#' %;= E #'"- S C%24' %;"- E 24'

     )C> C )8=9 %;)C> E 4C) C C;J; %;C) E 5% C 3";2''; %;% E 4

  • 8/18/2019 IBM Assembler mannual.doc

    11/118

    IBM 370 ASSEMBLY LANGUAGE 11 / 118

    Self efining +er"s

    • Can be used to designate registers, mass, and displacements 0it(in t(e operand entry eci"!l self*efining +er" •  )n unsigned decimal integer 

    • maximum number o$ digits 1'• -aximum *alue 2AA311

    He8!*eci"!l self*efining

    •  ) exadecimal integer 0it(in apostrop(es and preceded by a D

    • -aximum number o$ digits #

    • -aximum *alue 2AA311 Ch!r!c+er self*efining +er"

    •  ) c(aracter string 0it(in apostrop(es and preceded by a C

    • -aximum number o$ c(aracters 256

    E;AM(LES915 = 2,14!,4#3,64!241B;11'1; = 32 BI=SD;"; = # D I:I=SD;"1"2;C;)BC; = 4 C))C=SC;//; =7 )-S)>S = S>= >C;;;;;; =7 )S=S = S>= >

    Literals% 1,E";2'';% 2,E)8SB=>9

    -C -SS):8169,EC;=IS IS )> ;% 3,E";33; B= ) S)-% 3,"I% B= ) S)-

    "I% C ";33;-C "%):,ED;''; S)- ""C=-I "%):,D;''; S)- ""C=-I "%):,L S)- ""C=..

    L K D;'';"%): S C

    %) 4,%C S)- ""C=%) 4,1''' S)- ""C=.

    %C K 1'''

     Absolute e'(ressions )n expression is absolute i$ it;s *alue is unc(anged by program relocation"IS= CSC=

     ) C ";2;B C ";3;C C ";4;

     )BS) K 1'' )BSB K D;""; )BSC K B)

  • 8/18/2019 IBM Assembler mannual.doc

    12/118

    IBM 370 ASSEMBLY LANGUAGE 12 / 118

     )BS K A) )ll t(ese are absolute expressionsO

     )BS)15%;)

     )BS))BSC)BSCA15B)

     )BS)15BC)BS?8C))BS)9

    "elocatable e'(ressions ) relocatable expression is one 0(ose *alue c(anges 0it( program relocation.

    "IS= CSC= ) C ;2;B C ;3;C C ;4;

     )BS) K 1' )BSB K A) )BSC K 1'A8B)9

    =(e $ollo0ing are relocatable expressionsO

     ) ))BS)1'B)C1'A)BS)

    Location $ounter 

    • %ocation counter is incremented a$ter instruction or constant is assembled  to t(e next a*ailable location•  )ssembler c(ecs boundary alignment and ad@usts location counter i$ red.

    • 7(ile assembling t(e current line t(e location counter *alue does not c(ange

    %ocation counter Source Statements'''''4 > C C%3;SB;'''''! B" K A

    '''''# I>: C ";2'';'''''C )"= K A''''1' >D= S ''''1# )"=>D= K A''''1# >D=1 S ''''2' >D=2 S ''''2# : A#''''3' >D=3 S

    E8!"2le 9% K A

    B A#'..

    .B %

  • 8/18/2019 IBM Assembler mannual.doc

    13/118

    IBM 370 ASSEMBLY LANGUAGE 13 / 118

     ATT")#TES OF SY*)OLS OLeng+h !++ri#)+e

    • e$erred to as %;symbol

    • "or a symbol de$ined by PC; or ;S;, it is t(e implicit or explicit lengt(.

    • "or a symbol re$erring to a mac(ine instruction, it is t(e lengt( o$ t(e instruction.

    • "or a ;K; symbol, it is t(e lengt( o$ t(e le$t most term or supplied by t(e second operand

    E8!"2le 9  leng+h ) S " 4  S 2'"%4 4  S D%3 3

     ) 1,2 2 )) K )4 4S1 K 1'2 1S2 K D;"" ); 1S3 K C;J

  • 8/18/2019 IBM Assembler mannual.doc

    14/118

    IBM 370 ASSEMBLY LANGUAGE 14 / 118

    ;

      C 3;2,4,#,16; 12 (al$ 0ords 0it( t(e gi*en *alue  C B;1'''1'''; 1

      C C;S)-% S=I>:; 13  C ;123; 2

      C L%1';123; 1'  C %4;123; 4  C ;1.25; 4  C ;2.5!65; #  C )%38=9 3  C 8D=SJ-9 4

    E:INE S6ORAGE >S9• =o reser*e storage

    • Storage is not initialised

    • %ocation counter ad*anced by bytes allocated

      DS

    SYN6A;

  • 8/18/2019 IBM Assembler mannual.doc

    15/118

    IBM 370 ASSEMBLY LANGUAGE 15 / 118

    S 4 32S '" ' used to $orce a 0ord BoundaryS ' ' used to $orce a double 0ord boundaryS 'C%# ' lengt( attribute is #S 1'' 2''

     ) self *efining +er" is an absolute constant t(at can be 0ritten as a•  ) binary integer B;1''1;

    •  ) decimal integer 3

    •  ) (exadecimal integer D;4);

    •  ) seuence o$ text c(aracters C;)BC;

    • =(ese can be used as immediate operands in any instruction 0(ic( needs animmediate operand.

      E8!"2le C%I '8#9,C;L;

     ) li+er!l is a symbolic representation o$ a constant to 0(ic( t(e assembler assigns an address

    "C> C ";1;

    % 5,"C>% 5,E";1;%) % 2,E";4;- -C -S:,ECAAArror AAA;

     =(e $irst t0o statements are exactly eui*alent to t(e t(ird.•  ) con*enient means o$ introducing constants 0it(out t(e use o$ ;C; instruction

    • Storage is allocated $or literals at t(e end o$ t(e $irst CSC= 8%iteral ool9. =o a*oidaddressing problems, use a %=: at end o$ eac( CSC=

    • Storage allocation can be $orced at any point by ;%=:P assembler instruction

    • =0o literals are t(e same i$ t(eir speci$ications are identical

    •  )ssembler translates a literal into a base register and a displacement

     ) e?)i!lence constant allo0s a programmer to de$ine a *alue $or a symbol and use it0(ere*er t(ere is a need to employ t(at *alue.

    1 K 1 K A"" K D;'';> K D;"";J C ";4;L K 47 K J 7 is eui*alent to J

    C%I S=)=S,>B 7>C%I S=)=S,""B 7""

    !+! Align"en+• Instructions (a*e to be aligned on (al$0ord boundary

    • ata can be speci$ied to be aligned to  ouble 0ord 8i*isible by #9  "ull0ord " 8i*isible by 49  al$0ord 8i*isible by 29• %ocation counter sipped as per alignment reuirement

    E8!"2le 9'''1'' C C;)BC;

  • 8/18/2019 IBM Assembler mannual.doc

    16/118

    IBM 370 ASSEMBLY LANGUAGE 16 / 118

    '''1'3 sipped'''1'4 C ";4;'''1'# C C;);'''1'& sipped'''11' sipped'''111 sipped'''112 C ";56';

    I" ASSEMBLER O(6ION ALIGN IS SCI"I•  )ssembler c(ecs storage addresses 8labels9 to ensure t(at t(ey are aligned on boundaries

    reuired by t(e instruction.• ata areas are aligned on boundaries implicit 0it( t(eir type i$ no lengt( modi$ier is

    present%C=> C>= :)-''''1' )=) C C;)BC;''''14 S " )SS-. )= 7 BJ

    I" NOALIGN IS SCI"I• Constants and data areas are not automatically aligned

    •  )ssembler does not c(ec storage addresses $or boundary alignment.%C=> C>= :)-''''1' )=) C C;)BC;''''13 S " )SS-. )= >D= %C

    E8!"2leFIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    WTO 'ASM1 REPORTING'

    L 3,=F'200'LA 3,ABSB

    MVC ATA1(!),=C'ABCEF'

    MVC ATA1,=CL20'ABCEF'

    L 13,SAVE+4

      LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    C A(SAVE1)

    A C $'2'

    B C $'3'

    C C $'4'

    ABSA E%U 10

    ABSB E%U *&A

    C F'100'

    C F'&100'

    C $'100'

    C 3$'100'

    C C'ABCEFG$'

    C CL20'ABCEFG$'

  • 8/18/2019 IBM Assembler mannual.doc

    17/118

    IBM 370 ASSEMBLY LANGUAGE 17 / 118

      C 10C'AB'

    C P'123'

    C P'&123'

    C PL"'&123'

    C 3PL"'&123'

    ATA1 S CL20

    EN

  • 8/18/2019 IBM Assembler mannual.doc

    18/118

    IBM 370 ASSEMBLY LANGUAGE 18 / 118

    IN6EGER O(ERA6IONS  back 

    :I;E (OIN6 ARI6HME6IC ) ),),),)%,)%SB=)C= S,S,S,S%,S%-%=I%J -,-,-II ,

     )I=-=IC C-) C,C,C%) %,%,%,%=,%C,%S= S=,S=,S=-

     )I=-=IC SI"= S%),S),S%),S)C>= = BI>)J CBC>= = CI-)% C

    $onstants used Ty(e"ixed oint and "Binary Bexadecimal DC(aracter C

    ecimal  )ddress J,),S,,K

  • 8/18/2019 IBM Assembler mannual.doc

    19/118

    IBM 370 ASSEMBLY LANGUAGE 1( / 118

    IN6EGER ARI6HME6IC

    • :;s are 32 bits 0it( bit ' as a sign bit

    • >egati*e numbers stored as t0o;s complement

    • Bot( "ull 0ord and al$ 7ord instructions are supported

    • :?: and :?-emory instructions a*ailable• al$ 0ords con*erted to $ull 0ord by extending sign bit to t(e le$t

    =0o;s Complementecimal Binary ecimal Binary' '''' ' ''''1 '''1 1 11112 ''1' 2 111'3 ''11 3 11'14 '1'' 4 11''5 '1'1 5 1'116 '11' 6 1'1'! '111 ! 1''1

     )ddition and Subtraction

    6 '11' 6 1'1' 5 '1'1 5 1'11819 '''1 819 1111 869 '11' 869 1'1'

    '111 1''1 1'11 '1''

      '' 11 '1 1'>o o*er$lo0 >o o*er$lo0 *er$lo0 *er$lo0

    I$ t(e carry into t(e sign bit is di$$erent $rom t(e carry out o$ it, t(ere is an o*er$lo0 condition.

    L Copy $ull 0ord $rom memory to : D 1,28D2,B29% 3,) :3 -emory "ield )

    Be$ore '246 '35! ''') ''B'

     )$ter ''') ''B' ''') ''B'

    ST  Copy a $ull 0ord $rom : to memory D 1,28D2,B29S= 3,) :3 -emory $ield )

    Be$ore '123 '456 ')BC '"'123 '456 '123 '456

    L+  Copies a (al$ 0ord $rom memory to : D 1,28D2,B29% 3,) :3 -emory "ield )

    Be$ore '15& '26' 4321 )$ter '''' 4321 4321

    ST+  Copy a (al$ 0ord $rom : to memory D 1,28D2,B29S= 3,) :3 -emory $ield )

    Be$ore '123 '456 '"'123 '456 '456

  • 8/18/2019 IBM Assembler mannual.doc

    20/118

    IBM 370 ASSEMBLY LANGUAGE 20 / 118

    L*  Copies 1 to 16 "ull 0ords $rom memory S 1,3,28B29to consecuti*e :,s%- 2,4,) :;S -emory )ddress

    Be$ore 2O''''1234 )'O'''1)BC3O''''3456 )4O'''2BC4O''''56!# )#O'''3C"

     )$ter 2O'''1)BC )'O'''1)BC3O'''2BC )4O'''2BC4O'''3C" )#O'''3C"

    ST*  Copies 1 to 16 "ull 0ords to memory S 1,3,28B29"rom consecuti*e :,sS=- 2,4,) :;S -emory )ddress

    Be$ore 2O''''1234 )'O'''1)BC3O''''3456 )4O'''2BC4O''''56!# )#O'''3C"

     )$ter 2O''''1234 )'O''''12343O''''3456 )4O''''34564O''''56!# )#O''''56!#

    L"  Copies one : to anot(er 1,2% 3,4 :3 :4Be$ore )BC "'' 1234 56!#

     )$ter 1234 56!# 1234 56!#

    AI6ION A  )dds a memory $ield to : D 1,28D2,B29

    xample 641'E!4. ) 3,E";1'; :3 -emory

    Be$ore '''' ''4' '''' ''') )$ter '''' ''4) '''' ''')

    S  Subtracts a memory $ield $rom : D 1,28D2,B29xample 641'E54S 3,E";1'; :3 -emory

    Be$ore '''' ''4' '''' ''') )$ter '''' ''36 '''' ''')

     A"   )dds a : to anot(er : 1,2xample 4'&6819E4'&5

     ) 6,5 :6 :5Be$ore '''' 1''' """" """"

     )$ter '''' '""" """" """"

    S"  Subtracts a : $rom anot(er : 1,2xample 4'&6819E4'&!

    S 6,5 :6 :5Be$ore '''' 1''' """" """" )$ter '''' 1''1 """" """"

     A+   )dds a (al$ 0ord memory $ield to a : D 1,28D2,B29xample #'#E##

     ) 1',E;#; :1' -emoryBe$ore '''' ''5' '''#

     )$ter '''' ''5# '''#

  • 8/18/2019 IBM Assembler mannual.doc

    21/118

    IBM 370 ASSEMBLY LANGUAGE 21 / 118

    xample #'8#9E!2 ) 1',E;#; :1' -emory

    Be$ore '''' ''5' """# )$ter '''' ''4# """#

    S+  Subtracts a (al$ 0ord memory $ield $romD 1,28D2,B29 a :xample ##'E!2S 1',E;#'; :1' -emory

    Be$ore '''' '''# ''5' )$ter """" ""B# ''5'

     AL  )dd %ogical D 1,28D2,B29

     AL"   )dds a : logically to anot(er : 1,2

    • ange o$ result in t(e : is $rom 2AA31 to 2AA311

    • I$ an o*er$lo0 occurs 8carry into sign bit and carry out are di$$erent9 (ard0are interrupts not suppressed t(roug( a program mas

    "or logical additions t(e operands are assumed to be unsigned• Condition code is set 8Fero, negati*e, positi*e or o*er$lo09  

    MUL6I(LICA6ION  Rconsecuti*e :;SR

    Re*en numbered :Rodd numbered :R  

    Be$ore multiplication

       )$ter multiplication

    *  -ultiply D 1,28D2,B29E8!"2le  2 D 3 E 6% !,E";2;

    - 6,E";3;:6 :! -emory

    Be$ore any number '''' '''2 '''3 )$ter '''' '''' '''' '''6 '''3

    *"  -ultiply one : 0it( anot(er D 1,28D2,B29E8!"2le 65536 D 65536% 4,E";65536;- 6,4

    :6 :! :4Be$ore '''' '''' '''1 '''' '''1 ''''

     )$ter '''' '''1 '''' '''' '''1 ''''

    *+  -ultiply a : 0it( a (al$ 0ord D 1,28D2,B29$rom a memory $ield

    xample 2 D 5 E 1'% !,E";2;- !,E";5;

    :! -emoryBe$ore '''' '''2 '''5

     )$ter '''' ''') '''5

    A)* )+,b-. 1

      64 b .+c 1 ' 2

  • 8/18/2019 IBM Assembler mannual.doc

    22/118

  • 8/18/2019 IBM Assembler mannual.doc

    23/118

    IBM 370 ASSEMBLY LANGUAGE 23 / 118

    E8!"2le% 5,4 :5 :4

    Be$ore '''''')B """"""") )$ter '''''''6 """"""")

    % 4,5 :4 :5Be$ore """"""") '''''')B

     )$ter ''''''')B '''''')B

    % #,! :# :!Be$ore 123456!# #'''''''

     )$ter #''''''' #'''''''AAAo*$l0

    L!"  %oad negati*e register 1,2E8!"2le

    %> 4,5 :4 :5Be$ore """"""") '''''')B

     )$ter """"""55 '''''')B

    % 4,5 :4 :5Be$ore ''''''11 """"""55 )$ter '''''')B """"""55

    Condition code is set8 Fero, positi*e , negati*e, o*er$lo09

  • 8/18/2019 IBM Assembler mannual.doc

    24/118

    IBM 370 ASSEMBLY LANGUAGE 24 / 118

    ECIMAL O(ERA6IONS  back 

     ) )SB=)C= S-%=I%J -II CI-)% C-) C- CI-)% )=)

    7I= 4 BI= ""S= -SI"= CI-)% )=) SS= = L )> ) L)C>= L> =)C= )C ><

    Constants used =ypeecimal Loned L

    BC epresentation 8aced ecimal9

    ''11 ''1' '1'1 11'' 325 D325C'111 1''' 1''1 11'1 !#& D!#&

     ))1 S %5 ))2 C 123456!#

    • nly permissible 8and mandatory9 modi$ier is t(e lengt( modi$ier example %n

    • adding is al0ays at t(e le$t 0it( Leroes

    • =runcation is $rom t(e le$t and c(oice o$ lengt( modi$ier is crucial

    • CS are )rit(metic, Comparison, Copying $rom storage to storage, Con*ersion toand $rom aced decimal $ormat.

    • -ost instructions are SS1 18%,B19,28B29 8lengt( G 2569  SS2 18%1,B19,28%2,B29 8lengt( G 169

    ,AP  Lero and add paced SS2E8!"2le

    L) )839,B849 ) BBe$ore ont Care ''23456C

     )$ter 23456C ''23456C

     AP   )dd paced SS2E8!"2le

     ) )829,B839 ) BBe$ore '&&C ''''1C

     )$ter 1''C ''''1C

    Be$ore &&&C ''''1C )$ter '''C ''''1C

    8o*$l cond9SP  Subtract paced SS2

    S )829,B839 ) BBe$ore '&& ''''1C

     )$ter 1'' ''''1C

  • 8/18/2019 IBM Assembler mannual.doc

    25/118

  • 8/18/2019 IBM Assembler mannual.doc

    26/118

    IBM 370 ASSEMBLY LANGUAGE 26 / 118

    • ecimal o*er$lo0 occurs 0(en result is too long to $it into $irst operand and a signi$icant digit0ould be lost

    • ata exception occurs 0(ene*er 

    ⇒ Sign $ields are in*alid

    ⇒ perands o*erlap

    ⇒ =(e $irst operand o$ a - instruction does not (a*e su$$icient Feroes.

    COM(ARISONS$P  Compare paced SS2 18%1,B19,28%2,B29

    B 1E2B 1H2B% 1G2

    S"P  S(i$t and ound aced 18%1,B19,28B29,I3 SS1

    =(e $irst operand represents an address=(e second operands lo0 order 6 bits is t(e number o$ positions to be s(i$ted and direction o$ s(i$t. ositi*e represents le$t s(i$t and *acated positions on t(e le$t are $illed 0it( Feroes.

    >egati*e represents a rig(t s(i$t and Feroes are inserted on t(e le$t. =(e sign is not disturbed inany case. =(e t(ird operand is t(e rounding to be applied in case o$ rig(t s(i$t and is animmediate operand.

    % #,ED"""""""S )859,'8#9,5 be$ore '31415&26C

    a$ter ''''31416C

    CON%ERSION BE6@EEN EBCIC' BINARY AN (AC4E ECIMAL :ORMA6

    $%D con*erts binary to paced decimal32 bit binary to a # byte paced decimal $ield

    E8!"2leC 5,) :5 )

    Be$ore !" "" "" "" any number 

    a$ter !" "" "" "" '' '' '2 14 !4 #3 64 !C

    C 5,) :5 )Be$ore #' '' '' '' dont care

    a$ter #' '' '' '' '' '' '2 14 !4 #3 64 #

    $%) con*erts paced decimal to binary# byte paced decimal $ield to a 32 bit binary $ield

    E8!"2leCB 5,) :5 )

    Be$ore dont care '' '' '' '' '' '' '1 6Ca$ter '' '' '' 1' '' '' '' '' '' '' '1 6C

    CB 5,) :5 )Be$ore dont care '' '' '' '' '' '' '1 6a$ter "" "" "" "' '' '' '' '' '' '' '1 6

    PA$  con*erts BCIC to paced decimal 18%1,B19,28%2,B29perand one 0ill recei*e paced decimal $ieldperand t0o is t(e BCIC $ield in Foned decimal $ormat

    E8!"2le)C< )849,B849 ) B

    Be$ore any "1 "2 "3 C4

  • 8/18/2019 IBM Assembler mannual.doc

    27/118

    IBM 370 ASSEMBLY LANGUAGE 27 / 118

    a$ter '' '1 23 4C "1 "2 "3 C4

    #!P  con*erts paced decimal to BCIC 18%1,B19,28%2,B29perand t0o is t(e paced decimal $ieldperand one 0ill recei*e t(e BCIC $ield

    E8!"2le>< )8#9,B849 ) B

    Be$ore any 12 34 56 ! )$ter "' "1 "2 "3 "4 "5 "6 ! 12 34 56 !

    ED Con*erting a paced decimal number to BCIC 0it( edit ing 18%,B19,28B29 1 is pattern, 2 is

    paced $ld 8159,J Be$ore J ' ' 1 2 3 4 5 6 !

      Be$ore 4' 2' 6B 2' 2' 2' 6B 2' 21 2' 4B 2' 2' 6' 4'  )$ter 4' 4' 4' 4' "1 "2 6B "3 "4 "5 4B "6 "! 6' 4'

    1st byte o$ pattern is t(e $ill c(aracter, in t(is case a blanex 2' is a digit selector ex 21 is a signi$icance starter 

    ex 6B is a T,ex 4B is a T.

    *ery byte o$ paced decimal needs t0o bytes o$ BCIC code

    '' 12 3C   "' "' "1 "2 C3

    E8!"2le $f (!c5e* eci"!l ii*eFIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVEP A,B

    UNP %UOT,A(L'A&L'B)

    UNP REM,A+L'A&L'B(L'B)

    OI %UOT+3,'F0'

    OI REM+3,'F0'

    LA 3,MSG

    WTO TET=(3)

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",0

    BR 14

    SAVE S 1#FMSG C AL2(LEN)

    C C'%UOT='

    %UOT S CL4

    C C','

    C C'REM='

    REM S CL4

    LEN E%U *&MSG&2

    A C PL4'+0000'

  • 8/18/2019 IBM Assembler mannual.doc

    28/118

    IBM 370 ASSEMBLY LANGUAGE 28 / 118

    B C PL2'&#'

    EN

    E8!"2le $f *is2l!/ing ! In+eger FIRST CSECT

    STM 14,12,12(13)

    BALR 12,0USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    LA 4,234"

    CV 4,W

    UNP MSG+2(1!),W

    OI MSG+1,'F0'

    LA 3,MSG

    WTO TET=(3)

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",4

    BR 14

    SAVE S 1#F

    MSG C AL2(1!)

    S CL1!

    W S

    EN

  • 8/18/2019 IBM Assembler mannual.doc

    29/118

    IBM 370 ASSEMBLY LANGUAGE 2( / 118

    :LOA6ING (OIN6 O(ERA6IONS  back 

     ) ),),),),)7,)7,),),)DSB=)C= S,S,S,S,S7,S7,S,S,SD-%=I%J -,-,-,-,-D,-D,-DII ,,,

     )I=-=IC C-) C,C,C,C%) I>= " %,%,%,%=,%=,%C,%C,%,%

    %>,%,%,%S= I>= ))S S=,S=

    Constants used =ype"loating point ,,%:l$!+ing2$in+ N)"#er re2resen+!+i$n

    • Consists o$ a signed (exadecimal $raction and an unsigned se*enbit binary integer ,calledas c(aracteristic

    • C(aracteristic represents signed exponent in excess64 notation

    •  ) normalised $loating point number (as a nonFero le$tmost (exadecimal $raction digit.

    • I$ one or more le$tmost $raction digits are Feros, t(e number is said to be unnormalised.

    •  ) normalised number represents a uantity 0it( t(e greatest precision.

    • nnormalised numbers are normalised by s(i$ting t(e $raction le$t, one digit at a time, untilt(e le$tmost (exadecimal digit is nonFero and reducing t(e c(aracteristic by t(e number o$ (exadecimal digits s(i$ted.

    •  )ddition and subtraction 0it( extended operands, as 0ell as t(e multiply, di*ide, and (al*eoperations, are per$ormed only 0it( normalisation. )ddition and subtraction 0it( s(ort or longoperands may be speci$ied as eit(er normalised or not normalised.

    :l$!+ing($in+ !+! f$r"!+Sh$r+ fl$!+ing2$in+ n)"#er 

    • epresented by 32 bits

    • Bit ' is sign bit

    • Bits 1! are c(aracteristic

    • Bits #31 are digit $raction• Can reside in t(e storage or in t(e $loating point registers

    L$ng fl$!+ing2$in+ n)"#er 

    • epresented by 64 bits

    • Bit ' is sign bit

    • Bits 1! are c(aracteristic

    • Bits #63 are digit $raction

    • Can reside in t(e storage or in t(e $loating point registers

    e8+en*e* fl$!+ing 2$in+ n)"#er 

    • epresented by 12# bits

    • Bit ' o$ (ig(order 64 bits is t(e sign bit

    • Bits 1! o$ (ig(order 64 bits contains are c(aracteristic

    • Bits #63 o$ (ig(order 64 bits and bits !212! o$ lo0 order 64 bits contains t(e 2# dig  $raction• Can only reside in t(e $loating point registers

    :l$!+ing ($in+ ins+r)c+i$ns

    • "loating point registers ',2,4,6 are used in t(e instructions

    • nly le$t (al$ o$ " is used i$ s(ort $loating point number is speci$ied

  • 8/18/2019 IBM Assembler mannual.doc

    30/118

    IBM 370 ASSEMBLY LANGUAGE 30 / 118

    • " ' / 2,4 / 6 can be used to contain extended $loating point

    • Instructions are a*ailable $or data loading, arit(metic and comparison number 

  • 8/18/2019 IBM Assembler mannual.doc

    31/118

  • 8/18/2019 IBM Assembler mannual.doc

    32/118

    IBM 370 ASSEMBLY LANGUAGE 32 / 118

    $L Compare logical D Compares a 4 byte string in memory tocontents o$ a :

    1,28D2,B29

    $L"  Compare %ogical egister Compares 4 bytes $rom t0o :S1,2

    $L*  Compare %ogical under mas S Compares 1 to 4 bytes 8determined bymas9 $rom a : to a memory $ield

    1,-,28B29

    $L  Compare %ogical Immediate SI Compares an 1 byte immediate operandto a byte in memory

    18B19,I2

    $L$  Compare %ogical C(aracters SS Compares 1 to 256 bytes $rom onememory $ield to anot(er 

    18%,B19,28B29

    $L$L Compare %ogical C(aracters long Compares 1 to 2AA24 c(aracters $romone memory $ield to anot(er.

    BRANCHING

    CC 0 CC 1 CC , CC3C%,C%C,C%C%,C%I,C%-,C% 1E2 1G2 1H2 >).

    O2c$*e Me!ningB 1E2B> 1UE2B% 1G2B>% 1EH2B 1H2B> 1GE2

    N$+es9estructi*e o*erlap occurs 0(en a to $ield starts $rom 0it(in a $rom $ield

    o0 to modi$y lengt( $ield at run timeD 1,28D2,B29.

    =(e instruction at t(e memory address speci$ied is executed a$ter ing bits #158lengt( $ield90it( bits 2431 o$ 1 I$ t(e target instruction is a branc( t(en t(e branc( is made. I$ it is a B)% ?B)% t(en t(e return $rom t(e branc( is made to t(e instruction $ollo0ing t(e D instruction.

    % 4,E2'

    S 4,E1D 4,-RR

    - -C =8'9,"-RR

    "- S 1'"= S 1'"

  • 8/18/2019 IBM Assembler mannual.doc

    33/118

    IBM 370 ASSEMBLY LANGUAGE 33 / 118

    $L$L and *%$L instructions

    C%C% 1,2 -C% 1,2

    1 bits # to 31 is t(e = address11 bits # to 31 is t(e lengt( o$ = $ield2 bits # to 31 is t(e "- address21 bits # to 31 is t(e lengt( o$ "- $ieldbits ' to ! is t(e padding c(aracter to be used to lengt(en t(e s(orter string

    %) 2,S% 3,E%S%) 4,=% 5,E%=IC- 5,D#,ED''C%C% 2,4RRR

    S S C%1'''

    = S C%2'''

    T" and T"T  instructions

    T" =ranslate SS instructions can be used to replace certain bytes o$ t(estring 0it( ot(er bytes 18%,B19,28B29

    T"T =ranslate / test SS instruction can be used to $ind one o$ a set o$ c(aractersin a string 18%,B19,28B29

    >otesO perand 1 is t(e argument string operated on by = and searc(ed by ==instruction perand 2 is t(e "unction string set up by t(e programmer and is 256 byteslong

    ">1 S C%256: ">1CC D"":

     ):1 S C%256R== ):182569,">1BC #,>>BC 4,-BC 2,>

    >otesO o0 t(e instruction 0ors is as $ollo0s. ead a byte $rom argument string. se it as ano$$set into t(e $unction string. In t(e = instruction replace t(e argument byte 0it( t(e $unction

    byte. In t(e == instruction , i$ t(e $unction byte is non Fero, a copy o$ t(at byte is inserted in bits24 to 31 o$ :2 and t(e address o$ t(e byte is set into bits # to 31 o$ :1. xecutionterminates and a CC is set to 1 i$ more bytes remain to be scanned in t(e argument string. ) CCo$ 2 is set i$ t(ere 0as a non Fero byte in t(e $unction string and t(ere 0ere no more bytes to bescanned as 0ell. lse CC ' is set

  • 8/18/2019 IBM Assembler mannual.doc

    34/118

    IBM 370 ASSEMBLY LANGUAGE 34 / 118

    BI6 MANI(ULA6IONS  back 

    S"A S(i$t ig(t Single )rit(metic SSLA S(i$t %e$t Single )rit(metic SS"DA S(i$t ig(t ouble )rit(metic S 8$ irst operand is e*en odd : pair9SLDA S(i$t %e$t ouble )rit(metic S

    • 7(en s(i$ting le$t Feroes are inserted on t(e rig(t and o*er$lo0 is set i$ a bit *alue ot(er t(ant(e sign bit is lost $rom t(e s(i$t.

    •  7(en rig(t s(i$ting t(e lo0 order bits are lost and t(e sign bit is propagated

    • I$ o*er$lo0 occurs it can be c(eced by B 8branc( on *er$lo09

    • I$ o*er$lo0 is not set condition code ',1, or 2 is set

    S"L S(i$t ig(t Single %ogical SSLL S(i$t %e$t Single %ogical SS"DL S(i$t ig(t ouble %ogical S 8$irst operand is e*en odd : pair9SLDL S(i$t %e$t ouble %ogical S

    • 7(en rig(t s(i$ting t(e lo0 order bits are lost and t(e Feroes are inserted on t(e rig(t

    7(en s(i$ting le$t Feroes are inserted on t(e rig(t and t(e (ig( order bits are lost.• =(e condition code is ne*er set

    O  r D!   )nd D

     .  xclusi*e r DO"  r :S !"   )nd :S

     ."  D :S O  r Immediate SI!   )nd Immediate SI

     .  xclusi*e r ImmediateSIO$  r -emory $ields SS!$   )nd -emory "ields SS

     .$  xclusi*e r -em "lds SS

    6ES6ING BI6S=- =est nder -as SI 18B19,I2

    I2 is one byte.Bits corresponding to ;'; bit8s9 in t(e mas byte are not tested.

     )ssociated Branc( Instructions

    ),  Branc( i$ Leroes )ll tested bits are ;'; or all mas bits are ;';)O  Branc( i$ nes )ll tested bits are ;1;)*  Branc( i$ mixed =ested bits are a mix o$ ;'; and ;1;

  • 8/18/2019 IBM Assembler mannual.doc

    35/118

    IBM 370 ASSEMBLY LANGUAGE 35 / 118

    BRANCHING INS6RUC6IONS  back B)>C > C>I=I>C BC,BCB)>C )> %I>< B)%,B)%B)>C > C>= BC=,BC=B)>C > I>DC-) BD,BD%=-)J B)>C D

    )$  Branc( on Condition D -1,28D2,B29)E/)E"/)!E/)!E"/)L/)L"/)!L/)!L")+/)+"/)!+/)!+"/),/),"/)!,/)!," )*/)*"/)!*/)!*"/)P/)P"/)!P/)!P" )O/)O"/)!O/)!O"/!OP/!OP"/)/)"  All i"2le"en+e* )sing BC ins+r)c+i$n

    BRANCHING AN LOO(S)$T  Branc( on count D 1,28D2,B29

    • Subtract 1 $rom 1 and test $or non Fero.

    • Branc( i$ non Fero

    ).+  Branc( on Index ig( S 1,2,38B39• Increments or decrements Index

    • Counting iterations

    • =est to determine 0(et(er loop s(ould be repeated

    • BD is normally used 0it( decrementing

    • BD% is used 0it( incrementing

    • 1 is t(e Index register 

    • 2 contains t(e increment ? 21 contains t(e limit

    • S3 is t(e branc( address

    % !,%I-I=% 6,I>C% 5,E";';

    % % 3,D859 ) 3,J859 ) 3,L859BD% 5,6,%.

    D S 2'"J S 2'"L S 2'"%I-I= K JDI>C K 4

    ASSEMBLER IREC6I%ES  back 

  • 8/18/2019 IBM Assembler mannual.doc

    36/118

    IBM 370 ASSEMBLY LANGUAGE 36 / 118

    CSEC6

    • Indicates t(e beginning o$ a control section

    • Smallest portion o$ t(e code 0(ic( can be relocated

    •  ) program can (a*e more t(an one CSC=

    • CSC=S can be continued across CSC=S or SC=S

    • Separate location counter $or eac( CSC=

    • Symbols are not addressable across CSC= s

    RSEC6

    • e$ines a read only CSC= and maes t(e )ssembler c(ec $or possible*iolations. =(e assembler c(ec is not $ool proo$.

     SEC6

    • ummy Control Sections

    • =o describe t(e structure o$ a bloc o$ data in memory 0it(out actually allocating mem

    •  )cts as a template 8$or example 0it( storage obtained dynamically at run time9

    • >o code is generated

    • C statement is not allo0ed in a SC=

    E8!"2le9CS=- SC="I%1 S C%3"I%2 S C%1'"I%3 S C%1'"I%4 S C%1'"I%5 S "CI=J S %5

    USING

    • SI>: GsymbolH, n

    • Symbol can be any relocatable symbol de$ined in t(e program

    • A can be used in t(e place o$ symbol

    • "ields in t(e SC=s are accessed a$ter

    ⇒ stablis(ing a base register 0it( SI>: instruction at )ssembly time⇒ Initialising t(e Base egister 0it( t(e address o$ t(e storage area at run time.

    • n, base register, to be used by t(e assembler $or resol*ing t(e symbols in t(e basedisplacement "-

    • =(e location counter o$ t(e symbol is used as t(e base $rom 0(ic( displacements arecalculated

    • sers responsibility to load t(e base register 0it( base address

    • B)% instruction can be used to load t(e base address

    • ange o$ a base register is 4'&6 including t(e base

    • I$ t(e code siFe is more t(an 4'&6 bytes, multiples base registers (a*e to be usedE8!"2le 9B)% 12,' %oad t(e base addressSI>: A,12 eg 12 is a base register SI>: :,1' Base $or SC= :

    ORG

    • : GDH

    • I$ expr is speci$ied, location counter is set up 0it( expr *alue

    • I$ expr is not speci$ied, location counter taes pre*ious maximum *aluesed to rede$ine t(e storageE8!"2le9B"" S 1''"

  • 8/18/2019 IBM Assembler mannual.doc

    37/118

    IBM 370 ASSEMBLY LANGUAGE 37 / 118

    : B""  ) S C%#'  B S C%#'  C S C%#'  S C%#'

    :

    RO(

    • 8',1,...>9

    • Speci$ied registers are dropped as base registersE8!"2le  B)% 12,'

    SI>: A,12...

    12

    EN LABEL

    • Signals t(e end o$ a control section or program, %abel is t(e entry point

    EEC6• "orce a $orm $eed

    • =(e directi*e itsel$ not printed in t(e listing

    L6ORG

    • "orces assembler to dump t(e literals collected up to t(at point

    E;6RN' EN6RY See example belo0.FIRST CSECT

    ENTR ATA

    STM 14,12,12(13)

    BALR 12,0

    USING *,12ST 13,SAVE+4

    LA 13,SAVE

    WTO 'IN ASM4 BEFORE CALL TO SUB4'

    LA 3,MSG

    WTO TET=(3)

    L 1",ASUB1

    BALR 14,1"

    WTO 'IN ASM4 AFTER CALL TO SUB4'

    LA 3,MSG

    WTO TET=(3)

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",4

    BR 14

    SAVE S 1#F

    C A(SAVE)

    ASUB1 C V(SUB4)

    MSG C AL2(L'ATA)

    ATA C CL20'ATA BEFORE CALL'

    EN

  • 8/18/2019 IBM Assembler mannual.doc

    38/118

    IBM 370 ASSEMBLY LANGUAGE 38 / 118

    SUB4 CSECT

    ETRN ATA

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4LA 13,SAVE

    WTO 'IN SUB 4 BEFORE C$ANGING ATA'

    L 3,AATA

    MVC 0(20,3),=CL20'ATA AFTER C$ANGE'

    WTO 'IN SUB 4 AFTER C$ANGING ATA'

    L 13,SAVE+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    AATA C A(ATA)

    EN

    @;6RN

    • de$ines a 0ea external re$erence. ) 0ea external re$erence does not triggera linage editor auto call. >ote t(at in t(e $ollo0ing example t(e linage editordoes not ob@ect to S)1 remaining unresol*ed.

    E8!"2leFIRST CSECT

    WTRN SAVE1

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4LA 13,SAVE

    WTO TET=ATA

    L 13,SAVE+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    ATA C AL2(L'MSG)

    MSG C CL30'ASM1 REPORTING'

    EN

    COM

    • e$ines a common section. )ll common sections across CSC=S 0it( t(esame name map to t(e same storage. =(e storage $or C--> sections isallocated at t(e time t(e load module is built.

    SUB CSECT

    SUB AMOE 31

    SUB RMOE AN

  • 8/18/2019 IBM Assembler mannual.doc

    39/118

    IBM 370 ASSEMBLY LANGUAGE 3( / 118

      STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    L 4,ACOM

    LA ",1"ST$ ",0(0,4)

    MVC 2(1",4),=CL1"'T$IS IS SUB'

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",0

    BR 14

    SAVE S 1#F

    ACOM C A(COMMON)

    COMMON COM

    MSG S AL2

    S CL100

    EN

    FIRST CSECT

    FIRST AMOE 31

    FIRST RMOE AN

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    L 1",ASUB

    BALR 14,1"

    ICM 4,B'1111',ACOM

    WTO TET=(4)

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",0

    BR 14

    SAVE S 1#F

    ASUB C V(SUB)

    ACOM C A(COMMON)

    COMMON COM

    MSG S AL2

    S CL100

    EN

  • 8/18/2019 IBM Assembler mannual.doc

    40/118

    IBM 370 ASSEMBLY LANGUAGE 40 / 118

    CL AS(EC6S #!c5

     (rogram consists o0  -ac(ine instructions )ssembler instructions-acro Instructions.

    Develo(ment cycle  Coding

    re )ssembly )ssembly%inage ditrogram $etc(

    +C%O IB- supplied catalogued procedures can be used. )S-)C% is gi*en belo0  0(ic( assembles and lins a assembler program

    ??)S-)C% C??A??AAA )S-)C%??A??A =IS C >S = I: %% )SS-B% )> %I>7%J )SS-B% :)-

    ??A??C DC :E)S-)&',)-E8B+C=,>CESJS1.-)C%IB,ISES??SJS=I S>E//SJS=1,S)CE84'&6,812',12'9,,,>9,>I=EI,?? CBEB">E1??SJSI>= SJS=EA??SJS>C SJS=EB??SJS%I> S>E//B+,S)CE83'4',84',4'9,,,>9,>I=EI,?? ISE8-,)SS9,

    SOURCE

    ASSEMBLER 

    MACLIBSCOPY BOOKS

    OBJECT DECK OBJECT LIBRARIES

    LINKER 

    LOAD MODULE

    LOAD IN MAIN STORAGE FOR EXECUTION

  • 8/18/2019 IBM Assembler mannual.doc

    41/118

    IBM 370 ASSEMBLY LANGUAGE 41 / 118

    ?? CBE8B%9,?? CBEB">E1,>I=EI??SJSI>= SJS=EA

    I"2$r+!n+ lin5!ge e*i+$r 2!r!"e+ers

    LE6 allo0s you to speci$y se*erity le*el o$ an error to determine 0(et(er t(e load module is to be marunusable.

    MA( D NOMA( se map i$ you 0ant a generated map o$ t(e load module

    NCAL o not mae an automatic searc( o$ t(e ob@ect libraries 0(en lining

    REN6 Indicates module is reentrant, >>= mars it as non reentrant

    AMOE ,-D31DANY . se t(is parameter to o*erride t(e attribute establis(ed by t(e assembler in t(eassembly process

    RMOE ,-DANY o*errides t(is attribute as set by t(e assembly process

    Asse"#ler 

    ALIGN instructs assembler to c(ec $or alignment 0(ere it is reuiredde$ault )%I:>

    EC4  )ssembler generates ob@ect dec on SJS>Cde$ault >C<

    ES =(e xternal symbol dictionary is produced in t(e listingde$ault S

    OBEC6 instructs t(e assembler to generate an ob@ect data set on SJS%I>de$ault B+C=

    REN6 instructs t(e assembler to c(ec $or possible *iolations o$ reentrantde$ault >>=

    RL t(e assembler outputs t(e relocation dictionary in t(e listingde$ault %

    SYS(ARM SJS)- 8 parm*alueVVV9 max 55 c(ars

    ;RE:>:ULL rdinary symbol and literal cross re$erence listing produced including symbols t(at are nre$erred to .

    ;RE:>SHOR6 mits symbols not re$erred to.e$ault D"8S=,>"S9

    S2eci!l C$nsi*er!+i$ns hen +he "e"#er n!"e !n* +he CSEC6 n!"e *$ n$+ "!+ch. S$)rce :ile1FIRST CSECT

  • 8/18/2019 IBM Assembler mannual.doc

    42/118

    IBM 370 ASSEMBLY LANGUAGE 42 / 118

      STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    WTO 'IN ASM3 BEFORE CALL TO SUB1'

    L 1",ASUB1BALR 14,1"

    WTO 'IN ASM3 AFTER CALL TO SUB1'

    L 13,SAVE+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    ASUB1 C V(SUB1) -. / .- -5.

    *ASUB2 C V(SUB2) -. .- 6 -5

    EN

    S$)rce :ile,SUB1 CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    WTO 'IN SUB 1'

    C F'0'

    L 13,SAVE+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    SUB2 CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE1+4

    LA 13,SAVE1

    WTO 'IN SUB 2'

    L 13,SAVE1+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE1 S 1#F /- 76 6-. 86// - 7- .65-

      EN

    =(e solution is to explicitly mae t(e %inage ditor include t(e module by t(e linage editorcontrol statement input as belo0O

    ??% AI>C% SJS%IB8SB19

    ?A

  • 8/18/2019 IBM Assembler mannual.doc

    43/118

    IBM 370 ASSEMBLY LANGUAGE 43 / 118

    SUBROU6INES AN LIN4AGES ,- BI6 MOE  back SUBROU6INE

    • ntry point Identi$ied by a CSC=,S=)= >=J assembler directi*es.

    •  )n entry is made in t(e S $or eac( ntry point.

    •  ) CSC= can (a*e multiple entry points speci$ied by >=J directi*e

    • Internal Subroutine O) subroutine present in t(e source module $rom 0(ic( it is called.

    • xternal Subroutine O) subroutine present in a di$$erent source module. )ssembled and linedited separately

    • Static Subroutine O ) subroutine 0(ic( is no0n at t(e lin edit time. Can be an internal or anexternal subroutine.

    • ynamic SubroutineO ) subroutine 0(ic( is loaded at program run time using %), %I><macros

    • type address constantO =o re$er a symbol de$ined in anot(er CSC=.

    • xternal symbol directory 8S9 O ) table containing in$ormation about t(e name, locationand siFe o$$ eac( all external symbols

    Lin5ing +$ s)#r$)+ineB)% 1,2 Branc( and lin register 

    819 GC,C G29

    B)% 1,S2 Branc( and lin819 GC,C GS2

    =(e next instruction address is loaded in t(e register speci$ied by t(e$irst operand and t(e branc( is taen to t(e address speci$ied by t(e secondoperand. I$ 2 is Fero, t(en no branc( is taen

    Re+)rn fr$" s)#r$)+ineB 1 Branc( register 

    C G819Branc( unconditionally to t(e address speci$ied in t(e operand 1xampleO

    -)I> S=)= 'S=.B)% 14,SB1.% 15,SB2B)% 14,15

    A+

    ASB1 S

    B 14SB2 C 8SB=29

    >

    S!ing !n* res+$ring enir$n"en+rograms uses registers as base, index, and accumulators. I$ a program calls a subprogram, and0(en t(e control returns, t(ese register *alues s(ould not be altered. =o ac(ie*e t(is, t(e callingprogram pro*ides a S))) into 0(ic( t(e called program sa*es t(e registers. Be$ore t(econtrol is returned $rom t(e subprogram, t(e registers are restored to t(eir original *alues. Somesubprograms return to t(e called program a return code 8set in :159 and a reason code. It isa good programming practice to sa*e and restore t(e en*ironment. I$ t(is is done any subroutinecan be used by any program 0it( out t(e need to identi$y 0(ic( registers are modi$ied by t(esubroutine.

  • 8/18/2019 IBM Assembler mannual.doc

    44/118

    IBM 370 ASSEMBLY LANGUAGE 44 / 118

    IBM c$nen+i$n f$r s!ing regis+ers

    • *ery calling routine (as a sa*e area o$ 1# $ull0ords $or t(e use o$ called routine

    • =(e calling routine passes t(e sa*e area address in register 13

    • *ery called routine sa*es t(e registers in t(is area be$ore establis(ing addressability

    •  )ddress o$ called routine is in register 15

    • egister 14 (as t(e return address

    SA%EAREA >1F :)ll $r*s l!/$)+Sa*earea' eser*ed $or %?1

      Sa*earea4 sa*earea o$ program 0(ic( called t(is subprogramSa*earea# sa*earea o$ called subprogram called by t(is programSa*earea12 egister 14sa*earea16 egister 15sa*earea2' egister '. .. .. .Sa*earea64 egister 11

    Sa*earea6# egister 12E8!"2le-)I> S=)= '

    S=- 14,12,128139B)% 12,'SI>: A,12S= 13,S)4% 2,13%) 13,S)S= 13,#829...%) 15,'

    % 13,S)4% 14,128',139%- ',12,2'8139

    AB 14

    S) S 1#">

    A*!n+!ges $f SA%EAREA

    • "or0ard and bac0ard pointers running t(roug( t(e sa*e areas use$ul $ortracebac

    • Called program can $irst sa*e t(e en*ironment be$ore acuiring storage incase o$ reentrant program

    (!r!"e+er 2!ssing

    • "ixed and *ariable number o$ parameters can be passed to a subprogram

    • arameters *alue are not passed directly

    • ac( parameter is sa*ed in t(e storage t(en an array is created containing (e address o$ t(eparameters in t(e order t(ey are expected in t(e called program and t(e register 1 is loaded0it( t(e starting address o$ t(is address array. =(e last address in t(e array s(ould (a*e bit ;'; set to ; 1;

  • 8/18/2019 IBM Assembler mannual.doc

    45/118

    IBM 370 ASSEMBLY LANGUAGE 45 / 118

    • "or *ariable number o$ parameters, t(e (ig( order bit o$ t(e last parameter is set to one toindicate t(e end o$ parameter list

    E8!"2le%) 2,IS= 2,)-%) 2,2S= 2,)-4%) 3,3S= 3,)-#%) 1,)-% 15,E8C19B)% 14,15..%) 1,E)82,1,39% 15,E8C29B)% 14,15.

    1 S C%#

    2 C ";2';3 C C;)BC":I+

  • 8/18/2019 IBM Assembler mannual.doc

    46/118

    IBM 370 ASSEMBLY LANGUAGE 46 / 118

    .B 14

    I C ";1'';+ C ";12';< S "S)1 S 1#"A-I> CSC=

    . entry linages

    .%- 4,5,'819% 4,'849% 5,'859C 4,5B: BI:% ',5B S=

    BI: % ',4S= K A

    .

    . exit linages.B 14

    S)2 S 1#">

    E8!"2le $f c!2+)ring (ARM *!+! fr$" CLPICING UP PARMS

    FIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVEL 13,SAVE+4

    L 2,0(0,1)

    L$ 3,0(0,2)

    STCM 3,B'0011',MSG

    S 3,=F'1'

    E 3,IN1

    LA 4,MSG

    WTO TET=(4)

    LM 14,12,12(13)

    LA 1",0

    BR 14

    SAVE S 1#FIN1 MVC MSG+2(0),2(2)

    MSG C AL2(0)

    S CL100

    EN

    (!ssing S+r)c+)res >li5e ! COBOL 01 leel i+e"SUB CSECT

    STM 14,12,12(13)

  • 8/18/2019 IBM Assembler mannual.doc

    47/118

    IBM 370 ASSEMBLY LANGUAGE 47 / 118

      USING SUB,1"

    ST 13,SAVE+4

    LA 13,SAVE

    LR 12,1"

    ROP 1"

    USING SUB,12

    LR 2,1WTO 'IN SUB'

    LR 1,2

    L 2,0(1)

    USING PARMS,2

    L ",A

    A ",B

    ST ",RES

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",0

    BR 14

    SAVE S 1#FPARMS SECT

    A S F

    B S F

    RES S F

    EN

    FIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    L 1",ASUB

    LA 1,=A(PARMS)

    BALR 14,1"

    L ",RES

    CV ",W

    UNP MSG+2(1!),W

    OI MSG+1,'F0'

    WTO 'RESULT IS'

    LA 4,MSG

    WTO TET=(4)

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",0

    BR 14

    SAVE S 1#F

    MSG C AL2(1!)

    S CL1!

    ASUB C V(SUB)

    W S

      S 0F

  • 8/18/2019 IBM Assembler mannual.doc

    48/118

    IBM 370 ASSEMBLY LANGUAGE 48 / 118

    PARMS S 0CL12

    A C F'100'

    B C F'200'

    RES S F

      EN

  • 8/18/2019 IBM Assembler mannual.doc

    49/118

    IBM 370 ASSEMBLY LANGUAGE 4( / 118

    MACRO AN CONI6IONAL ASSEMBLY Back M!cr$

    •  )n extension o$ assembler language.

    • ro*ides con*enient 0ay to generate a seuence o$ assembler language statements

    •  ) macro de$inition is 0ritten only once

    • -acro in*ocation expands to t(e desired seuence o$ statements• Conditional assembly statements can be used to tailor t(e statements generated

    • arameters can be passed to t(e macro

    • xpanded during t(e preassembly time and generates inline code

    M!cr$ *efini+i$n

    • Can appear at beginning o$ a source module in 0(ic( case it is called a source -)C

    • System macros reside in a system library 8ddname SJS%IB9

    • ser macros reside in a user library or in t(e source program itsel$ 

    • >ested macro in*ocations possible

    :$r"!+ $f ! M!cr$ *efini+i$n

    eader. Indicates t(e beginning o$ a macro de$inition 8-)C9• rototype statement. e$ines t(e macro name and t(e symbolic parameters

    • Body. Contains model statements, processing statements, comments statements andconditional assembly statements.

    • =railer. Indicates t(e end o$ a macro de$inition 8->9

    (r$+$+/2e

    • -ust be t(e second noncomment statement in e*ery macro de$inition.

    • nly internal comments are allo0ed bet0een t(e macro (eader and t(e macro prototype.

    • "ormat o$ t(e prototype statementO

    W>ameX peration WperandsX

    !ame 0ield   O ) *ariable symbol. =(e name entry in t(e calling macro instruction isassigned to t(is symbol.

    O(eration 0ield O =(e name o$ t(e macro. =(e macro is in*oed 0it( t(is name.O(erands  O Speci$y positional or ey0ord parameters. -aximum 24' parameters

    can be passed*acro body   O

    • Contains t(e seuence o$ statements t(at are generated in t(e macro expansion.

    • -odel statements $rom 0(ic( assembler language statements are generated.

    • rocessing statements t(at can alter t(e content and seuence o$$ t(e statementsgenerated or issue error messages.

    • Comments statements.

    • Conditional assembly instructions to compute results to be displayed in t(e message created b->= instruction, 0it(out causing any assembler language statements to be generated

    M$*el S+!+e"en+

    •  )ssembler language statements are generated at preassembly time $rom modelstatement

    • ariable symbols can be speci$ied to *ary t(e contents o$ t(e statements generated

    • Statements generated must not be conditional assembly instructions

    %!ri!#le S/"#$ls

    • re$ixed 0it( ;/; c(aracter 

  • 8/18/2019 IBM Assembler mannual.doc

    50/118

    IBM 370 ASSEMBLY LANGUAGE 50 / 118

    • Can appear in macros and in conditional assembly statements

    • Can be symbolic parameters, system *ariables or set symbols

    • System *ariables are read only and t(eir *alue is maintained by t(e )ssembler 

    E8!"2leSO /% />)- /)I /))-819

    SJS=-O /SJS>D /SJS)= /SJSC=

    C$nc!+en!+i$n 8P.P9• sed 0(en a c(aracter string (as to be concatenated to a *ariable symbol

    • Concatenation c(aracter is mandatory19 0(en an alp(anumeric c(aracter is to $ollo0 a *ariable symbol29 ) le$t parent(esis t(at does not enclose a subscript is to $ollo0 a *ariable symbol

    • =o generate a period, t0o periods must be speci$ied in t(e concatenated string $ollo0ing t(e*ariable symbol

    • Concatenation c(aracter is not reuired19 0(en an ordinary c(aracter string precedes a *ariable symbol29 ) special c(aracter, except a le$t parent(esis or a period, is to $ollo0 a *ariable symbol39 ) *ariable symbol $ollo0s anot(er *ariable symbol

    49 Bet0een a *ariable symbol and its subscript

    S+ring S/"#$l %!l)e Res)l+/"%.) /"% )) )))/"%) /"%) S- S-

    /B 1'/.8/B9 / 1'' 1''81'9

    /I &&/"

    ;/I../"; ;&&.;/I./"; ;&#;/)3 /) ) )3

    S/"#$lic (!r!"e+ers

    • ariable symbols included in macro prototype are supplied *alues by t(e macro call

    •  )ctual *alue supplied $or a $ormal parameters is a c(aracter string 8maxE255c(ars9

    • =0o inds o$ symbolic parameters

    ⇒ ositional arameters

    ⇒ ull string $or t(e omitted parameters

    • e$aults can be speci$ied $or ey0ord parameters

    • arameters can be subscribed

    • a*e local scope

    • ead only

    E8!"2le-)C-)C1 /1,/

  • 8/18/2019 IBM Assembler mannual.doc

    51/118

    IBM 370 ASSEMBLY LANGUAGE 51 / 118

    .

    .-)C1 >,

    E8!"2le-)CII /1,/2,/=J- /1,E"Y1;/=J /1,/2->

    nvocation-)I> CSC=

    .

    .

    .II #,>- - #,E"Y1; #,>-

    .

    .II 4,6,

    - 4,E";1;..

    4,6>

    (r$cessing S+!+e"en+s

    • -acro instruction

    • Conditional assembly instructions

    M!cr$ ins+r)c+i$nsMNO6E instruction

    GSK SJ-H ->= GoptH GmessageH• =o generate error messages or display intermediate *alues o$ *ariable symbols

    • Can be used in open code or in a macro

    • pt speci$ies a se*erity code. I$P,P is speci$ied t(en t(e se*erity code *alue is P1P

    • I$ opt is omitted or a YA; is speci$ied, t(en t(e message is generated as a commentxampleO->= 2, Yrror in syntax;

    ->= ,Yrror, se*erity 1;->= A, Y) comment;->= Y)not(er comment;

    ME;I6 instructionGSK SJ-H -DI=

    • xit $rom t(e current macro de$inition

    • Can be used only inside a macro de$inition

    C$""en+s

  • 8/18/2019 IBM Assembler mannual.doc

    52/118

    IBM 370 ASSEMBLY LANGUAGE 52 / 118

    •  ) PAP in column generates an ordinary comment 0(ic( 0ill appear in t(e listing

    •  ) P.AP seuence in column 1 generates an internal comment 0(ic( 0ill not appear in t(e listing

    S/s+e" %!ri!#les

    %ariables set by the system

    /SJS)=, /SJS)-, and /SJS>D can be used only 0it(in a macro

    N!"e escri2+i$n/SJS%IS= ro*ides alternate 0ay o$ accessing positional parameters/SJS)- =o obtain t(e compile time parm *alue passed t(ru +C% DC statement/SJSC= =o get t(e name o$ CSC= $rom 0(ere macro is in*oed/SJS=I- =o get time in .-- $ormat/SJS)= =o get date in --??JJ $ormat

    E8!"2lerototype statement O % >)- 1,2,,4,85,69/SJS%IS=89 E %/SJS%IS=819 E 1/SJS%IS=829 E 2/SJS%IS=839 E >%% S=I>:

    /SJS%IS=849 E 4/SJS%IS=859 E 5,6/SJS%IS=85,19 E 5/SJS%IS=85,29 E 6>;/SJS%IS= E 5>;/SJS%IS=859 E 2

    S)#lis+s

    • =o speci$y *ariable number o$ parameters to a macro

    • ne or more entries separated by commas and enclosed in parent(esis

    • Including t(e parent(esis, maximum lengt( is 255 c(aractersE8!"2le

    -)C

    /% ) /1,/2,/

    L!#els in "!cr$I$ ordinary symbols are used as label, t(en $or eac( macro in*ocation, t(e same label 0ill begenerated and duplicate symbol error 0ill occur at assembly time. =o a*oid t(is /SJS>Dsystem *ariable can be concatenated 0it( a symbol, so t(at t(e label generated is uniue.E8!"2le

    -)C

  • 8/18/2019 IBM Assembler mannual.doc

    53/118

    IBM 370 ASSEMBLY LANGUAGE 53 / 118

    %%/SJS>D K A

    B> %/SJS>D->

    nvocation-)I> S=)= '

    %%'''1 K A B> %'''1

    %%'''2 K A B> %'''2

    C$n*i+i$n!l Asse"#l/

    • Selecti*ely assemble a seuence o$ instructions

    • Can be used in t(e open code or in t(e macros

    • rocessed at t(e preassembly time

    • -any $unctions lie a programming language is a*ailable

    ⇒ ariable declarations and assigning *alues

    ⇒  )rit(metic and logic $unctions

    ⇒ C(aracter processing

    ⇒ Control $acilities

    • Conditional assembly statement labels are called seuence symbols and are pre$ixed 0it( .

    Se+ S/"#$ls

    • ro*ides arit(metic, binary, or c(aracter data

    • alues can be *aried at preassembly time

    • Can be subscripted 8set symbol array9

    • Can be local80it(in a macro9 or global 8across ot(er macros in t(is assembly9set symbols

    • sed as

    ⇒ =erms in conditional assembly expressions

    ⇒ Counters, S0itc(es and c(aracter strings

    ⇒ Subscripts $or *ariable symbol

    ⇒ alues $or substitution

    Gl$#!l se+ s/"#$ls

    • alues can be accessed any 0(ere in t(e source

    • as to be de$ined in eac( part o$ t(e program in 0(ic( it is accessed 8macro, open code9

    • eclared using:B%), $or global arit(metic set symbols:B%B, $or global binary set symbols:B%C, $or global c(aracter set symbols

    • :B%) and :B%B (a*e a de$ault *alue ' 8Fero9

    • :B%C (as null string as de$ault *alue• SJ>=)D

    :B%) G)%IS=H:B%B G)%IS=H:B%C G)%IS=H

    E8!"2le:B%) /=S=,/)%:B%C />)-,/I:B%B /=

  • 8/18/2019 IBM Assembler mannual.doc

    54/118

    IBM 370 ASSEMBLY LANGUAGE 54 / 118

    L$c!l se+ s/"#$ls

    • alues can be accessed only in t(e macro in 0(ic( it is de$ined

    • eclared using%C%), $or local arit(metic set symbols%C%B, $or local binary set symbols

    %C%C, $or local c(aracter set symbols• %C%) and %C%B (a*e de$ault *alue ' 8Fero9

    • %C%C (as null string as de$ault *alue

    • SJ>=)D%C%) G)%IS=H%C%B G)%IS=H%C%C G)%IS=HE8!"2le%C%) /C>=,/)%%C%C /S=1%C%B /=

    C$n*i+i$n!l Asse"#l/ E82ressi$ns

    =(ree inds⇒  )rit(metic

    ⇒ C(aracter 

    ⇒ Binary

    • Can be used as operands o$ conditional branc( instruction

    • =o assign *alues to set symbols

    •  )rit(metic expressions are $ormed using arit(metic operators

    • C(aracter expressions can produce strings o$ up to 255 c(ars

    • arameter substitution 0it(in uoted strings

    • uplication $actor $or uoted strings

    • Boolean expression by combining arit(metic or c(aracter expressions using relationaloperators

    Assigning %!l)es +$ Se+ S/"#$ls

    • :lobal set symbols (a*e to be de$ined be$ore assigning *alues

    • ndeclared set symbols are de$ined as local set symbols

    • -ore t(an one element in an array can be assigned *alues in a single set statements

    Se+ Ari+h"e+ic

    • G) SJ-B%H S=) Garit(metic expressionH

    • =o assign an arit(metic *alue to a S=) symbol

    • alue represented by S=C symbol *ariable string can be used as a term in an  arit(metic expression pro*ided t(ey contain only numeric digits.• alue represented by S=B symbol *ariable can also be used in arit(metic expression

    • alid unary operators are ,.Binary operators are ,,A,?E8!"2les

    /) S=) 1' 23 /B S=) 2 4 /C S=) /) 1'?/B 25 / S=) 8/)1'9?/B 23 /) S=) 11 22/B S=) /)?2 5 /) S=) 1 2/B S=) /)?2 3 

  • 8/18/2019 IBM Assembler mannual.doc

    55/118

    IBM 370 ASSEMBLY LANGUAGE 55 / 118

    Se+ Bin!r/

    • G) SJ-B%H S=B GBoolean expressionHE8!"2le

    /B S=B 1/) S=B '

    • =o assign an binary bit *alue to a S=B symbol

    Se+ Ch!r!c+er 

    • G) SJ-B%H S=C GexpressionH

    • =o assign c(aracters *alue to a S=C symbol

    • =(e expression could be

    ⇒  ) type attribute re$erence

    ⇒  ) c(aracter expression

    ⇒  ) sub string notation

    ⇒  ) concatenation o$ sub string notations, or c(aracter expressions, or bot(

    •  ) duplication $actor can precede any o$ t(e $irst t(ree optionsE8!"2le9

    /C S=C ;S=I>:';AA /CEPS=I>:'PA/ S=C T/C84,29AA / E PI>PA/ S=C ;%;;SJ-B%;AA / E P%;SJ-B%PA/" S=C ;)%"//;

    AA /"EP)%"/PA/: S=C ;/.>;AA /:EPI>>PA/C1 S=C 38;)BC;9AA /C1 E T)BC)BC)BCAE8!"2le

    -)C/>)- - /=,/"-

    %C%) /)1%C%B /B1,/B2%C%C /C1

    /B1 S=B 8%;/= K 49/B2 S=B 8S;/= K '9/)1 S=) /B1/C1 S=C ;/B2;/>)- S= 2,S)))

    % 2,/"-/)1

  • 8/18/2019 IBM Assembler mannual.doc

    56/118

    IBM 370 ASSEMBLY LANGUAGE 56 / 118

    S= 2,/=/C1% 2,S)))->

    nvocation-)I> S=)= ' - "%),"%B S= 2,S))) % 2,"%B1 S= 2,"%) % 2,S)))

    C$n*i+i$n!l Br!nch

    GSK SJ-B%H )I" 8G%:IC)% DH9.GSK SJ-B%H

    =(e logical expression in t(e operand $ield is e*aluated at preassembly time to determine i$ it istrue or $alse. I$ t(e expression is true, t(e statement named by t(e seuence symbol in t(eoperand $ield is t(e next statement processed. I$ t(e expression is $alse, t(e next seuentialstatement is processed by t(e assembler.

    %ogical operators are K,>,%,%=,:,:=

    xample )I" 8Y/C; K YJS;9.=. )>....= )>

    Unc$n*i+i$n!l #r!nch

    • GSK SJ-B%H ): GSK SJ-2H

    Branc(es to t(e statement identi$ied by PSK SJ-2P

    C$n*i+i$n!l Asse"#l/ L$$2 C$)n+er 

    • GSK SJ-B%H )C= G)I=-=IC DSSI>H

    • Set a conditional assembly loop counter eit(er 0it(in a macro de$inition or in open code.

    • Can appear any 0(ere in t(e program.

    • ac( time ): or )I" is executed t(e counter *alue is decremented by one and i$ its is Feroexit $rom t(e macro or stop processing t(e statements in t(e open code

    •  )*oids excessi*e looping

    •  )ssembler (as a de$ault counter and it is initialised 0it( 4'&6

    NO(

    • Gseuence symbolH )>

    • er$orms no operation• sed to de$ine a seuence symbol 0(ic( can be used in )I" and ):

    !+! A++ri#)+esGcH ;SJ-B%

     )ttribute escription= =ype o$ t(e symbol

    alues returned by assembler are ),,S,K "or t(e *arious address constants

  • 8/18/2019 IBM Assembler mannual.doc

    57/118

    IBM 370 ASSEMBLY LANGUAGE 57 / 118

    B Binary constantC C(aracter constant,,% "loating point constant", Integer constants aced decimal constant exadecimal constantL Loned decimal constantI -ac(ine instruction- -acro+ Control section= D=> symbol> Sel$ de$ining term unde$ined 8omitted9% %engt( o$ symbol number o$ bytesC >umber o$ c(aracters contained by t(e *ariable symbol> >umber o$ element in a sublist associated 0it( t(e symbol e$ined attribute, indicates 0(et(er or not t(e symbol (as been de$ined prior 

    E8!"2le-)C=)B%

    %C%) /I/SJS%IS=8'9 S '.7I% )I" 8/I := >;SJS%IS=9.>

    C ;/SJS%IS=8/I9/I S=) /I1

     ): .7I%.> ->

    M!cr$ hel2 f!cili+/

    • GnameH -% G*alueH

    • Controls a set o$ trace and dump $acilities

    • Can occur any0(ere in open code or in macro de$initions

    • emains in e$$ect until superseded by anot(er -% statement

    • -ore t(an one $acility can be speci$iedalue "unction1 -acro Call =race2 -acro Branc( =race4 -acro )I" ump# -acro xit ump16 -acro ntry ump32 :lobal Suppression64 -acro ex ump12# -(elp Suppression

  • 8/18/2019 IBM Assembler mannual.doc

    58/118

    IBM 370 ASSEMBLY LANGUAGE 58 / 118

    E'am(le o0 TP#T *A$"O-)C

    /%)B% == /), D /%>, D /"%%SC %C%C /=-:

    A )I" 8;/%)B%; K ;;9.>%)B

    /%)B% S '.>%)B )>.A  )I" 8;/); K ;;9.>)  )I" 8;/);81,19 K ;8;9.):  %) ',/) GET ADDRESS IN R0   ): .>).): )>/=-: S=C ;/);82,

  • 8/18/2019 IBM Assembler mannual.doc

    59/118

    IBM 370 ASSEMBLY LANGUAGE 5( / 118

    E'am(le o0 SA%E macro  -)C/%)B% S) /:S, D  /=, D  /I.A  )I" 8;/%)B%; K ;;9.>%)B/%)B% S '>%)B )>  )I" 8;/I; K ;;9.C>=I>.A =(is is a macro comment  B 128159A =(is is a normal assembler comment  )I" 8;/I; K ;A;9.I  C C%#;/I;  ): .C>=I>.I )>  )I" 8;/%)B%; K ;;9.>I  C C%#;/%)B%;  ): .C>=I>

    .>I )>  C C%#;/SJSC=;

    .C>=I> )>

    .A  )I" 8;/:S; K ;;9.>:S  S=- /:S819,/:S829,128139.>:S )>  ->

  • 8/18/2019 IBM Assembler mannual.doc

    60/118

    IBM 370 ASSEMBLY LANGUAGE 60 / 118

    E'am(le o0 "ET#"! macro  -)C/%)B% => /:S, D  /=, D  /CE.A  %C%) /7:S )I" 8/:S819 : /:S8299.=1 )I" 8/:S829 K 159.=1 )I" 8;/C; K ;;9.C=3 )I" 8;/C;81,19 K ;8;9.C=2%) 15,/C

    .C=3 )>%- /:S819,/:S829,128139

    B 14-DI=.C=2 )>/)% S=) /C819

    % 15,/)%%- /:S819,/:S829,128139B 14-DI=

    .A

    .=1 )> )I" 8;/C; K ;;9.C=4

    /7< S=) 815/:S8199A4 )I" 8;/C;81,19 K ;8;9.C=1%) 15,/CS= 15,12/7%- /:S819,/:S829,128139B 14-DI=

    .C=1 )>/)% S=) /C819

    S= /)%,12/7:S )>

     )I" 8;/C; K ;;9.C=6 )I" 8;/C;81,19 K ;8;9.C=5%) 15,/C

    .C=6 )>B 14-DI=

    .C=5 )>/7< S=) /C819

    % 15,/7<B 14

  • 8/18/2019 IBM Assembler mannual.doc

    61/118

    IBM 370 ASSEMBLY LANGUAGE 61 / 118

    -DI=->

  • 8/18/2019 IBM Assembler mannual.doc

    62/118

    IBM 370 ASSEMBLY LANGUAGE 62 / 118

    M%S SYS6EM MACROS  back SAM

    CB -acro• Included $or e*ery data set accessed by t(e program

     )ccess met(od depends upon t(e parameters passed to t(e CB•  )ll parameters are ey0ord parameters speci$ying *arious options $or t(e data set

    • :enerates non executable code 8control bloc9 and s(ould t(ere$ore be coded in t(e data area

    >ame CB >)- External name in +C%,S: ES R ,-)C" E88:9 R 89 R 8:,9,-R%9%C% E,B%otesO : :et, ut,:, :et and =- -o*e mode I?% %ocate mode I?" "ixed unbloced"B "ixed bloced"B) "ixed bloced 0it( $irst c(aracter as a )S) control c(aracter. sed only $or

    printer output ariable unblocedB ariable bloced

    O(EN -acro>ame > 8CBnameWoptions...X9

    • %ogically connect a data set• ata set identi$ied in t(e CB is prepared $or processing

    • ption -eaningI>= Input data set== utput data set)= ata set to be updated in placeD=> )dd records to t(e end o$ t(e data set

    • IS isp options 8)SS,C)=%:9E8!"2le> 8-%J,8I>=9,S)%S,8==99

    CLOSE -acro>ame C%S 8CB>)- W,option9,...X9

    • %ogically disconnect a data set• ption -eaning

    ) osition to t(e beginning o$ t(e data set%) osition to t(e logical end o$ t(e data set7I> -agnetic tape (as to be positioned at t(e beginning

    • IS isp options lie )SS,C)=%:E8!"2leC%S 8-%J,S)%S9

  • 8/18/2019 IBM Assembler mannual.doc

    63/118

    IBM 370 ASSEMBLY LANGUAGE 63 / 118

    GE6 -acro 8KS)-9>ame := CB>)-, Warea nameX• etrie*e t(e next record

    • Control is returned a$ter t(e record is read

    • In locate mode t(e address o$ t(e record is returned in 1

    • In mo*e mode t(e record is mo*ed to t(e user area

    E8!"2le:= -%J, -C

    (U6 -acro 8KS)-9>ame = CB>)-,Warea nameX• 7rite a record.

    • Control is returned a$ter t(e record is 0ritten

    • In locate mode t(e area name parameter is omitted and t(e system returns t(e address o$ t(e I? bu$$er in 1. =(e data (as to be mo*ed to t(is area and it is 0ritten in t(e next= call.

    • In mo*ed mode, t(e system mo*es t(e record to an output bu$$er be$ore t(e control is  returned.

    E8!"2le= -%J,-C

    E8!"2lePRINT CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    OPEN (SSPRINT,OUTPUT)

    LTR 1",1"

    BN9 OPENERR

    LA ",20

    MVC OUTREC+1(132),=CL132'T$IS IS LINE ONE:'

    LOOP PUT SSPRINT,OUTCAR

    BCT ",LOOP

    CLOSE SSPRINT

    L 13,SAVE+4

    RETURN (14,12),,RC=0

    OPENERR L 13,SAVE+4

    RETURN (14,12),,RC=1!

    OUTCAR C AL2(13),AL2(0)

    OUTREC C CL133' '

    SSPRINT CB NAME=SSPRINT,MACRF=PM,SORG=PS,

      LRECL=13,BLSI9E=130,RECFM=VBSAVE S 1#F

    EN

    CL??SJSI>= SJS=EA

    Me"$r/ M!n!ge"en+

  • 8/18/2019 IBM Assembler mannual.doc

    64/118

    IBM 370 ASSEMBLY LANGUAGE 64 / 118

    GE6MAIN

    • =o allocate *irtual storage

    • Can be allocated on double 0ord or page boundary

    • Storage is not initialised

    • Storage allocation abo*e or belo0 16-B line

    • se "-)I> to release t(e storage

    • egister 1 contains t(e storage addressSyntax>ame :=-)I> ,%El*,B>JEbndry,%CE1oc egister $orm% %engt( *alueB>JB%7?):%C B%7?)>J 816-B line9

    E8!"2le:=-)I> ,%E4'&6,B>JE):,%CE)>J>oteO -ore details on :=-)I> are a*ailable in t(e c(apter I=)% S=):-)>):->=

    E8!"2le =(is example uses D, CD data types and K type address constantD re$ers to storage allocated in an external dummy section. ) SC= can also beconsidered an external dummy section i$ it is used in a K type constant. =(e CD isinitialised by t(e linage editor to t(e sum o$ t(e lengt(s o$ all external dummy sections int(e load module. It is used to getmain storage $or t(e external dummy sections at run time.=(e K type address constants are set to t(e o$$set o$ t(e corresponding dummy sections.=I> ) 

  • 8/18/2019 IBM Assembler mannual.doc

    65/118

    IBM 370 ASSEMBLY LANGUAGE 65 / 118

      ) CSC=  .  % 3,%>  :=-)I> ,%E839  % 11,1  .  % 15,E8C9

      B)% 14,15  .

    % 15,E8B9  B)% 14,15

      . )D D 2%#

      BD D 4"%4  %> CD  .  C K8)D9  C K8BD9  . 

    "O#T!E )  >ame peration perand  B CSC=  .  % 3,""S  ) 3,11  S= 2,'8',119  .: D 5

      D 1'"  . :""S C K8:9 ""S C K89  . "O#T!E $   >ame peration perand  SC=  I=- S "  > S "  S- S "

    C CSC=  .  % 3,""S

     ) 3,11  SI>: ,3  S= &,S-

      .  . ""S C K89  .  .

    :REEMAIN

    • eleases t(e acuired *irtual storage

    •  )ddress s(ould be on a double 0ord boundarySyntax

  • 8/18/2019 IBM Assembler mannual.doc

    66/118

    IBM 370 ASSEMBLY LANGUAGE 66 / 118

    >ame "-)I> ,%El*,)Eaddr  egister $orml* %engt( *alue

     ) irtual storage address

    E8!"2le"-)I> ,%E4'&6,)E819>oteO -ore details on "-)I> are a*ailable in t(e c(apter I=)% S=):-)>):->=

    E8!"2le $f ! 2r$gr!" +h!+ */n!"ic!ll/ !c?)ires i+s $r5ing s+$r!ge !n* ini+i!lises i+ i+hc$ns+!n+s fr$" s+!+ic re!* $nl/ s+$r!ge.FIRST CSECT

    FIRST AMOE 31

    FIRST RMOE AN

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    LR 2,1

    GETMAIN R,LV=LEN,LOC=BELOWST 13,4(0,1)

    USING WS,13

    LR 13,1

    LR 1,2

    MVC WS+2(LEN&2),WSCONST+2

    BAL 2,INIT

    LOA EP=A

    LTR 1",1"

    BN9 LOAERR

    LR 1",0

    LA 1,PARM

    BASSM 14,1"

    WTO 'BAC'

    L ",RES

    CV ",W

    UNP MSG+2(1!),W

    OI MSG+1,'F0'

    WTO 'RESULT IS'

    LA 4,MSG

    WTO TET=(4)

    LR 2,13

    L 13,SAVE+4

    FREEMAIN R,LV=LEN,A=(2)

    LM 14,12,12(13)

    LA 1",0BR 14

    LOAERR L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",1!

    BR 14

    WSCONST S 0F

    S 1#F

  • 8/18/2019 IBM Assembler mannual.doc

    67/118

    IBM 370 ASSEMBLY LANGUAGE 67 / 118

      C F'100'

    C F'200'

    S F

    S F

    S F

    S F

    C AL2(1!)S CL1!

    S

    LEN E%U *&WSCONST

    INIT S 0$

    LA 3,A

    ST 3,PARM

    LA 3,B

    ST 3,PARM+4

    LA 3,RES

    ST 3,PARM+#

    BR 2

    WS SECTSAVE S 1#F

    A S F

    B S F

    RES S F

    PARM S F

    S F

    S F

    MSG S AL2

    S CL1!

    W S

    EN

    A CSECT

    STM 14,12,12(13)

    BALR 12,0

      USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    LR 2,1

    WTO 'IN A'

    LR 1,2

    LM 2,4,0(1)

    L ",0(0,2)

    A ",0(0,3)

    ST ",0(0,4)

    WTO 'EITING A'

    L 13,SAVE+4

    LM 14,12,12(13)

    LA 1",0

    BSM 0,14

    SAVE S 1#F

    EN

  • 8/18/2019 IBM Assembler mannual.doc

    68/118

    IBM 370 ASSEMBLY LANGUAGE 68 / 118

    (r$gr!" M!n!ge"en+LOA

    • Brings t(e load module into *irtual storage

    • -odule contains program or table

    • laced abo*e or belo0 line

    • eturns

    ⇒  )ut(orisation code⇒ %engt( o$ t(e module

    ⇒ ntry point to t(e module

    ⇒  )- o$ t(e module

    • Control is not passed to t(e module

    • sed in dynamic subroutine call

    • M+- ca) b- a.-

    >ame %) Eentry namen return to caller t(e registers contain t(e $ollo0ing' ntry point address o$ reuested load module. =(e (ig( order bit re$lects t(e load mod

     )- 81 $or 31 bit )-, else ' $or 24 bit )-9.I$ )- is any t(en t(e bit re$lects callers )-.

    15 Lero i$ no error, else reason code

    E8!"2le%) E-J:%= 15,15B>L % 15,' stic to using register 15 $or entry pointBSS- 14,15 BSS- taes care o$ s0itc( o$ )- i$ red.

     )n important point to note is t(at i$ t(e module (as already been loaded into t(e callers addressspace because o$ a earlier reuest 8 ossibly $rom some async(ronous exit routine9 t(en controlis gi*en to t(e existing copy o$ t(e module. Since 0e branc( to t(e entry point directly, 0e can(a*e a problem i$ t(e module is in use and it is not reentrant or is only serially reusable. "or t(is

    reason DC=% or %I>< is pre$erred as t(e control is passed *ia system 0(ic( c(ecs $or t(ispossible source o$ error. ELE6E

    • emo*e a module $rom *irtual storage

    • ntry name same as used in load macro

    • =as termination remo*es t(e module

    >ame %= Eentry nameegister 15 is Fero on success$ul completion.

    CALL>ame C)%% entryname R 8n9,8parm1,parm2,V.9,%

    !otesControl returns only a$ter called program returns. ence register 15 re$lects return code o$ called progI$ entry name is used, t(e called program gets lin edited into t(e main program 8caller9 at lining tim

    ;C6L

    • =o trans$er control to anot(er module

    • -odule loaded i$ not in *irtual storage

    • andles t(e addressing mode

  • 8/18/2019 IBM Assembler mannual.doc

    69/118

    IBM 370 ASSEMBLY LANGUAGE 6( / 118

    • Control does not return bac

    name DC=% 8reg1,reg29, Eentry name, ))-E8parm1,parm2,V9,%E1,-"E8, user area R 8n99

    >otesO =(e reg1,reg2 indicates t(e registers t(at are to be restored $rom sa*e area be$ore t(ecalled routine gets control . sually coded 82,129. -"E8,ser area9. ser area points to an area0(ere t(e parameter list can be generated .Since t(e trans$er is t(roug( t(e system, t(e systemtaes care o$ t(e )- s0itc( i$ reuired. =(e system also taes care o$ reentrancy o$ t(emodule trans$erred to. Control does not return bac to caller in any case.

    E8!"2le9 DC=% 82,129,E-J:,-"E8,))=)9..

     ))=) C )8)-19C )8)-29

    LIN4

    • =o pass control to an entry point

    • -odule loaded i$ not in *irtual storage

    • andles t(e addressing mode

    • arameter list could be passed

    • Control returns bac

    • rror (andling could be speci$ied

    >ame %I>< Eentry name,))-E8parm1,parm2,V..9,%E1,=Eerrroutine

    Called routine gets control 0it( t(e $ollo0ing *alues in t(e register ⇒ 1 address o$ parameter list

    ⇒ 15 ntry address o$ called program

    I$ t(e lin 0as unsuccess$ul t(e error routine gets control 0it( t(e $ollo0ing⇒ 1 )bend Code t(at 0ould (a*e been issued i$ t(e caller (ad not pro*ided error exit

    ⇒ 212unc(anged

    ⇒ 15 )ddress o$ t(e error exit

    ⇒ 14 used as 0or register by system

    E8!"2le %I>< E-J:,))-E8parm1,parm29,=E

    .

    .)-1 S ")-2 S "

    V

    (r$cess M!n!ge"en+ABEN>ame )B> compcode,)S>E,-,S=

    compcode *alue ' to 4'&5.egister notation 829 to 8129 permitted)S> =(is code is passed to subseuent user exits i$ speci$ied. 32 bit (exadecimal

    *alue or 31 bit decimal number 

  • 8/18/2019 IBM Assembler mannual.doc

    70/118

    IBM 370 ASSEMBLY LANGUAGE 70 / 118

    - euests a dump o$ *irtual storage assigned to tas. >eeds ??SJS)B>,??SJS- or ??SJS- statement to be present in t(e +C% $or t(e @ob step.S= euests all tass associated 0it( t(is +ob step o$ 0(ic( t(is tas is a part to abend

    A66ACH

    • =o create a ne0 tas

    >e0 tas is t(e subtas• arameter list could be passed

    • CB can be pro*ided

    • %imit priority same as t(at o$ t(e creating tas

    • ispatc(ing priority same as t(at o$ t(e creating tas

    • se =)C macro to remo*e t(e sub tas

    • eturns =CB address in reg 1>ame )==)C Eentry name,

    ))-E8parm1,parm2,V9,%E1,CBEecb addr,D=E)ddress o$ end o$ tas routine

    "egisters on entry  to subtas are⇒ ' sed as 0or area by system

    ⇒ 1 sed by macro to point to parameter list

    ⇒ 212 sed as 0or regs by System

    ⇒ 13 S(ould point to a 1#" sa*e area in callers module

    ⇒ 14 eturn address. Bit ' is ' i$ subtas gets control in 24 bit mode else 1 i$ subtasgets control in 31 bit mode

    ⇒ 15 ntry point address o$ subtas

    "egisters on return to caller a$ter issue o$ )==)C⇒ 1 address o$ =CB o$ subtas

    ⇒ 15 ) return code o$ non Fero means subtas could not be attac(ed

    Load Libraries searched are

    ⇒ +ob pac area

    ⇒ euesting tass tas library and all uniue tas libraries o$ parent tass

    ⇒ Step library

    ⇒ +ob library

    ⇒ %in ac area

    ⇒ %in %ibrary

    In simplest $orm usage can be O )==)C E:1,CBECB1

    CB1 S "!otes1-

    • =(is macro creates a separate t(read o$ execution in callers address space• 7it(in t(e )ddress space t(is subtas 0ill compete $or processor resources

    19 =(ere is a despatc(ing priority $or address space29 )t a lo0er le*el t(ere is a despatc(ing priority $or t(e subtass

    • =(e attac(ing tas (as to 0ait $or subtass to end be$ore terminating else it 0ill abend 0(enattempting to terminate

    • =(e attac(ing tas (as to 0ait on t(e CB 0(ic( is posted by t(e system 0(en t(e subtasends

    • =(e attac(ing tas t(en issues a =)C macro.

  • 8/18/2019 IBM Assembler mannual.doc

    71/118

    IBM 370 ASSEMBLY LANGUAGE 71 / 118

    • D= exit routine gets control 0it( t(e $ollo0ing register *alues

    ⇒ ' used as a 0or register by t(e system

    ⇒ 1 )ddress o$ =CB o$ subtas. >eeded $or issuing =)C macro

    ⇒ 2127or registers

    ⇒ 13 1#" sa*e area pro*ided by system

    ⇒ 14 return address

    ⇒ 15 entry point o$ exit routine

    E6ACH

    • emo*es a subtas

    • I$ issued be$ore tas completion, terminate t(e tas

    • S(ould be issued i$ CB or =D is used in )==)C

    • emo*ing a tas remo*es all its dependent tass also

    • I$ CB or =D is used, and t(e parent tas does not issue =)C, t(en t(eparent tas 0ill abend

    >ame =)C tcb address R 8n9

    perand can be in register notation in 0(ic( case regs 1 t(ru 12 may be used.=(e =CB address s(ould (a*e been pre*iously obtained by D= exit routine

    E8!"2le )==)C E:1,D=E>"=S<%= 15,15B>L S= 1,=CB1 sa*e address o$ =CB $or later use..

    =CB1 C ";';>"=S< =)C 819

    B 14

    @AI6• 7ait $or completion o$ e*ents

    • Initialise t(e CB be$ore calling

    •  ) list o$ CBs can be speci$ied $or 0aiting on any number o$ e*ents

    E8!"2le $f MAIN cre!+ing +$ s)#+!s5s 6AS41 !n* 6AS4,FIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    WTO 'MAIN1 STARTING'

    ATTAC$ EP=TAS1,ECB=ECB1

    LTR 1",1"

    BN9 ERROR1

    ST 1,TCB1

    ATTAC$ EP=TAS2,ECB=ECB2

  • 8/18/2019 IBM Assembler mannual.doc

    72/118

    IBM 370 ASSEMBLY LANGUAGE 72 / 118

      LTR 1",1"

    BN9 ERROR2

    ST 1,TCB2

    WTO 'MAIN1 ENTERING WAIT FOR TAS1 COMPLETION'

    WAIT ECB=ECB1

    WTO 'MAIN1 ENTERING WAIT FOR TAS2 COMPLETION'

    WAIT ECB=ECB2LA 4,TCB1

    ETAC$ (4)

    LA 4,TCB2

    ETAC$ (4)

    L 13,SAVE+4

    RETURN (14,12),,RC=0

    ERROR1 L 13,SAVE+4

    RETURN (14,12),,RC=4

    ERROR2 L 13,SAVE+4

    RETURN (14,12),,RC=#

    SAVE S 1#F

    ECB1 C F'0'ECB2 C F'0'

    TCB1 S F

    TCB2 S F

    EN

    TAS1 CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    LA ","0

    LOOP WTO 'TAS1 REPORTING'

    BCT ",LOOP

    L 13,SAVE+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    EN

    TAS2 CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    LA 13,SAVE

    LA ","0

    LOOP WTO 'TAS2 REPORTING'

    BCT ",LOOP

    L 13,SAVE+4

    LM 14,12,12(13)

  • 8/18/2019 IBM Assembler mannual.doc

    73/118

    IBM 370 ASSEMBLY LANGUAGE 73 / 118

      SR 1",1"

    BR 14

    SAVE S 1#F

    EN

    RE6URN

    >ame => 8reg1,reg29,=,CEretcoderestores reg1 to reg2 $rom sa*e area pointed by 13= sets a $lag in t(e sa*e area in t(e called program $or dump analysis i$ reuired-aximum *alue $or return code is 4'&5 0(ic( is set in 15>see e8!"2le $f i"2le"en+!+i$n )n*er MACROS !n* c$n*i+i$n!l !sse"#l/

    SA%E>ame S) 8reg1,reg29Sa*es reg1 t(ru reg2 in sa*e area pointed to by 13>see e8!"2le $f i"2le"en+!+i$n )n*er MACROS !n* c$n*i+i$n!l !sse"#l/

    REEN6ERABILI6Y"or load modules 0(ic( may be s(ared amongst more t(an one concurrent tas, reentrancy is

    important. -ost macros 8in standard $orm9 generate an inline parameter list o$ data areas0(ic( are used $or passing as 0ell as recei*ing in$ormation $rom t(e macro call. b*iously inlineparameter list maes t(e load module non reentrant and at best serially reentrant.

    "or t(is reason to mae a load module reentrant, do not de$ine data areas in t(e program 0(ic(0ill be part o$ t(e load module. Instead at run time 8using :=-)I> or S=): B=)I>9 todynamically acuire storage. ) typical example o$ t(is 0ould be to acuire t(e 1# $ull 0ord sa*earea dynamically. 7(ere t(e acuired area needs to be accessed by $ield you can use a SC=to $ormat t(e bloc o$ storage.

     )s $or -)CS IB- pro*ides, apart $rom standard $orm 0(ic( de*elops inline parameter lists,LIS6 and E;ECU6E >M:L $r M:E  $orm o$ t(e macro exist. =(e list $orm does not generateany executable code. Instead it generates only a parameter list. )t run time you acuire storage

    eui*alent in siFe to t(is list and copy t(e list to t(is area. =(is 0ay eac( t(read o$ execution 0ill(a*e it;s o0n discrete parameter area. )t run time use t(e execute $or o$ t(e macro 80(ic( canalso be used to c(ange some o$ t(e parameters generated earlier9 0it( a pointer to t(eparameter list built up in *irtual storage.

    =(e list $orm o$ t(e macro is signalled to t(e assembler by t(e parameter -"E%=(e execute $orm is signalled to t(e assembler by using t(e parameter -"E

    E8!"2le..%) 3,-)C>)- load address o$ t(e list generated%) 5,>SI) load address o$ end o$ listS 5,3 :5 0ill no0 (a*e lengt( o$ list

    B)% 14,-=> go to rtn to mo*e listK ,-"E8,8199 :1 points to parm list, execute $orm.. processing (ere.B 14

    A acuire storage su$$icient to (old t(e list-=> :=-)I> ,%E859

    % 4,1 address o$ area in gpr4

  • 8/18/2019 IBM Assembler mannual.doc

    74/118

    IBM 370 ASSEMBLY LANGUAGE 74 / 118

    BC= 5,' subtract 1 $rom gpr5D 5,-I>S=B 14

    -I>S= -C '8',49,'839 c(ange t(e lengt( $ield and copy t(e list-)C>)- K 8>)-1,>)-2,#,SJS=-9,=E),-"E%>SI) K A>)-1 C C%#;-)+;>)-2 C C%#;-I>;

     E8!"2le )sing @6OFIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    ST 13,SAVE+4

    GETMAIN R,LV=LMSG

    LR 2,1

    LA 3,MSG

    LA 4,LMSG

    BCTR 4,0E 4,MV

    WTO ,MF=(E,(2))

    LA 13,SAVE

    L 13,SAVE+4

    LM 14,12,12(13)

    SR 1",1"

    BR 14

    SAVE S 1#F

    MV MVC 0(0,2),0(3)

    MSG WTO 'T$IS IS T$E MESSAGE',MF=L

    LMSG E%U *&MSG

    EN

    Reen+r!nc/ !n* ri+!#le s+$r!geFIRST CSECT

    STM 14,12,12(13)

    BALR 12,0

    USING *,12

    LR 2,1

    GETMAIN R,LV=WSLENGT$,LOC=BELOW

    USING WS,1

    ST 13,SAVE+4

    LA 13,SAVE

    ROP 1

    LR 13,1LR 1,2

    USING WS,13

    WTO 'ASM1 REPORTING'

    MVC MSG+2(!),=C'ABCEF'

    LA !,!

    ST$ !,MSG

    LA !,MSG

    WTO TET=(!)

  • 8/18/2019 IBM Assembler mannual.doc

    75/118

    IBM 370 ASSEMBLY LANGUAGE 75 / 118

      LA 1",4

    LR 2,13

    L 13,SAVE+4

    FREEMAIN R,LV=WSLENGT$,A=(2)

    L 14,12(0,13)

    LM 0,12,20(13)

    BR 14WS SECT

    SAVE S 1#F

    MSG S AL2

    S CL100

    WSLENGT$ E%U *&WS

    EN

  • 8/18/2019 IBM Assembler mannual.doc

    76/118

    IBM 370 ASSEMBLY LANGUAGE 76 / 118

    ACCESSING %SAM A6A SE6S USING ASSEMBLER LANGUAGE  back 

    M!cr$sN!"e ACB AM%SAM'

    BU:N'BU:NI'BU:S('NAME'

      MACR:>ARJ''CN%J'4EYJ'IRJ'SEJ'S4(J'INJ'OU6J E;LS6'(ASS@'

    !OTES1 )- O )l0ays code S)- $or access to S)- data setsB"> O >umber o$ data bu$$ers, de$aultE2,o*erride possible t(roug( +C%B">I O >umber o$ Index bu$$ers, de$aultE1,o*erride possible t(roug( +C%B"S O SiFe o$ area $or Index and ata Bu$$ers. e$aults to speci