The pieces of an ASSEMBLER program
The CSECT statement
Format 1: label CSECT
Format 2: label CSECT , comment
The END statement
Format: END label
Defines the end of what should be assembled.
Last line of an assembler program.
label is usually label on the main or 1st CSECT. If specified, then the CSECT named label is the entry point of the program.
Last line of EXECUTABLE code:
BCR B’1111’,14
Linkage Conventions:
On entry to an assembler program, R15 contains the address of the entry point (ie. the beginning of the program). R15 may be used as a base register.
On entry to an assembler program, R14 contains the return address, which is an address in the operating system to branch to when the program is finished.
A sample ASSEMBLER program:
Address Code to execute 000000 EXMPL1 CSECT 000000 L 5,24(,15) 000004 A 5,28(,15) 000008 ST 5,36(,15) 00000C L 4,32(,15) 000010 SR 4,5 000012 ST 4,40(,15) 000016 BCR B’1111’,14 000018 NUM1 DC F’15’ 00001C NUM2 DC F’7’ 000020 NUM3 DC F’8’ 000024 RESULT1 DS F 000028 RESULT2 DS F END EXMPL1
Wouldn’t it have been nice to be able to use the labels NUM1, NUM2, etc...?
Implicit Addressing
Implicit address – an address that the assembler will be required to convert to an explicit address
Use a label (usually on a DC or DS in storage) rather than a D(B) or D(X,B) address when coding an instruction
Format 1: label
Format 2: label+n -- where n is a decimal displacement
Format 3: label(R) -- where R is the # of the index register
Format 4: label+n(R) -- where n is decimal displacement, R is index reg
Must first establish addressibility (supply the assembler with the base address) with the USING statement.
Format: USING label,R
R – register # that contains a valid base address
label – label in the program that corresponds to base address in R
USING does not take up any space.
A revised sample ASSEMBLER program:
Address Code to execute 000000 EXMPL1 CSECT 000000 USING EXMPL1,15 000000 L 5,NUM1 000004 A 5,NUM2 000008 ST 5,RESULT1 00000C L 4,NUM3 000010 SR 4,5 000012 ST 4,RESULT2 000016 BCR B’1111’,14 000018 NUM1 DC F’15’ 00001C NUM2 DC F’7’ 000020 NUM3 DC F’8’ 000024 RESULT1 DS F 000028 RESULT2 DS F END EXMPL1