, 1. GENERAL INFORMATION AND PROGRAMMING HINTS HARDWAR1 DESCRIPTION OF DEVICES, PSU 360/67 OSHASP DESCRIPTION OF OS/360 AND HASP WORKINGS ASPRGTC1 S/360 ASSEMBLER PROG. TECHNIQUES AND MODULARITY DOCUMENT S/360 DOCUMENTATION HINTS LINKAGE S/360 LINKAGE CONVENTIONS DSECT S/360 DSECT EXAMPLE CS102M1 S/360 OPCODE FAMILIES AND NAMING STRUCTURE 2. SPECIFIC COURSE MATERIALS CS102TPA PARTIAL OUTLINE OF INTRO. ASSEMBLER COURSE CS102HN HANDOUT LIST FOR INTRO ASSEMBLER COURSE CS102AS1 ASSIGNMENTS FOR INTRO. ASSEMBLER COURSE CS102FP1,2,J FINAL PROJECT AND TEST DECKS CS411TPA PARTIAL OUTLINE OF SYSTEMS COURSE CS411HN HANDOUT LIST FOR ABOVE CS411GI1 GENERAL INFORMATION FOR ABOVE DUMPSJCL, DUMPTEST INITIAL DUMP INTRODUCTION CS411AS1 ASSIGNMENTS FOR SYSTEMS COURSE CS411MC1 MACRO ASSIGNMENTS FOR SYSTEMS CS411MC2 COURSE CS411FP1, 2, 3, 4, I, J, K SYSTEMS COURSE FINAL PROJECT AND TEST DECKS 3. SAMPLE PROGRAMS FLOTLINK FLOATING PT. FORTRAN/ASSEMBLER LINKAGE EXCP EXAMPLE OF A CHANNEL PROGRAM BSAM BSAM I/O EXAMPLE BPAM BPAM I/O EXAMPLE QSAM QSAM I/O EXAMPLE OVLY1 OVERLAY STRUCTURE EXAMPLE PTPCHMAC BPAM/IBM UTILITY EXAMPLE , 00001000 HARDWAR1 - 01 00001010 FEB 1972 00001020 PENN STATE UNIVERSITY COMPUTATION CENTER 00001030 360/67 CONFIGURATION 00001040 this writeup: pages 01 - 04, plus Diagram A (separate). 00001050 00001060 INTRODUCTION 00001070 00001080 This writeup briefly describes the devices included in the PSU 00001090 360/67 system, and shows how they are connected together. Each device 00001100 is described below, and diagram A shows the connections. 00001110 00001120 References are made to DEVICE ADDRESSES. Each individually 00001130 addressable device (such as a single disk drive, card reader, etc) has 00001140 a 3 digit (hexadecimal) number which uniquely identifies it to the 00001150 system, and is used in all input/output operations. The DEVICE ADDRESS 00001160 is of the following form: 00001170 00001180 abc where: 00001190 a gives the CHANNEL NUMBER (from 0 up) 00001200 b specifies a CONTROL UNIT attached to that channel 00001210 c notes which device attached to a given control unit. 00001220 00001230 Since each digit can have the value 0-F, theoretically it would be 00001240 possible to attach 16 devices to each of 16 control units attached to 00001250 16 channels, for a maximum of 4096 separate devices. In practice, this 00001260 number is much less, since most S/360's allow a MAXIMUM of 7 channels or00001270 less. 00001280 00001290 The devices follow, more or less in order from the CPU outward. 00001300 00001310 CENTRAL PROCESSING UNIT 00001320 00001330 2067-1 (a single 360/67 CPU). uses 200 nanosec (.2 microsec) cycle 00001340 Read Only Storage (ROS) of 88 bits/word to implement S/360 00001350 instruction set (Universal plus special model 67 instructions)00001360 includes a HIGH RESOLUTION TIMER (13 microsec cycle). 00001370 includes a BCU (Bus Control Unit), which is connected to all 00001380 memory modules, and determines which channel or CPU gets to 00001390 use a given memory module. 00001400 00001410 PRIMARY STORAGE 00001420 00001430 2365 III (4 units) each unit contains 256K bytes. Physically each 00001440 2365 contains 2 arrays of 128K bytes, with physical word size 00001450 of doublewords, i.e., each has 2 arrays of 16K doublewords, 00001460 and is thus 2-way interleaved at this level. Each 2365 is 00001470 independent of the others. 00001480 CYCLE TIME: 750 nanosec / ACCESS TIME: 375 nanosec 00001490 00001500 2361 II (1 unit) - Large Core Storage (LCS) - 2048K bytes, organized 00001510 physically of 2-way interleaved doublewords. 00001520 CYCLE TIME: 8000 nanosec (8 microsec) / ACCESS TIME: 3.2 mic 00001530 00001540 Of the two types of storage, the first contains user programs, and 00001550 heavily used parts of system programs, while the LCS contains less-used 00001560 system programs, tables, and buffer areas. 00001570 , 00002000 HARDWAR1 - 02 00002010 00002020 CHANNELS 00002030 00002040 2870 MULTIPLEXOR CHANNEL - includes 2 SELECTOR SUBCHANNELS (used 00002050 for magnetic tape drives). generally handles LOW-SPEED 00002060 devices (card readers, printers, etc) 00002070 MAXIMUM TOTAL TRANSFER RATE: 426 KB (kilobytes) per second 00002080 00002090 2860 SELECTOR CHANNELS - 5 total (2 in 2860 II, 3 in 2860 III). 00002100 used for HIGH-SPEED devices (disk, drum, etc) 00002110 MAXIMUM DATA TRANSFER UNIT, EACH SELECTOR: 1250KB 00002120 00002130 All CHANNELS and the CPU contend for use of memory modules. The 00002140 BCU arbitrates among them using a simple priority scheme in following 00002150 order: 00002160 00002170 SERVED EARLIER ---> SERVED LATER 00002180 CHANNEL # : 1 2 0 3 4 5 CPU 00002190 drums disk mx disk disk ADAGE 00002200 00002205 The above order is used since the drums cannot wait very long and 00002210 have the highest transfer rate, the multiplexor channel (0) is fairly 00002220 early because it may have a large number of things to do, and the CPU 00002230 is always last because it never hurts it to wait. 00002240 00002250 00002260 00002270 CONTROL UNITS 00002280 00002290 Each control unit can attach to a number of devices, and it is used00002300 to control greatly different devices in a such a way as to make them 00002310 appear more alike, as far as the channels are concerned. Each device 00002320 must be attached to a particular type of control unit, and each control 00002330 unit normally can control a group of related devices. 00002340 00002350 2820 STORAGE CONTROL UNIT - controls the 2301 drum units, attached 00002360 to channel 1 . 00002370 00002380 2821 CONTROL UNIT - controls UNIT RECORD devices (card readers, 00002390 printers, punches). attached to multiplexor channel. 00002400 00002410 2848 DISPLAY CONTROL - controls the 8 2260 scopes which display 00002420 system status to the operators. 00002430 00002440 2701 DATA ADAPTOR - controls a small number of high-speed 00002450 transmission lines, i.e. high speed terminals (4800 bits/sec 00002460 transmit rate), such as 360/20's at various locations. 00002470 00002480 2703 TRANSMISSION CONTROL - controls a larger number of lower- 00002490 speed terminals, including typewriter/teletype terminals and 00002500 read/print/punch terminals at Commonwealth Campuses (such as 00002510 IBM 2780, DCS CP-4, etc). 00002520 , 00003000 HARDWAR1 - 03 00003010 00003020 DISPLAY DEVICES 00003030 00003040 1052 CONSOLE TYPEWRITER - messages are printed here requiring 00003050 action by computer operators, and they can enter commands 00003060 to the system at this location. 00003070 00003080 2260 ALPHAMERIC DISPLAY SCOPES (8 units) - these display current 00003090 system status (jobs, disk usage, etc), and also are used to 00003100 display requests for magnetic tapes to be mounted, etc. 00003110 00003120 00003130 SECONDARY STORAGE - DIRECT ACCESS STORAGE DEVICES (DASDs) 00003140 00003150 2301 MAGNETIC DRUMS (2 drums) - attached to channel 1 via 2820. 00003160 Each holds 4.09 megabytes (million bytes) of data, rotates 00003170 once each 17.5 milliseconds, with average rotational delay 00003180 (latency time) of 8.6 milliseconds. Records data 4 bits in 00003190 parallel (for high transfer rate). Has 200 conceptual TRACKS,00003200 each of 20,483 bytes maximum size. EACH DRUM IS UNREMOVABLE. 00003210 MAXIMUM TRANSFER RATE: 1.2 megabytes/second (FASTEST DEVICES 00003220 USED ON THIS SYSTEM). 00003230 These hold most heavily-used compilers and system programs. 00003240 00003250 231x (2314, 2319) MAGNETIC DISK STORAGE FACILITIES - total of 22 00003260 disk drives (including 2 spare ones). Each DRIVE holds one 00003270 2316 DISK PACK: 29.17 megabytes maximum, on 20 disk surfaces 00003280 (11 plates - outside ones not used). Uses MOVABLE HEADS 00003290 to access information. Each CYLINDER (of which there are 200 00003300 usable at any one time) contains the 20 TRACKS accessible at 00003310 one time without moving the READ/WRITE HEADS. Each track can 00003320 record at most 7294 bytes of information. 00003330 NOTE: unlike drums, each DISK PACK can be removed, and another00003335 one mounted in is place if desired. 00003337 ROTATION TIME: 25 millisec, AVERAGE LATENCY: 12.5 millisec. 00003340 SEEK TIMES (time to move HEADS to correct cylinder): 00003350 MIN = 25, AVERAGE = 60 or 75, MAX = 130 or 135 millisec. 00003360 MAXIMUM DATA TRANSFER RATE: 312,000 bytes/sec. 00003370 00003380 NOTE: each of the three storage facilities contains its own 00003390 control unit, and each drive is numbered accordingly, i.e., 00003400 230-237, 330-337, 430-433, on channels 2, 3, 4. 00003410 00003420 TOTAL DASD STORAGE IS AS FOLLOWS: 00003430 2314 (8 drv) 233 megabytes 00003440 2319 (8 drv) 233 megabytes 00003450 2314 (4 drv) 116 megabytes 00003460 2301 (2 drums) 8 megabytes 00003470 -------------- --- --------- 00003480 *TOTAL* 590 megabytes (approx) 00003490 , 00004000 HARDWAR1 - 04 00004010 00004020 SECONDARY STORAGE - SEQUENTIAL DEVICES 00004030 00004040 240x (2402 III, 2403 III) MAGNETIC TAPE DRIVES - read/write tape 00004050 at maximum density of 800 BPI (bits/inch), 9 tracks per tape 00004060 (2 of the drives also read/write 7-track tapes). Each group 00004070 of 4 drives is connected to one SELECTOR SUBCHANNEL of the 00004080 MULTIPLEXOR CHANNEL. The control units for these drives are 00004090 contained in the 2403 units. 00004100 MAXIMUM TRANSFER RATE: 90,000 bytes/sec (90KB), using tape 00004110 speed of 112.5 inches per second, tape gaps of .6 inch between00004120 blocks of data. 00004130 00004140 00004150 UNIT RECORD DEVICES 00004160 00004170 1403 LINE PRINTERS (of various models), printing with maximum rated00004180 speed of 1100 lpm (lines/minute) for 1403 N1, 600 lpm for 00004190 others. Use removable TRAINs, so that different character 00004200 sets can be obtained (upper case only: QN, upper/lower: TN). 00004210 Attached to 2821 control units (on multiplexor). 00004220 00004230 2540 CARD READ/PUNCH - one unit contains a card reader and card 00004240 punch (treated logically as separate addresses: for example: 00004250 00C for reader, 00D for attached punch). 00004260 READS cards (optically) at 1000 cpm (cards/minute) maximum. 00004270 PUNCHES cards at 300 cpm maximum. 00004280 Attached to 2821 control unit. 00004285 00004290 2671 PAPER TAPE READER - reads punched paper tape at up to 1000 cps00004300 (characters per second). attached also to 2821 control unit. 00004310 00004320 00004330 SUMMARY OF DEVICE CHARACTERISTICS 00004340 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00004350 DEVICE CAPACITY PER UNIT TRANSFER RATE AVERAGE DELAY 00004360 TYPE (megabytes) (KB/second) (seek) (latency) ms. 00004370 ---- ----- ------ ------ --------- 00004380 00004390 2301 DRUM 4.09 1200 0 8.6 00004400 00004410 2319 DISK 29.17 per pack 312 60 12.5 00004420 2314 DISK 29.17 per pack 312 75 12.5 00004430 00004440 2400 TAPE DRIVE varies, 20 per 90 - - 00004450 2400-ft tape OK 00004460 00004470 1403 PRINTER 132 bytes/line 2.4 - - 00004480 2540 READER 80 bytes/card 1.3 - - 00004490 2540 PUNCH 80 bytes/card 0.4 - - 00004500 2671 PAPER TAPE -- 1.0 - - 00004510 00004530 REFERENCES: GA22-6810 IBM S/360 SYSTEM SUMMARY 00004540 GA27-2719 IBM S/360 MODEL 67 FUNCTIONAL CHARACTERISTICS 00004550 , 00001000 OSHASP - 01 00001010 00001020 OVERVIEW OF OS/360 WITH HASP 00001030 00001040 This writeup gives a quick overview of the process by which any 00001050 OS/360 sytstem is initialized, how storage is used (particularly in 00001060 OS/360/MVT), and describes how OS/360 is modified by the use of HASP 00001070 (Houston Automatic Spooling Priority system). The storage layout is 00001080 described for the PSU CC 360/67 system. 00001090 00001100 I. INITIALIZATION - getting a system up and running 00001110 00001120 Consider a computer with no operating system currently in it. The 00001130 first necessity is to get a workable operating system in it, so that 00001140 jobs can be run. This is NOT a trivial process: note that there is no 00001150 Program Fetch resident in the machine, no I/O Access Method routines, 00001160 and not even a correct set of PSW's in low core for directing interrupt 00001170 actions. 00001180 00001190 For OS/360, the initialization process is composed of two parts: 00001200 IPL and NIP. IPL (Initial Program Loader) initializes memory and some 00001210 other things, and brings the NUCLEUS (the core of the OS) into memory. 00001220 NIP (Nucleus Initialization Program) performs the remaining actions 00001230 required to set up a specific NUCLEUS to be ready to execute. 00001240 00001250 A. IPL - Initial Program Loader 00001260 00001270 The process of getting an OS/360 system running is called IPLing, 00001280 and includes the following main steps: 00001290 00001300 1. The operator makes sure the disk pack called SYSRES (SYStems 00001310 RESidence) is mounted on a disk drive. The LOAD UNIT switches are set 00001320 to show the device address of the SYSRES disk pack, and the LOAD button 00001330 pressed. This causes the CONTROL RECORD to be read from the first 00001340 record on the disk pack, consisting of a PSW and two CCW's, placed at 00001350 location 0 in memory. Execution of this record causes the IPL 00001360 BOOTSTRAP record to be read into memory. The BOOTSTRAP record consists 00001370 of a set of CCW's which are used to read the IPL program into memory, 00001380 beginning at location 0. It ends with a LPSW to give control to the 00001390 IPL program. 00001400 00001410 2. IPL selects which NUCLEUS will be loaded (there may be a choice 00001420 which can be given by switches on the operator console). 00001430 00001440 3. IPL clears all memory above itself to zeroes, also obtaining 00001450 the size of memory; i.e., it stores until addressing interrupt occurs. 00001460 00001470 4. IPL clears the floating point registers, thus finding out if 00001480 the floating point feature is installed. 00001490 00001500 5. IPL brings the NUCLEUS into memory. First, it relocates the 00001510 part of itself not yet executed into high memory (near 252K), so that 00001520 the NUCLEUS can be placed beginning at 0. It then simulates Program 00001530 Fetch, loading the csects of the NUCLEUS load module into memory. The 00001540 first csect loaded is the NIP, loaded just below IPL, followed by the 00001550 I/O Interrupt Handler at 0 (which thus defines all of the special PSW's 00001560 in low core). IPL then passes control to NIP. 00001570 , 00002000 OSHASP - 02 00002010 00002020 B. NIP - Nucleus Initialization Program 00002030 00002040 The IPL process described above applies to all versions of OS/360. 00002050 The NIP is generated in different ways, depending on the specific type 00002060 of system and choice of options desired. Note: NIP is a csect which is 00002070 link-edited with the nucleus, so that it can refer to sections of the 00002080 nucleus via address constants, and provide efficient and specific 00002090 initialization services. It includes the following steps: 00002100 00002110 1. The CVT (Communications Vector TAble) is initialized, and its 00002120 location placed at location 16, so that it can be accessed from any 00002130 routine, whether part of the nucleus or not. 00002140 00002150 2. NIP determines whether the computer has Large Core Storage (LCS)00002160 attached to it or not. This is particularly necessary for those 00002170 systems which include HIARCHY SUPPORT, i.e., the ability to usefully 00002180 distinguish between main core and LCS, perhaps splitting programs into 00002190 heavily-used and lesser-used sections. 00002200 00002210 3. NIP checks the workability of operator console(s), and also 00002220 checks the workability of ready direct-access devices (using TIO 00002230 instructions). It particularly checks that the SYSRES volume is mounted00002240 and contains certain datasets needed by the system. 00002250 00002260 4. NIP performs various housekeeping actions, such as checking and 00002270 setting the timer to make sure it is working correctly, initializing 00002280 some pointers for storage management, initializing the SVC table (which 00002290 gives a pointer to each routine associated with a defined SVC number). 00002300 It also sets up to be able to obtain modules from the SYS1.LINKLIB, 00002310 which contains the heaviest-used load modules for the system, and also 00002320 establishes communications with the operator. 00002330 00002340 5. For any system having one, NIP loads reentrant modules into the 00002350 LINK PACK. These modules can be used during following execution, and 00002360 are located at the high end of memory. In a system with fast core+LCS, 00002370 the LINK PACK can be split, residing at both the high end of fast core 00002380 and the high end of LCS. 00002390 00002400 6. With the addition of various other miscellaneous operations, 00002410 NIP prepares a REGION which will contain the MASTER SCHEDULER, which is 00002420 the program doing overall job scheduling and operator communication. 00002430 It then can pass control (LINK or XCTL) to the MASTER SCHEDULER, and 00002440 the system is finally ready to run jobs. 00002450 00002460 At this point, memory layout (fast core only) is as follows: 00002470 00002480 HIGH ADDRESS LINK PACK (reentrant modules) 00002490 MS (MASTER SCHEDULER) 00002500 FREE AREA (dynamic for problem programs) 00002510 SQS (SYSTEM QUEU SPACE) (contains space for system 00002520 control blocks - TCB's, etc) 00002530 LOW ADDRESS NUCLEUS 00002540 00002550 NOTE: in systems with HIARCHY SUPPORT, FREE AREA, MS, and 00002560 LINK PACK would also have areas in LCS. 00002570 , 00003000 OSHASP - 03 00003010 00003020 II. RUNNING JOBS IN AN OS/360 SYSTEM 00003030 00003040 This section describes how jobs are run in a standard OS/360 00003050 system, using either OS-MFT or OS-MVT. Note that OS-PCP runs jobs 00003060 one at a time (sequential scheduling, uniprogramming), with no SPOOLing 00003070 of jobs to and from disk before and after execution. OS-MFT and OS-MVT 00003080 are generally similiar in that they both can SPOOL input onto DASD, 00003090 execute jobs in priority order, and write the output out later. The 00003100 main difference is in the handling of storage, in which OS-MVT is much 00003110 more dynamic. Note that all scheduling of jobs and communication with 00003120 the operator is effectively under the control of the MASTER SCHEDULER. 00003130 00003140 A. READING INPUT STREAMS 00003150 00003160 For each existing input stream (card reader, or input on tape), 00003170 the operator can issue a START RDR command. This causes a copy of the 00003180 READER/INTERPRETER program (referred to herafter as a RDR) to read 00003190 cardimages from the requested input device. 00003200 00003210 During its operation, a RDR reads an input stream, scans JCL cards 00003220 and converts them to a standard internal text form, and also obtains 00003230 cataloged procedure definitions from the procedure library (PROCLIB). 00003240 From the internal text, it builds INPUT QUEUE entries, representing 00003250 the information on the user JCL cards. It also writes any input data 00003260 cards onto disk, while placing pointers to the data into the INPUT 00003270 QUEUE entries so that it can be found later. The job's INPUT QUEUE 00003280 entry is enqueued in priority order with other jobs awaiting execution. 00003290 00003300 When all of the cards for a job have been read, it has in effect 00003310 been split up into the following: 00003320 1. INPUT QUEUE ENTRIES, in priority order, in a special system data00003340 set used only for work queue entries, referred to as SYSJOBQUE. 00003350 2. INPUT STREAM DATA SETS, placed on DASD, using normal OS/360 00003370 Direct Access Device Storage Management (DADSM) routines. NOTE: DADSM 00003380 routines are themselves kept on DASD, nonresident, and allocating disk 00003390 space often requires a fair number of accesses to disk to look for free 00003400 space on one, and to allocate the space appropriately. The DADSM 00003410 routines are quite general and powerful, but also create some overhead. 00003420 00003430 B. INITIATING JOB STEPS 00003440 00003450 The operator may START one or more INITIATORs, each of which can 00003460 initiate jobs from one or more classes(categories) of jobs. Each 00003470 initiator will then attempt to initiate the highest priority job from 00003480 the first class of jobs which has a ready job. If there are no jobs 00003490 awaiting execution in its allowed classes, it WAITs for one to become 00003500 available. Note that it essentially removes input queue entries from 00003510 SYSJOBQUE. Like every RDR, each INITIATOR is executed as a separate 00003520 task. (INITIATOR may be abbreviated INIT). 00003530 , 00004000 OSHASP - 04 00004010 00004020 When an allowable job becomes available, the initiator obtains 00004030 a REGION for the job (from the FREE area, also called the DYNAMIC area),00004040 uses the information from the RDR to allocate DASD storage, tape drives,00004050 and other I/O devices. It then ATTACHes the first module of the program00004060 to be executed (thus creating the JOB STEP TASK), and WAITs until the 00004070 job step completes. 00004080 00004090 When a job step is finished, the TERMINATOR (part of the INITIATOR 00004100 really, so that the whole unit is called an INITIATOR-TERMINATOR) 00004110 effectively cleans up, performing disposition of I/O devices (DISP 00004120 parameter in JCL), and releasing the REGION which had been acquired for 00004130 the job step. 00004140 00004150 During this process, job steps are essentially independent, i.e., 00004160 they could require different sizes of regions, and might execute in 00004170 different locations. Note that the INITIATOR-TERMINATOR must also 00004180 control the skipping of steps as controlled by the JCL COND option. 00004190 00004200 During execution, SYSOUT datasets are written to DASD, to be 00004210 printed/punched later. When the last job step of a job completes, 00004220 the INIT creates a work queue entry calling for the job's output to be 00004230 printed/punched. 00004240 00004250 C. WRITING SYSTEM OUTPUT 00004260 00004270 A program called a SYSTEM OUTPUT WRITER (WTR) can be STARTed by 00004280 the operator to transcribe output from DASD to printers or punches, or 00004290 even tapes to be printed/punched later. Output can originally be 00004300 grouped into CLASSes, which can be written according to priority or 00004310 otherwise treated differently as desired. 00004320 00004330 COMMENTS ON THE PROCESS ABOVE 00004340 00004350 The process described above is quite flexible and general. However,00004360 it does require a fair amount of time to set up any job, even a small 00004370 one. As such, it is quite satisfactory for any installation which runs 00004380 jobs which require a fair amount of time, since then the setup time is 00004390 negligible. However, due to the use of OS DADSM for PSPOOLed input and 00004400 output, DASD space can become fragmented, disk head movement can 00004410 become excessive, and much time can be used up allocating and 00004420 deallocating disk space. Although OS/360 is quite reasonable in a 00004430 commercial installation, or in one running a few large jobs, it seems 00004440 to have too much overhead for university or other installations which 00004450 often run many small jobs. For this reason, most larger S/360 computers00004460 (i.e., models 75,67,65, and larger 50's) typically use some method to 00004470 reduce the overhead in running small jobs. All of the methods involve 00004480 'faking out' OS/360 in some aspect or other. The method emphasized here00004490 (which happens to be the most popular one) is HASP (Houston Automatic 00004500 Spooling Priority) system. 00004510 , 00005000 OSHASP - 05 00005010 00005020 III. RUNNING AN OS/360 HASP SYSTEM 00005030 00005040 In any OS/360 system, it is fairly typical to have one or more 00005050 special jobs in the system, which are loaded before normal user jobs. 00005060 and typically remain resident from one IPL to the next. Such jobs may 00005070 control remote batch terminals, timesharing typewriter terminals, or 00005080 provide any other service which the installation desires. Such jobs 00005090 are normally placed into the high-address sections of the FREE area 00005100 (or of the two FREE areas, if the system has both main core plus LCS). 00005110 When HASP is used, it is normally the first job submitted to OS/360, 00005120 and it essentially takes over the system, even though it appears to 00005130 OS/360 as just another job. 00005140 00005150 A. HASP INITIALIZATION 00005160 00005170 There are two possible cases when starting HASP up after an IPL. 00005180 A COLD START occurs when the system is completely empty, i.e., there 00005190 are no jobs already enqueued on disk which can be executed. If there 00005200 are disk packs on the system containing previously-read jobs, the start 00005210 is called a WARM START. A WARM START normally occurs if the system was 00005220 previously taken down on purpose, such as for systems programming, or 00005230 if enough information had been saved previous to a 'crash'. A COLD 00005240 START only occurs when the system crashes badly, and destroys records 00005250 of jobs already SPOOLed onto disk. In this case, the jobs must be read 00005260 in again. 00005270 00005280 When HASP first gains control, it issues a special SVC call, which 00005290 returns to HASP with protect key 0 and supervisor state, also supplying 00005300 HASP with some useful pointers to control blocks in the nucleus. NOTE: 00005310 this special SVC can only be called 1 time, since it locks after its 00005320 first usage after an IPL. 00005330 00005340 UCB's (Unit Control Blocks) exist for every device connected to 00005350 the computer system. HASP now scans these, and essentially allocates to00005360 itself: 00005370 00005380 1. All real unit-record devices (readers, punches, printers). 00005390 00005400 2. All disk packs which have volume label names beginning SPOOL. 00005410 00005420 It also obtains effective control of the operator's console(s), 00005430 plus remote terminals, if any. 00005440 00005450 Finally, HASP modifies the SVC table (which contains pointers to 00005460 the routines which are called for each specific SVC number), so that 00005470 the following ones go into HASP, rather than to the original routines 00005480 (also saving these addresses for later use for itself): 00005490 00005500 SVC 0 (EXCP - all input/output) 00005510 SVC 34 (WTL - write to log) 00005520 SVC 35 (WTO, WTOR - write to operator, with/withput reply) 00005530 , 00006000 OSHASP - 06 00006010 00006020 B. RUNNING NORMAL USER JOBS UNDER OS/360 WITH HASP 00006030 00006040 1. Input Stage - HASP continually reads cards from whatever card 00006050 readers are active in the system. It checks for JOB cards, performs 00006060 various accounting checks on input jobs, and transcribes the jobs to 00006070 disk. In this stage, each job is split up into two sections: the JCL 00006080 cards (with certain modifications), and the input data cards. It 00006090 enqueues the jobs according to a priority scheme, which can be found 00006100 from many different sources of information. These include category, 00006110 time, output, storage requirements, originating site of job, and 00006120 commands from the operator to change priority of either single jobs 00006130 or entire groups of jobs. The disk allocation scheme used is quite 00006140 efficient, and is described later. 00006150 00006160 2. Execution Stage - HASP has the ability to control which jobs 00006170 may execute in which portions of the OS FREE area, and using the various00006180 priority and storage requirements, it selects jobs from its queue to be 00006190 executed. One OS RDR exists, permanently STARTed to a card reader. 00006200 This card reader does not actually exist (i.e., it has a device address 00006210 which does not correspond to a real card reader). Since SVC 0's are 00006220 intercepted by HASP anyway, HASP effectively selects a job and feeds it 00006230 to the OS RDR, which thinks the job is coming across a real card reader.00006240 The OS RDR includes an EXIT LIST, which allows it to call some routine 00006250 after it has scanned each JCL Card, but before the JCL card's data is 00006260 actually recorded. HASP is entered, and takes this opportunity to 00006270 modify any JCL that it wishes to, for example, removing any REGION= 00006280 requests on JOB or EXEC cards. HASP has special treatment for any 00006290 system input or output data sets, as described below: 00006300 00006310 //XXXXXXXX DD * or DATA : the OS RDR would normally expect data 00006320 to follow such a card, and would normally thus SPOOL such to disk 00006330 itself. HASP does not want this to occur, since it has already SPOOLed 00006340 the data. It happens that there are large number of UCB's for pseudo 00006350 card readers already in the system. HASP selects one of these UCB's 00006360 which is not being used, and effectively changes the tables for this 00006370 type of card so that it appears as: 00006380 //XXXXXXXX DD UNIT=xxx 00006390 As a result, the OS RDR thinks that the data set will be read from 00006400 unit xxx, so that it does not try to SPOOL the input. In any case, 00006410 the input no longer follows that JCL card, because HASP feeds the RDR 00006420 only the JCL cards of a user job. During this process, HASP connects 00006430 up the device address xxx to the specific input data set which had 00006450 been previously SPOOLed. 00006460 00006470 //XXXXXXXX DD SYSOUT=x : HASP also has a large number of UCB's for 00006480 nonexistent, pseudo printers/punches. It does the same thing to this 00006490 kind of card as it does to DD * cards, except that it only allocates 00006500 the pseudo devices, and will later save the output which is written to 00006510 them. 00006520 00006530 As soon as the RDR finishes reading a job, an initiator can 00006540 immediately initiate it, since HASP chooses jobs appropriately. 00006550 When the initiator chooses i/o devices, it finds that it can always 00006560 allocate devices for unit-record i/o, since HASP had already checked 00006570 to make sure a pseudo reader/printer/punch was available for each 00006580 SYSIN or SYSOUT data set. 00006590 , 00007000 OSHASP - 07 00007010 00007020 Finally, a job step of the user job executes. When it wishes 00007030 to read cards or print lines, it acts as though it were using a real 00007040 device attached to the system, and OS/360 accepts this. Whenever an 00007050 SVC 0 is issued to request such I/O, HASP intercepts it. 00007060 00007070 HASP may be entered for any of the following reasons: 00007080 00007090 1. WTO, WTOR, WTL - HASP adds own processing as desired. 00007100 2. I/O to disk, drum, tape, terminals, etc - HASP does not 00007110 interfere, but passes these on to the real I/O Supervisor. 00007120 3. I/O to real unit-record devices - these have probably been 00007130 issued by HASP in the first place, so it passes control to the real 00007140 I/O routines to let them perform the I/O. 00007150 4. I/O to a pseudo device - these must be caused by user program. 00007160 For input, HASP fetches the cardimages from disk into memory (if they 00007170 are not already present), and feeds requested cardimage(s) to the user 00007180 program by MVCing them there (using user protect key for safety). For 00007190 output, it blocks up output and eventually writes it to disk. In all 00007200 cases, HASP simulates the effect of having real card readers/printers/ 00007210 punches, which are odd only in possessing great speed; i.e., the effect 00007220 on OS/360 is of having issued an I/O request and having had it complete 00007230 immediately. 00007240 00007250 During execution, HASP can also provide extra services, such as 00007260 monitoring time used, output records, etc. It also reorders priorities 00007270 of executing user tasks so that I/O bound jobs have higher priorities 00007280 than do CPU-bound ones. This action (which is unknown to OS/360) helps 00007290 minimize time spent waiting . 00007300 00007310 00007320 3. Output Stages - Print and Punch - after a job has been executed,00007330 it enters the Print queue, is printed, enters the Punch queue, and 00007340 has punched output (if any) actually punched. This activity occurs 00007350 without the knowledge of OS/360, which believes the job disappeared 00007360 whenever it finished execution. Only when a job is finished punching 00007370 is its disk space released. This allows for jobs to be saved across 00007380 system crashes, and for such useful services as repeating output by 00007390 operator control. 00007400 00007410 C. DASD STORAGE MANAGEMENT IN HASP 00007420 00007430 HASP manages its DASD storage quite efficiently, not only needing 00007440 NO accesses to DASD to allocate or deallocate space, but also doing a 00007450 good job of minimizing arm movement on moveable-head devices. HASP 00007460 requires the use of entire volumes (normally 2311 or 2314 disks). For 00007470 example, the PSU CC's 360/67 has 3 2314 disk packs for HASP. The 00007480 management of this storage works as follows: 00007490 00007500 A MASTER CYCLINDER BIT-MAP is maintained in HASP. This is a 00007510 string of bytes, in which each bit represents 1 CYLINDER on the SPOOL 00007520 disks (for example, 600 bits for the cylinders on 3 packs). A one-bit 00007530 represents a FREE CYLINDER, while a zero-bit shows that the given 00007540 cylinder is allocated to some job. HASP also remembers for each disk 00007560 which cylinder was the last referenced, thus always noting the current 00007570 position of the read/write heads. 00007580 , 00008000 OSHASP - 08 00008010 00008020 Two JOB BIT-MAPS exist for each job, one for SYSIN data and the 00008030 other for SYSOUT data. Whenever a cylinder is required for a job, 00008040 HASP searches for a free one in the following fashion: 00008050 1. It first searches the master bit-map for a free cylinder at 00008070 the current position of any read/write head, i.e., where it can read 00008080 or write without even moving a head. 00008090 2. It then searches for a free cylinder at +1 from current head 00008110 positions, then -1 from each, followed by +2, -2, etc up to +8, -8 00008120 cylinders away from current head position. 00008130 3. If the above fail, it searches sequentially through all 00008150 cylinders in the master bit-map. 00008160 When a cylinder is found, its bit is turned off in the master bit- 00008180 map, and turned on in the appropriate job bit-map. The overall effect 00008190 of this process is to minimize head movement. 00008200 When disk storage for a job is to be released, the deallocation 00008220 scheme is extremely fast and efficient: the job bit-maps are just 00008230 OR'd into the master bit-map, thus returning all of the cylinders to 00008240 free storage. 00008250 00008270 IV. OTHER PSEUDO-DEVICE SYSTEMS FOR USE WITH OS/360 00008280 00008290 The following are other systems which are based on OS/360, but 00008300 use some kind of pseudo-devices to make it run faster. 00008310 00008320 A. ASP - ATTACHED SUPPORT PROCESSOR 00008330 00008340 In this system, 2 computers are used. All unit-record devices are 00008350 attached to the multiplexor channel of a medium-sized 360, along with 00008360 some disk. It performs all SPOOLing, control of remote terminals, etc. 00008370 It is connected to a larger system via a chnnel. OS/360 is in the 00008380 large system, and it reads its input and sends its output along the 00008390 channel-channel hookup between the two CPU's. A typical setup would 00008400 use a 360/50 hooked to a 360/75. 00008410 00008420 An advantage over HASP is that ASP offers somewhat better setup 00008430 facilities for optimizing use of tapes and non-SPOOL disks. A 00008440 disadvantage is the requirement of two CPU's, either of which may have 00008450 problems, and thus stop the entire system. 00008460 00008465 B. LASP (LOCAL ASP) or CLASP (CLOSELY LINKED ASP) 00008470 00008480 These are versions of ASP in which the code from the smaller 00008490 computer is moved over into a region on the larger machine. This allows00008500 an ASP system to be run on one processor. If the system is also run 00008510 under straight ASP, it requires switches to switch the unit-record 00008520 devices over to the bigger machine. It also requires more memory than 00008530 HASP, but does allow the system to run even with one CPU down. 00008540 00008550 C. TUCC HYPERDISK 00008560 00008570 This method uses LCS plus part of a 2314 disk pack to simulate 00008580 the entire disk pack containing heavy-used systems programs. The most 00008590 recently used tracks of this disk are kept in LCS, thus making the disk 00008600 effectively faster, without changing the internals of OS/360. 00008610 , 00009000 OSHASP - 09 00009010 00009020 V. PSU CC 360/67 SYSTEM - OS/MVT WITH HASP 00009030 00009040 The following tables gi$e the current layout (with no guarantee of 00009050 future appearance) as of 6/12/72, for the 360/67 at the PSU CC. The 00009060 system has both fast core (1024K) and Large Core Storage (2048K). 00009070 00009100 LOW HIGH K LOW HIGH 00009110 MS 2928 3072 144 2DC000 300000 00009120 HASP 1968 2928 960 1EC000 2DC000 00009130 FMGR 1628 1968 340 197000 1EC000 00009140 RJE 1346 1628 282 150800 197000 00009150 WATFOR 1336 1346 10 14E000 150800 00009160 RASP 1236 1336 100 135000 14E000 00009170 FREE 1024 1236 212 100000 135000 00009180 ______________________________________________________________ 00009190 MS 964 1024 60 0F1000 100000 00009200 HASP 876 964 88 0DB000 0F1000 00009210 RDR 866 876 10 0D8800 0DB000 00009220 FMGR 852 866 14 0D5000 0D8800 00009230 RJE 832 852 20 0D0000 0D5000 00009240 WATFOR 704 832 128 0B0000 0D0000 00009250 FREE 122 704 582 01E800 0B0000 00009260 NUC 0 122 122 000000 01E800 00009270 00009280 NOTES 00009290 00009300 MS (Master Scheduler) includes the Link Pack areas. The fast core 00009310 section contains mainly modules for the various I/O Access Methods,00009320 while the LCS part contains reentrant parts of INITIATORS, RDRS, 00009330 plus other routines (overlay supervisor, special tables,etc). 00009340 00009350 HASP Fast core section is most heavily-used sections. LCS part has 00009360 lesser-used sections, plus such items as in-core SYSJOBQUE (HASP 00009370 intercepts all RDR and INIT reads/writes to SYSJOBQUE, and keeps 00009380 such information in about 600K of LCS). Also has HASP buffers for 00009390 all devices, plus tables of tape names/locations for user tapes. 00009400 00009410 FMGR File Manager - manages, synchronizes RJE, BAT files. 00009430 00009440 RJE Remote Job Entry - handles typewriter terminals. 00009450 00009460 WATFOR WATFOR REgion - RPSS - manages CAtegory W fast processors 00009470 swapped in and out of memory (WATFOR, ASSIST, PL/C, etc). 00009480 00009490 RASP Interface between 360/67 and ADAGE AGT/30 graphics computer. 00009500 00009510 FREE fast core - 560K for user programs (4x140, 2x280, 1x280+2x 00009520 140, occasionally 1x560), rest for Sytem Queue Space. 00009530 LCS - currently unused, except for systems programs. 00009540 , 00000050 ASPRGTC1 - 01 00000150 00000200 00000250 S/360 Assembler Language Programming Techniques 00000300 John R. Mashey - Winter l972 00000350 00000400 00000450 Topic: Program Modularity and Parametrization Methods: 00000500 Using Macros, Internal Subroutine, External Subroutines 00000550 This topic: pages 01-08 00000600 00000650 It is generally important in any computer program to avoid coding00000700 any procedure more times than necessary. It is generally best to write00000750 something one time, then have it available for later use in many parts00000800 of a program. In assembler language, there are three main ways of doing00000850 this: macros, internal subroutines, and external subroutines. This00000900 writeup describes each of these techniques, gives the advantages and00000950 disadvantages of each, and notes under what condition each is best.00001000 00001050 I. DESCRIPTION, DEFINITION, AND CALLING 00001100 00001150 A. MACRO INSTRUCTIONS 00001200 00001250 A macro instruction is defined, and either placed at the beginning00001300 of an assembly language program (a USER macro), or entered into a macro00001350 library (a SYSTEM macro). When called, it generates 0 or more assembly00001400 language statements at the point of invocation, and the code generated00001450 may vary greatly from call to call. 00001500 00001550 1. DEFINITION 00001600 00001650 A macro definition begins with MACRO, followed by the PROTOTYPE00001700 STATEMENT, which gives the name of the macro. The body of the macro00001750 includes 0 or more MODEL STATEMENTS, which are assembler commands and00001800 machine instructions to be generated, and macro-operations, which serve00001850 to direct the expansion processing of the macro. The macro definition00001900 is terminated by the MEND statement. The following steps are typical00001950 in defining a macro: 00002000 00002050 a. DETERMINE BASIC PURPOSE AND GENERATED CODE: It is generally00002100 a good idea to write at least some of the statements to be generated00002150 together as a code segment first, to get some feel for what is needed.00002200 00002250 b. DECIDE ON NECESSARY ARGUMENTS AND THEIR USAGE: it may be a goo00002300 idea to write the purpose of each argument in the operand list, punch it00002350 and include it in a block of comments at the beginning of the macro.00002400 This helps the macro to be done to do what it is supposed to do.00002450 00002500 Use POSITIONAL operands for heavily-used arguments, i.e., if an00002550 argument MUST be supplied every time, make it positional. In a group00002600 of positionals, place the most heavily used ones near the front, since00002650 it is much more convenient to omit the later ones than the earlier.00002700 Use KEYWORD arguments for values which may not be needed always, or for00002750 ones which are conveniently supplied with default values which are most00002800 often used. Use SUBLISTS or &SYSLIST for variable numbers of arguments.00002850 00002900 c. WRITE ACTUAL BODY OF MACRO, BUILDING MACRO-TYPE COMMANDS00002950 AROUND THE MODEL STATEMENTS TO BE GENERATED. 00003000 , 00003050 ASPRGTC1 - 02 00003100 00003150 2. INVOCATION 00003200 00003250 A macro can be called merely by writing its name and supplying it00003300 with any needed arguments. Note that a label on a macro call is never00003350 generated (and is thus UNDEFINED) unless the macro definition is made00003400 to generate it on some model statement. 00003450 00003500 B. INTERNAL SUBROUTINES 00003550 00003600 Internal subroutines are sections of code written as parts of a00003650 given control section (CSECT), and are only used inside that CSECT. Like00003700 external subroutines, internal subroutines can of course call others.00003750 They are typically used for small to medium sections of code which are00003800 needed at several places in a CSECT, but are not needed by any other,00003850 or are not big enough to warrant the overhead in making them external00003900 subroutines. 00003950 00004000 1. DEFINITION 00004050 00004100 It is often typical to place a group of internal subroutines near00004150 the end of the code section of a program (just before the data areas).00004200 It is a good idea to set up conventions for the use of internal00004250 subroutines, before writing any. The following are often needed:00004300 return register (either one standard one, or several different ones),00004350 argument registers, and work registers which can be used without saving.00004400 In general, internal subroutines should not need to do much saving and00004450 restoring of registers. They should be able to return via BR REG.00004500 00004550 2. INVOCATION 00004600 00004650 Calling an internal subroutine is usually done by first filling any00004700 argument registers with needed values, then coding: BAL REG, INSUB.00004750 This type of linkage can be fast and small. 00004800 00004850 C. EXTERNAL SUBROUTINES 00004900 00004950 External subroutines are used for major program segments, and00005000 can usually be assembled separately from the rest of the program. In00005050 fact they can be written in a different language (i.e., FORTRAN and00005100 ASSEMBLER combinations). 00005150 00005200 1. DEFINITION 00005250 00005300 An external subroutine may be written in either of two ways in00005350 assembly language: as a CSECT, or as an ENTRY within a CSECT. In the00005400 first case, the subroutine is entered at the CSECT statements and return00005450 at one or more places depending on the desired code. In the second case00005500 each entrypoint may be given control, and may share code or be00005550 totally separate from the other entries. This form is often used for00005600 a group of related routines (like SIN and COS, which are both entries in00005650 a CSECT), or for a routine requiring initialization or termination00005700 functions different from the normal calling function. 00005750 , 00005800 ASPRGTC1 - 03 00005850 00005900 A multiple-entry CSECT is typically set up as follows: 00005950 00006000 CSECTNAM CSECT 00006050 ENTRY ENTRY1,ENTRY2,...ENTRYN 00006100 ..... code for entry at CSECTNAM: multiple-entry routines often00006150 ..... are entered only at the entry points, not at the CSECT.00006200 00006250 ENTRY1 LINKAGE CODE (SAVE, XSAVE, etc) 00006300 ..... executable code when called at ENTRY1..... 00006350 RETURN LINKAGE CODE (RETURN, XRETURN, etc). 00006400 00006450 ..... remaining entrypoint names and code 00006500 00006550 ..... internal subroutines needed by more than one entry point.00006600 00006650 ..... data areas used by various of the entry point routines.00006700 00006750 The following are important points to remember when using multiple00006800 entry CSECTS: 00006850 00006900 THE DIFFERENT ENTRY POINTS NEVER CALL EACH OTHER. In essence, all00006950 of the routines represented by the various entry points are at the same00007000 level in calling structure of an entire program. 00007050 00007100 ONLY ONE SAVE AREA IS ACTUALLY NEEDED. Since the routines inside00007150 the CSECT never call each other, the user can code the save area at the00007200 end of the LAST section of code, so that all of the previous sections00007250 can refer to it (note that if placed on the first, it would be difficult00007300 for the later ones to access it using a LA instruction: address00007350 constants must be used instead). With XSAVE/XRETURN, this means that00007400 the SA=* operand is coded only on the LAST XRETURN. 00007450 00007500 CARE MUST BE TAKEN WITH ADDRESSIBILITY. All of the code sections00007550 can of course address the data areas at the end of the CSECT. However,00007600 the programmer must be very careful with any internal subroutines he00007650 writes, because the BASE REGISTERS USED TO ASSEMBLE INTERNAL SUBROUTINES00007700 MUST HAVE THE CORRECT VALUES IN THEM AT EXECUTION TIME. IF THEY DON'T,00007750 AS WHEN THEY ARE CALLED FROM DIFFERENT SECTIONS HAVING DIFFERENT USING00007800 SETUPS, THEY WILL ASSEMBLE PROPERLY AND THEN BLOW UP AT EXECUTION TIME.00007850 IN PARTICULAR, THE PROGRAMMER SHOULD PLACE INSTRUCTIONS TO BE EXECUTED00007900 (EX operation) WITH THE SECTION OF CODE USING THEM, AND NOT AT WITH THE00007950 DATA AREAS, IF THEY PERFORM ANY SYMBOLIC ADDRESSING. 00008000 00008050 The problems described above are typically handled either by making00008100 all entry point code segments set up the same USING conditions, or by00008150 setting a specific register to point to the beginning of the internal00008200 subroutines, EXecuted instructions and data. If register 13 points to00008250 a save area just above these code sections, it can be used this way,00008300 since it will always have that same value. Getting the same USING00008350 conditions across an entire multi-entry CSECT can be done: 00008400 00008450 ENTRYX XSAVE 00008500 L BASEREG,=A(CSECTNAM) 00008550 USING CSECTNAM,BASEREG 00008600 00008650 Note that the above can be accomplished with the XSAVE AD= operand.00008700 , 00008750 ASPRGTC1 - 04 00008800 00008850 D. COMBINED FORMS 00008900 00008950 In some cases, it is convenient to combine the ease of use of the00009000 macro with the small size of internal or external subroutines. In this00009050 case, the macro expansion sets up any needed arguments, saves registers,00009100 etc, then generates code to invoke the subroutine. The subroutine then00009150 provides the major portion of the processing code, any needed large data00009200 areas, etc. 00009250 00009300 Examples of the combined form are the following macros: XDECI,00009350 XDECO, XPRNT, XSNAP, which call XXXXDECI, XXXXDECO, XXXXPRNT, and00009400 XXXXSNAP, respectively. 00009450 00009500 Two different extremes exist in writing combined forms: 00009550 00009600 1. COMBINED FORM - STANDARD LINKAGE 00009650 00009700 In some case, the calling sequence to invoke an external subroutine00009750 essentially includes the CALL macro or equivalent code, i.e., it uses00009800 standard conventions. It typically assumes that registers 0, 1, 14, 1500009850 may be modified without causing trouble. This method is efficient and00009900 general, but can cause trouble if used improperly. 00009950 00010000 2. COMBINED FORM - SPECIAL NONDESTRUCTIVE LINKAGE 00010050 00010100 In some cases, it may be useful to define a macro instruction which00010150 invokes a subroutine, but can be used ANYWHERE without disturbing any00010200 registers, changing the condition code, or requiring that certain of the00010250 registers not be the ones being used as base registers (in particular,00010300 register 15). This is the kind of linkage used from XDECO to XXXXDECO00010350 XPRNT to XXXXPRNT, etc. The following shows the general form of such a00010400 linkage setup, giving first the kind of code to be generated by the00010450 macro part, then the entry and exit code for the associated routine:00010500 (NOTE: label is typically an &SYSNDX-generated unique label)00010550 00010600 STM 14,0,label save registers to be changed 00010650 .... evaluate arguments of macro: any required Load Addresses 00010700 .... must be done using LA 0, argument since doing LA into 00010750 .... any other register could destroy a base register. If 00010800 .... more than one argument is needed, the remaining ones can 00010850 .... be stored into control block after label. Examples: 00010900 LA 0,argument 00010950 ST 0,label+12 2nd argument (one arg left in RO) 00011000 .... after all arguments are evaluated and saved, and ONLY 00011050 .... THEN, it is now possible to modify registers: 00011100 L 15,label-4 V-type adcon for routine 00011150 CNOP 2,4 make sure next inst not on F boundry 00011200 BALR 14,15 call routine, also point 14 at the 00011250 argument list following 00011300 DC V(subroutine entry point) adcon to get there 00011350 label DS 3F 3 words for saving 14, 15, 0 00011400 DS F space for arguments after first 00011450 .... DS OR DC space here for any remaining arguments 00011500 .... the subroutine will return control to next instruction: 00011550 LM 14,0,4(14) reload registers. Note that this is 00011600 only safe way, since 15 might have 00011650 current base register. 00011700 , 00011750 ASPRGTC1 - 05 00011800 00011850 The following shows the typical code used to enter and exit the00011900 supporting module used with the previous macro expansion. Note that the00011950 entry point of the routine might be either a CSECT name, or an ENTRY00012000 name, i.e., one CSECT might contain several entrypoints, one for each00012050 supporting subroutine needed. 00012100 00012150 entrypoint label definition (CSECT, or label DS OH) 00012200 USING entrypoint,15 initial base register 00012250 .... save all registers which may be modified by code. Save 00012300 .... into THIS CSECT (unlike normal OS/360 conventions). 00012350 .... DO NOT SAVE INTO CALLER'S SAVE AREA, since it may not 00012400 .... exist, especially if caller is a lowest-level routine. 00012450 00012500 .... initialization code: if this routine performs I/O, or 00012550 .... calls any others, or requests any supervisor services, it00012600 .... is a good idea to set up another base register than 15, 00012650 .... set up a save area, and put its address into register 13,00012700 .... since any of the above actions may result in registers 00012750 .... being saved at wherever 13 points. 00012800 00012850 .... processing code to perform required actions 00012900 00012950 .... result return code: result may be left in register 0, 00013000 .... in which case it should not be restored (neither here nor00013050 .... in generated code before: i.e., change LM 14,0,4(14) to 00013100 .... LM 14,15,4(14) and STM likewise). 00013150 00013200 .... register restoration: restore all registers modified in 00013250 .... this routine. Especially restore 14. 00013300 00013350 SPM 14 restore original condition code (note00013400 that calling BALR 14,15 saved it) 00013450 00013500 B number(14) branch to displacement number beyond 00013550 address in 14, enough to pass control00013600 to statement: LM 14,0,4(14) 00013650 00013700 It may be useful for the programmer to create a DSECT which00013750 describes the control block generated by the macro expansion. This00013800 would permit the module to refer to arguments and return points using00013850 symbols rather than absolute displacements. A typical DSECT might be:00013900 00013950 dsectnam DSECT 00014000 DS V(routine) space for adcon 00014050 DS 3F space for regs 14, 15, 0 00014100 argument DS F argument value placed here, if any 00014150 .... further arugment DS statements follow. 00014200 return LM 14,0,4(14) return label (YES, THIS IS LEGAL: it does00014250 NOT generate code, but it makes the point 00014300 clear as to description of block). 00014350 00014400 If such a DSECT were used, the routine code would include:00014450 USING dsectnam,14 to set up DSECT addressibility 00014500 B return return (instead of B number(14) 00014550 , 00014600 ASPRGTC1 - 06 00014650 00014700 II. ADVANTAGES AND DISADVANTAGES 00014750 00014800 The following lists the good and bad points of each type:00014850 00014900 A. MACRO INSTRUCTIONS 00014950 00014975 1. ADVANTAGES 00015000 00015050 Code can be tailored to each individual request, i.e., the code00015100 generated by each macro call can vary from a great deal to nothing,00015150 such as debug code eliminated by testing a global set variable.00015200 00015250 SPEED: macro-generated code can be the fastest in execution, since00015300 it can perform its actions without having to set up linkage to another00015350 section of code. 00015400 00015450 VARIABILITY: generated code can vary depending on the nature of00015500 arguments passed to a macro (such as testing the TYPE of arguments to00015550 generate different instructions). 00015600 00015650 2. DISADVANTAGES 00015700 00015750 SLOW ASSEMBLY: macro processing can be very slow. 00015800 00015850 LARGE CODE: if used improperly, macros can generate large amounts00015900 of code very easily. If there are many copies of large blocks of code,00015950 much space can be wasted. 00016000 00016050 OBJECT DECKS: a macro cannot be assembled and an object deck of it00016100 gotten like a subroutine can, i.e., if a call is made to a macro, the00016150 macro definition must be included in the program or in a library, while00016200 a CSECT may be saved as an object deck (which is usually much smaller00016250 than the source deck). 00016300 00016350 B. INTERNAL SUBROUTINES 00016400 00016450 1. ADVANTAGES 00016500 00016550 SPEED: although not as fast as in-line code from a macro, the code00016600 for an internal subroutine is usually faster than the linkage to an00016650 external one. In particular, values can be passed in registers, and00016700 usually registers will not have to be saved. 00016750 00016800 SPACE: internal subroutines require less space than generating the00016850 same code several times via macro expansions. 00016900 00016950 2. DISADVANTAGES 00017000 00017050 SPACE: if the same function is performed by internal subroutines00017100 in several CSECTS, code is thus duplicated and space wasted. 00017150 00017200 COMPLEXITY: in some cases, in order to make efficient use of a00017250 number of internal subroutines, it is necessary to set up fairly00017300 extensive rules on usage of registers in a CSECT, so that the linkage00017350 among them may be fast and small. 00017400 , 00017425 ASPRGTC1 - 07 00017450 00017500 C. EXTERNAL SUBROUTINES 00017550 00017600 1. ADVANTAGES 00017650 00017700 SPACE: if written as an external subroutine, code can be usefully00017750 called from almost anywhere in a program. Thus, there is only one copy00017800 of it, and it generally will occupy the least space. 00017850 00017900 SEPARATE COMPILE/ASSEMBLY: a routine written as a CSECT can be00017950 assembled separately from the rest of the program an object deck can00018000 be obtained, and translation time generally saved. The routine may of00018050 course be written in a different language than the rest of the program.00018100 00018150 2. DISADVANTAGES 00018200 00018250 LINKAGE TIME: if standard OS/360 linkage is followed, a fair amount00018300 of execution time and object code space can be consumed by this linkage.00018350 More efficient nonstandard linkage can be used instead, but this brings00018400 with it the disadvantage of nonuniformity and lack of generality.00018450 00018500 D. COMBINED FORMS 00018550 00018600 1. ADVANTAGES 00018650 00018700 In general, the combined forms can possess all the advantages of00018750 the separate forms especially since the macro portions can generate00018800 different code depending on circumstances; thus the code for the same00018850 macro might expand in-line in one case and generate an out-of-line call00018900 to a routine in another. 00018950 00019000 2. DISADVANTAGES 00019050 00019100 COMPLEXITY: it of course requires somewhat more planning and code00019150 to set up a good combined form system, since both a macro and module00019200 must be created and meshed together properly. 00019250 , 00019300 ASPRGTC1 - 08 00019350 00019400 III. CIRCUMSTANCES FAVORING USE OF THE VARIOUS FORMS 00019450 00019500 A. MACRO INSTRUCTIONS 00019550 00019600 In general, a pure macro instruction is used as follows:00019650 00019700 VARYING CODE: the required code varies radically from call to00019750 call. For example: XSAVE and XRETURN. 00019800 00019850 SHORT CODE: if a macro can generate less in-line code to perform00019900 the required function than is needed to generate a call to the routine,00019950 then it should be written as a macro. In some cases, it takes as much00020000 work to set up the arguments as it does just to perform the operations.00020050 For example: the code to obtain the minimum or maximum of several00020100 arguments is probably most efficiently written as a in-line macro.00020150 00020200 LINKAGE CODE: code for linking to routines is almost necessarily00020250 written as macros, since it makes little sense to call a routine in00020300 order to perform linkage, unless the linkage code required is very00020350 complex (in which case the program is probably going to be SLOW).00020400 00020450 B. INTERNAL SUBROUTINES 00020500 00020550 Internal subroutines are usually used (as opposed to macros which00020600 generate code in-line) under the following circumstances: 00020650 00020700 CODE WITH LITTLE VARIANCE: if the code is not going to be much00020750 different from macro call to macro call, it may be better to let the00020800 macro call generate a BAL to one copy of the code as an internal subr.00020850 00020900 Internal subroutines are usually used (as opposed to EXTERNAL00020950 subroutines) under these circumstances: 00021000 00021050 SHORT CODE, HEAVILY USED: if code must be used many times by00021100 a CSECT, then the faster linkage of internal subroutines usually makes00021150 it worth writing it that way. 00021200 00021250 CODE NEEDED ONLY BY ONE CSECT: if not too long, it is fairly00021300 logical to incorporate it as part of that CSECT. It will probably be00021350 much more efficient since it will have access to the internal variables00021400 of the CSECT, and be able to communicate via register values easily,00021450 rather than requiring long operand lists. 00021500 00021550 C. EXTERNAL SUBROUTINES 00021600 00021650 LONG CODE: if something is long and complex enough, it may be a00021700 good idea to make a separate module of it, test it, get an object deck,00021750 then leave it along thereafter. 00021800 00021850 CODE OF GENERAL USE, NEEDED MANY PLACES: in this case, it is00021900 practically necessary to make code an external subroutine, so that it00021950 can be accessed where needed. 00022000 00022050 D. COMBINED FORMS 00022100 00022150 These are useful anywhere the others are. The nondestructive form00022200 is specially useful if it is to be used by beginning programmers.00022250 , 00001000 DOCUMENT-1 00001010 00001020 S/360 Assembler Language 00001030 Documentation and Listing Techniques 00001040 00001050 by John R. Mashey and Andrea Rhodes 00001060 00001070 00001080 Goals of Good Documentation : 00001090 1. Aid in designing good programs 00001100 2. Aid in debugging programs 00001110 3. Make programs clear and understandable once written 00001120 4. Make structure of program well-organized 00001130 00001140 00001150 Good documentation is a great aid to producing clear, well-written,00001160 and understandable programs, and can save much programming and computing00001170 time. Good documentation is especially necessary for programming00001180 projects requiring either a long period of time by one programmer,00001190 any period of time by more than one programmer, or modifications to any00001200 code by anyone other than the original author. Good documentation00001210 techniques can be helpful in the following ways: 00001220 00001230 PROGRAM DESIGN 00001240 Many beginning programmers seem to write programs in haphazard00001250 and unplanned ways, and often add comments only after the program is00001260 running. This method not only leads to poorly-structured programs,00001270 but usually results in wasted time, and is not feasible except for00001280 relatively trivial problems. 00001290 A much better method is to write most of the overall comments with00001300 a flow chart first, specifying the structure and conventions of the00001310 program, and then writing the program to fit. This usually leads to00001320 cleaner-coded, well-structured programs which are produced in less00001330 time than those written by most novice programmers. 00001340 00001350 PROGRAM DEBUGGING 00001360 Program debugging is aided by documenting a program before and00001370 during its creation, rather than afterward. Many mistakes can be00001380 avoided by having programming conventions well-specified before writing00001390 the code. The very act of adding a comment to a statement often helps00001400 identify errors in the statement, because it forces the programmer to00001410 think about the function of the statement. Finally, good documentation00001420 is useful if help is required from someone else, since it aids one in00001430 understanding the program quickly. (It also makes other people much00001440 more willing to look at a program!) 00001450 00001460 PROGRAM MODIFICATIONS 00001470 Clear and complete documentation is absolutely invaluable when a00001480 program must be modified, especially if anyone but the original00001490 programmer is making the changes. It may be noted that useful programs00001500 tend to be modified often. 00001510 , 00002000 DOCUMENT-2 00002010 00002020 00002030 ASSEMBLY LANGUAGE DOCUMENTATION 00002040 The following advantages apply to any computer language.00002050 However, they are most important for assembly language, for the00002060 following reasons: 00002070 1. Assembly language programs typically require many more00002080 statements than do high-level language programs for the same task.00002090 2. Assembly language programs are not usually self documenting.00002100 Without good documentation, not even the programmer who wrote the code00002110 will be able to understand it several months later. 00002120 3. Assembly language programs are often very sensitive to minor00002130 changes, much more so than higher-level languages. 00002140 00002150 00002160 The remainder of this paper describes a well-documented assembly00002170 program, and notes the various techniques which can be used to achieve00002180 this result. Briefly, a well-documented program has the following00002190 characteristics: 00002200 00002210 1. The documentation structure mirrors the program structure, and00002220 it leads from the general to the specific. Thus, the program begins00002230 with a block of comments which describes the overall purpose of the00002240 program, and gives some indication of the general structure. Each00002250 major section has a block of comments describing it, as does each00002260 of the section's subsets. 00002270 2. At least 95% of machine-instruction statements have comments.00002280 3. The program is easy to read, and blocked off into logical00002290 sections, so that anyone may look at it and understand it easily.00002300 4. Good programs typically have 15-25% of the total statements00002310 as comment cards, in addition to the comments on the individual00002320 statements. 00002330 00002340 00002350 S/360 ASSEMBLER DOCUMENTATION HINTS--DO'S and DON'TS 00002360 00002370 DON'T 00002380 punch statements in random columns. This makes a program very00002390 unreadable. Use a drum card, and if you do not know how, ask your00002400 assistant. The following is a defacto standard for S/360 Assembler00002410 statements: 00002420 00002430 Col. 1 : LABELS 00002440 Col. 10: OPERATION CODES 00002450 Col. 16: OPERAND FIELD 00002460 Col. 36: COMMENTS (col. 40 is preferred by some people) 00002470 Col. 72: CONTINUATION COLUMN 00002480 Col. 73-80: SEQUENCE NUMBERS (very useful--ask your assistant00002490 how to sequence a deck if you are unsure) 00002500 00002510 This layout can be obtained by the use of the following drum card:00002520 Cols. 1,10,16,36,73: punch '1' (gives tab stops at these cols.)00002530 Col. 72: punch '-' (skips col. 72 automatically, unless AUTO00002540 DUP/SKIP is off) 00002550 All other columns: punch 'A' 00002555 If for some reason these columns are not wanted, a standard set should00002560 be decided upon, and then held to completely. 00002570 , 00003000 DOCUMENT-3 00003010 00003020 DON'T 00003030 Place a comment card before every statement. This bad habit makes00003040 programs absolutely unreadable. Embedded comments should be used to00003050 block programs into logical sections, not to explain the function00003060 of individual statements. 00003070 00003080 DON'T 00003090 bury code with too many interspersed comments. If so many00003100 comments are necessary, place them in blocks ahead of the program00003110 segments and not in the middle. 00003120 00003130 DO 00003140 put a comment on nearly every machine instruction. Comments are00003150 also helpful for explanations of variables and flags. Each comment00003160 should describe the function of its statement, and generally, it alone.00003170 If a comment is needed to describe the function of a block of00003180 half-a-dozen cards, it probably should be placed on a comment card00003190 preceding the block of code. These comments should be punched when00003200 the program is originally punched. A good technique is to add these00003210 comments while keypunching the program. Often, this results in00003220 catching many mistakes at that point. It is noted that few novice00003230 programmers do this, while most experts do. It is also noted that00003240 many programmers who do this wish they had started doing so earlier,00003250 since they realize how much time they had wasted by not commenting00003260 the original deck. 00003270 00003280 DO 00003290 use TITLE, SPACE, and EJECT commands. The command 00003300 TITLE 'A HEADING MESSAGE' 00003310 skips the listing to a new page, and prints the heading message at the00003320 top of every page until another TITLE command is issued. This not only00003330 clearly labels your listing, but it saves time in looking through a00003340 listing which is more than a few pages long. The command 00003350 EJECT 00003360 skips the listing to a new page, and is useful in blocking off major00003370 parts of a program. The command 00003380 SPACE n 00003390 inserts n blank lines into the listing at that point. This is useful00003400 for blocking off smaller sections of a program, particularly small00003410 loops, register equates, etc. 00003420 Not only do listing control instructions aid to the readability00003430 of a program, but they also save the programmer time in debugging.00003440 00003450 DON'T 00003460 merely restate an instruction when you place a comment on it.00003470 Of the following two examples, which is more explanatory? 00003480 00003490 A 1,VAR ADD VAR TO REGISTER 1 00003500 00003510 A 1,VAR R1=SUMMATION OF ODD PRIME NUMBERS 00003520 00003530 DON'T 00003540 put several single comments between statements in an unreadable00003550 manner. It is often useful to indent a single comment to column 16.00003560 This keeps it from interfering with the reading of labels and opcodes,00003570 and thus distinguishes it from the machine instructions. 00003580 , 00004000 DOCUMENT-4 00004010 00004020 DO 00004030 use comment card blocks which list useful information. For00004040 example, a list of register allocation and usage is extremely00004050 helpful, not only in debugging, but also in revising a program.00004060 Such a list should appear as part of the preface to the appropriate00004070 section of code. Another example is a list of calling conventions for00004080 subroutines. For extensive programs, lists of the following might be00004090 kept at the beginning of each subroutine: MACROS USED, SUBROUTINES00004100 CALLED BY THIS SUBROUTINE, SUBROUTINES WHICH CALL THIS SUBROUTINE,00004110 VARIABLES USED BY THIS SUBROUTINE, VARIABLES CHANGED BY THIS 00004120 SUBROUTINE, etc. 00004130 00004140 DO 00004150 block off large sections of comment cards. Large blocks of00004160 comments can begin in whatever column is appropriate, but in general,00004170 should use most of the card, since they will otherwise add a great deal00004180 of length to a program. For the sake of appearance, comments should00004190 be blocked off by blank lines (SPACE n) or lines of continuous00004200 characters. The most common characters used for this purpose are00004210 asterisks (in columns 1-71, or in just the odd columns). An esthetic00004220 appearance can be obtained by placing an asterisk in column 71 of each00004230 comment card in a major block, with lines of asterisks before and after00004240 the entire block of documentation. 00004250 00004260 DO 00004270 flag instructions which will be modified during execution in order00004280 to make programming logic obvious. This may be accomplished by using00004290 '*-*' or '$', the latter EQU'ed to zero, for any modified field. For00004300 example, 00004310 00004320 $ EQU 0 $ => INST. MODIFIED IN EX 00004330 00004340 .......... other statements .......... 00004350 00004360 STC 2,MVC+1 SET BUFFER LEN. FOR LATER 00004370 * USE. 00004380 00004390 .......... other statements .......... 00004400 00004410 MVC MVC OUTPUT($),0(5) MOVE VARIABLE # BYTES INTO 00004420 * OUTPUT BUFFER. 00004430 00004440 .......... other statements .......... 00004450 00004460 00004470 The above methods have been derived both from the examination of00004480 many professionally-written programs and from the authors' own00004490 experiences. Thus, they are not arbitrary rules but techniques which00004500 have been widely used and proven to be effective aids in programming00004510 assembler language. 00004520 , LINKAGE-1 STANDARD LINKAGE CONVENTIONS Charles Pfleeger Under OS/360, certain conventions have been established regarding the use of registers. These conventions will have been followed when you, the problem programmer, receive control from the system; they should be followed for any routines which you call, or for communi- cating with the system (e.g. system macro calls, SVC's, returning control, etc.). Following these conventions will make your code easier for someone else to follow. Certain debugging aids are also available for those who adhere to standard conventions. In general, unless there is a strong reason to deviate, these conventions should be employed. REGISTER 14 is called the return register and contains the address to which this routine is to return upon exit. REGISTER 15 is called the entry point register, and contains the address through which this routine was entered. Note that tempor- ary addressability may be established by USING entrypointname,15 If this routine calls no other routines, register 15 may be used as a permanent base register. If this routine calls any other routines, however, register 15 will be changed, and should not be used as a permanent base register. In this latter case, the sequence LR BASEREG,15 USING entrypointname,BASEREG (where BASEREG is any of registers 2-12) may be used to establish permanent addressability. On return, register 15 may be used to return a code to indicate normal or error return. One frequently-used technique is to set R15 zero on a normal return and set it non-zero if some error condition occurred prior to return. REGISTER 0 is used to return the single result from some process (as in a Fortran function subprogram). Note: although you will probably not use this convention much, it is heavily used by the operating system. Register 0 cannot be guaranteed to be intact after executing some call to the system, as a system macro, or an SVC. REGISTER 1 is the pointer to an argument list. It contains the address of the first of one or more full word entries (on con- secutive f.w. boundaries). These entries are the addresses of arg- uments to be used by the calling routine. If there may be an indefinite number of arguments, (as with a routine which would accept one, two, or any number of arguments-- c.f. Fortran MAX0), the first bit of the last address is set to a 1. (This bit will not interfere with ordinary S/360 addresses, since an address can be fully specified in 3 bytes; byte 1 is ig- nored on an address constant.) , LINKAGE-2 The following example illustrates how to use the address list passed through register 1. LA 1,ARGLIST get argument list address L 15,=V(CALLRTN) get entry address BALR 14,15 call routine . . . ARGLIST DC A(ARG1) DC A(ARG2) . . . DC X'80',AL3(ARGn) Note the length factor does not provide auto- matic alignment. . . . CALLRTN CSECT . . . L 2,0(1) get addr. of next arg. LTR 1,1 last arg. in list? BM RETURN if yes, return LA 1,4(1) else get addr. of next arg. When a programmer receives control from the system, information from the PARM field of his EXEC card is passed via register 1. Register 1 points to a fullword of storage. Bit 0 of this fullword is set to 1 (to indicate the last--only--argument of the list). This fullword contains the address of a halfword. The halfword is a count of the number of characters in the parm field message, and these characters follow immediately after the halfword count field. The contents of the halfword may be picked up to use as a length count in an execute instruction, and the address of the halfword may be used as a base to move the information characters of the PARM field. REGISTER 13 is called the save area register. It contains the add- ress of an 18 fullword area (on a f.w. boundary) within the calling routine. The routine called will use this area to save the contents of registers, to be able to return the registers intact to the calling program. This save area has a set format: Word 1 Used by PL/I and FORTRAN Word 2 address of the save area used by the calling program. Word 3 address of the save area set up by the called program. Word 4 address to which to return (reg. 14). Word 5 address of entry point (reg. 15). Word 6 contents of register 0. . . . Word 18 contents of register 12. Save areas are chained in a doubly-linked list. At any low- level routine, by tracing back through a chain of save area links, one can eventually return to the system at the original point of call. , LINKAGE-3 When your routine is entered, first you should save registers and then establish and link your own save area. STM 14,12,12(13) save regs. 14, 15, and 0-12 in calling program's save area. LA 5,MYSAVE get addr. of my save area ST 5,8(13) link calling pgm. s.a. to mine ST 13,4(5) link my s.a. to calling pgm's LR 13,5 transfer pointer to s.a. On return: L 13,4(13) retrieve addr. of calling pgm's save area LM 14,12,12(13) restore registers as they were BR 14 MYSAVE DC 18F'0' A calling program is known as a "higher routine", and the routine called is the "lower routine". Register 13 is always to point to an area whose contents may be destroyed. An exception to the requirement that a routine must always establish a save area is that the lowest-level routine (the one which calls no others) need not set up a save area. The reason for this is the save area is for the use of any called routines, but that the lowest-level routine will have no called routines. It is important to know the conventions on save areas, but the use of XSAVE AND XRETURN (consult appropriate documentation) can reduce the problems in coding and linking save areas. THE NAME CONVENTION is a means of having the EBCDIC form of the name of a routine appear at certain key places on dumps. To use this convention, the first four bytes of a routine must be a branch, on 15 as a base register, which passes over a series of bytes. These bytes contain the EBCDIC form of the name of a routine, and also a length count for this name area. This example shows how to code a name field. name CSECT B m+1+4(,15) DC X'm' DC CLm'name' next instruction. The value of m must be odd, in order to have the next instruction properly aligned. An alternate approach uses the convention on register 15: name CSECT USING name,15 B NEXTINST DC X'm' DC CLm'name' NEXTINST next instruction , LINKAGE-4 Notes: O/S follows these conventions strongly. In particular, the system often destroys the contents of registers 0, 1, 14, and 15 when it returns control from a system macro, an SVC, or another system function. One must SAVE THE CONTENTS of these registers BEFORE exec- uting one of these functions; hard-to-locate errors will frequently occur after failure to do so. It is a good idea to mark a save area upon exit. This is usually done be moving X'FF' into the first byte of the fourth word of the save area (the place register 14 was stored). Although this technique does not seriously affect the contents of the save area for reading in a dump, this technique quickly shows what save areas are active and which are not active when reading a dump. Register 13 must be kept as the save area pointer; however, by careful programming, it can also double as a base register. Consult the appropriate section from XSAVE and XRETURN documentation for the coding sequence using these macros. You may set up your own save area for this purpose by setting it high in a program, and following it by a USING on register 13, referencing the name of the save area. For reserving the 18 fullwords of storage for a save area, use DC instead of DS. A constant of F'0', or F'-1' will quickly show in a dump if the save area was ever used. SAVE and RETURN are two system macros which will eliminate much of the coding for saving and returning conventions. SAVE generates the code necessary to save a specified series of registers. The registers are specified as they would be for a STM instruction. In addition, the operand T will cause registers 14 and 15 to be stored, regardless of what other registers may also be saved from the pair specified. The following example will cause registers 5, 6, ... 10 and 14 and 15 to be saved. SAVE (5,10),T The RETURN macro will generate code to restore registers, insert a ret- urn code in register 15, flag the save area (X'FF' in wd. 4), and branch back via register 14. The registers to be restored are coded as with SAVE. If 15 already has a return code in it and should not be restored, it is coded as RC=(15); else RC=n may be coded, where n is some value to insert into register 15. The operand T causes the flag X'FF' to be inserted in the save area. The following code will restore registers 5, 6, ... 10 to be reloaded, the save area to be flagged, and 15 to be loaded with a value 16. RETURN (5,10),T,RC=16 **NOTE** Both of these macros expect that register 13 will already be loaded with the address of the appropriate save area. , LINKAGE-5 The use of the PSU macros XSAVE and XRETURN can provide added flexibility in saving and restoring registers. Both can generate code to print a trace message showing entry and exit from a module; XSAVE can be used to establish and load a base register or to print a snap of the registers saved; XRETURN can create a save area. NOTE that as with RETURN, XRETURN assumes that register 13 still points to the relevant save area. For most uses, the code XSAVE alone can be used to save regis- ters. For a routine with only one return point, XRETURN SA=* will suf- fice; if a routine has more than one return point, however, XRETURN alone should be coded at all return points except one, and at that one XRETURN SA=* should be coded. The reason for this is that SA=* will cause a save area to be created; only one should be created per module. For further details on the parameters involved in these two macros, see the appropriate PSU documentation. The following example causes register 12 to be established as a base register, causes all registers to be saved on entry, cuases no trace messages to be printed on entry or on exit, and causes R15 to be loaded with the return code value 8. MAIN CSECT XSAVE BR=12,TR=NO (Note--default is for all registers to be saved) XRETURN SA=*,TR=NO,RC=8 , , CMPSC 411 - DSECT Example PRINT NOGEN EQUREGS MAIN CSECT XSAVE . ESTABLISH STANDARD LINKAGE CALL NEXT CALL LOWER ROUTINE XRETURN SA=* ESTABLISH SAVE AREA LTORG NEXT CSECT XSAVE . ESTABLISH STANDARD LINKAGE CALL LAST CALL LOWEST ROUTINE XRETURN SA=* ESTABLISH SAVE AREA LTORG LAST CSECT XSAVE . ESTABLISH STANDARD LINKAGE CALL TRACE CALL TRACE RTN TO PRNT S.A. XRETURN SA=* GENERATE SAVE AREA LTORG * * THE ABOVE ROUTINES DO NOTHING BUT ESTABLISH LINKS TO TRACE * THROUGH THE SAVE AREAS * * * ROUTINE TRACE PROVIDES A PRINTED TRACE OF THE NAMES OF THE * CSECTS OF ACTIVE S.A.'S. IT USES DSECTS SAVEAREA AND NAMECONV * TO FORMAT THE SAVEAREA AND FIRST FEW BYTES OF THE PROGRAM. * TRACE CSECT XSAVE SA=TRACESA ESTABLISH LINKS USING SAVEAREA,R13 USING NAMECONV,R15 XPRNT =CL25'0BACK TRACE OF SAVE AREAS--',25 L R13,4(R13) CONNECT TO FIRST ACTIVE S.A. LOOP LTR R13,R13 CHECK IF END OF CHAIN BZ DONE IF YES, EXIT L R15,REG15SAV GET PTR. TO BEGIN. OF CSECT CLC BRANCH,=X'47F0' CHECK TO SEE IF VALID BRANCH BNE ERROR IF NOT, ABORT IC R7,LENGTH PICK UP LENGTH OF NAME BCTR R7,R0 SET UP FOR EXECUTE EX R7,MOVE MOVE CHARS. OF NAME TO OUTPUT XPRNT OUT,40 PRINT NAME OF ROUTINE MVC OUT+1(39),OUT BLANK OUT OUTPUT AREA LM R14,R11,REG14SAV RELOAD REGS. (FOR RETURN) L R13,BACKLINK FOLLOW LAST LINK B LOOP DONE XPRNT =CL25'0BACK TRACE COMPLETED',25 LA R13,TRACESA XRETURN SA=TRACESA ERROR XPRNT =CL25'0ERROR IN TRACE-BACK',25 ABEND 999 ABORT MOVE MVC OUT+1(*-*),NAME INSTR. FOR EXECUTE OUT DC CL40' ' LTORG , DSECT - 2 * * THE FOLLOWING DSECT FORMATS THE SAVE AREA * SAVEAREA DSECT UNUSED DS F BACKLINK DS F PTER TO HIGHER S.A. FORELINK DS F PTER TO LOWER S.A. REG14SAV DS F SAVE AREA FOR REG 14 REG15SAV DS F START OF S.A. FOR REG 15-12 * * THE FOLLOWING DSECT FORMATS THE BEGINNING OF A CSECT. IF THE * NAME CONVENTION IS FOLLOWED, THE FIRST INSTR MUST BE A BR. ON * R15 AS A BASE REG. FOLLOWED BY A LENGTH AND A NAME. * NAMECONV DSECT BRANCH DS XL2,XL2 SPACE FOR BSC INSTR(4 bytes) LENGTH DS C NAME DS C SPACE FOR NAME (MARK BEGINNING * ADDR. ONLY) END MAIN /* Following is the output from this example-- *** MAIN ENTERED *** *** NEXT ENTERED *** *** LAST ENTERED *** *** TRACE ENTERED *** BACK TRACE OF SAVE AREAS TRACE LAST NEXT MAIN IEWLCTRL BACK TRACE COMPLETED *** TRACE EXITED *** *** LAST EXITED *** *** NEXT EXITED *** *** MAIN EXITED *** , DSECT - 3 Following is the actual assembler listing of the TRACE csect. Notice those instructions which reference labels from the SAVEAREA and NAMECONV dsects. Look at the object code and see what the base register and displacement by which they were assembled is. LOC OBJECT CODE ADDR1 ADDR2 STMT SOURCE STATEMENT 000300 192 TRACE CSECT 193 XSAVE SA=TRACESA 000000 220 USING SAVEAREA,R13 000000 221 USING NAMECONV,R15 222 XPRNT =CL15' BACK TRACE 000386 58DD 0004 00004 232 L R13,4(R13) 00038A 12DD 233 LOOP LTR R13,R13 00038C 4780 C07E 003E0 234 BZ DONE 000390 58F0 D010 00010 235 L R15,REG15SAV 000394 D503 F000 C1C6 00000 00528 236 CLC BRANCH(2),=X'47F0 00039A 4770 C13A 0049C 237 BNE ERROR 00039E 4370 F004 00004 238 IC R7,LENGTH 0003A2 0670 239 BCTR R7,0 0003A4 4470 C170 004D2 240 EX R7,MOVE 241 XPRNT OUT,40 0003CE D226 C177 C176 004D9 004D8 251 MVC OUT+1(39),OUT 0003D4 98EB D00C 0000C 252 LM R14,R11,REG14SAV 0003D8 58D0 D004 00004 253 L R13,BACKLINK 0003DC 47F0 C028 0038A 254 B LOOP 255 DONE XPRNT =CL20'TRACE COMPL 000406 41D0 C0F2 00454 265 LA R13,TRACESA 266 XRETURN SA=TRACESA 285 ERROR XPRNT =CL20'ERROR IN TR 295 ABEND 999,DUMP 0004D2 D200 C177 F005 004D9 00005 303 MOVE MVC OUT+1(*-*),NAME 0004D8 4040404040404040 304 OUT DC CL40' ' 000500 305 LTORG 310 * 000000 311 SAVEAREA DSECT 000000 312 UNUSED DS F 000004 313 BACKLINK DS F 000008 314 FORELINK DS F 00000C 315 REG14SAV DS F 000010 316 REG15SAV DS F 317 * 000000 318 NAMECONV DSECT 000000 47F0 F000 00000 319 BRANCH B 0(,15) 000004 320 LENGTH DS C 000005 321 NAME DS C 322 * 000000 323 END MAIN , 00001000 CS102M1 - 01 00001010 00001020 COMPUTER SCIENCE 102 - RUN ASSIGNMENT 00001030 00001040 1. Punch up the following program and run: 00001050 // YOUR JOB CARD 00001060 // EXEC ASACG 00001070 //SYSIN DD * 00001080 MAIN CSECT 00001090 * THIS PROGRAM ILLUSTRATES XDUMP AND PROGRAM INTERUPTION 00001100 BALR 12,0 THESE TWO STMTS ARE FOR 00001110 USING *,12 COMMON LINKAGE CONVENTIONS 00001120 LA 3,CARD PTR TO CARD IMAGE READ IN 00001130 XREAD CARD,80 READ DATA CARD 00001140 XPRNT CARD,80 ECHO PRINT 00001150 XDECI 4,0(3) CONVERT DECIMAL TO INTERNAL HEX 00001160 XDECI 5,0(1) CONVERT NEXT # ON CARD 00001170 * THE NEXT STMT PRINTS CONTENTS OF USERS REGISTERS. 00001180 * NOTE REG 4,5 00001190 XDUMP 00001200 B 4000 ABEND-BRANCH OUT OF PROGRAM 00001210 CARD DS 80C 00001220 END 00001230 /* 00001240 //DATA.INPUT DD * 00001250 100 -1024 00001260 /* 00001270 00001280 00001290 00001300 2. This next program is a batch run of 5 jobs, each terminating 00001310 abnormally. The program is stored on RJE file. Punch up the 00001320 follwoing cards EXACTLY to run the program 00001330 // YOUR JOB CARD 00001340 // EXEC ASACG,PARM=BATCH 00001350 //SYSIN DD * 00001360 /*INCLUDE RAB01.BATCH 00001370 /* 00001380 00001390 3. To merely get a listing of the prog in 2., use the following cards: 00001400 // YOUR JOB CARD 00001410 /*INCLUDE RAB01.PRINT 00001420 /*INCLUDE RAB01.BATCH 00001430 /* 00001440 , CS102M1 - 02 A GUIDE TO S/360 MNEMONIC OPERATION CODES I. INTRODUCTION The beginning programmer facing the variety of operations available on a modern large computer is often overwhelmed by the large number of operations and complexity thereof. In some cases, a few hints can be helpful in learning and remembering the names, purposes, and usage of the various operations. In particular, certain properties of S/360 menemonics can help the learner a great deal. Some of them are: A. REGULAR SCHEME FOR NAMING OPCODES In general, a fairly coherent and regular method has been used in naming operations. In some cases, it is possible to determine the bit pattern and operation of a mnemonic just from looking at it. Related operations usually have related mnemonics. B. COMMONLY USED MNEMONICS The designers apparently went to some effort to make the most often used mnemonics the shortest and easiest to remember. Most of these have 1 or 2 letter mnemonics. II. NAMING OF MNEMONIC OPCODES A. VERB (MODIFIER) (DATA TYPE) (MACHINE FORMAT) The mnemonics generally follow the format given above, with the VERB always present, while the others may be omitted. The general meanings of the fields are given below. 1. VERB: specifies a general type of action performed, such as addition, subtraction, comparison, data movement. 2. MODIFIER: specifies a modification of the general action given by the verb, such as logical addition (rather than algebraic), moving multiple registers rather than single ones, and performing different actions while loading one register into another. 3. DATA TYPE: specifies the type of data being operated on, and is usually the same letter as that used to define a constant of the given type, such as H (halfword), P (packed decimal), etc. 4. MACHINE FORMAT: gives the type of machine instruction being used. This is most typically done by adding R or I to an RX mnemonic to obtain a similiar RR or SI instruction. In general, the RX instructions, which are the heaviest used, have the shortest mnemonics, and most of the other instructions can be built from them by adding more letters. , CS102M1 - 03 B. EXAMPLES OF COMMONLY USED MNEMONIC ELEMENTS The following sections explain the common mnemonic elements. 1. VERBS VERB MEANING, COMMENTS ---- -------------------------------------------------------------- A Add two numbers (which may be binary, decimal, or floating) B Branch to another instruction (like GOTO) C Compare two fields (numbers or character strings) CV ConVert a number from one base to another D Divide one number by another L Load a quantity into a register from another or from storage M Multiply one number by another MV MoVe information from one area in storage to another. N aNd information together (logical AND) O Or information together (logical OR) S Subtract one number from another ST STore a register (or part of one) into storage X eXclusive or information together (logical exclusive OR) For example, note that a given VERB may begin many instructions, which immediately shows they are related to each other. For example, the following are all comparison operations: C, CD, CE, CH, CL, CP, CR, CDR, CER, CLC, CLR. 2. MODIFIERS The following lists verbs and their common modifiers. VERBS MODIFIERS MEANING, EXAMPLES -------- -------- ---------------------------------------------------- A,C,S L Logical addition, comparison, or subtract is used rather than algebraic. EX: AL, CL, CLC, SLR. B AL And Link - form of branch for doing linkage to subroutine so it can return. EX: BAL, BALR C Condition - branch or not depending on a previously set condtion (IF(--) GOTO --). EX: BC, BCR. CT Count - branch form used to decrement a register and branch if value not zero (DO LOOP). EX: BCT, BCTR. X indeX - branch form for incrementing and testing index quantities. (DO LOOP). EX: BXH, BXLE. L C Complement - used to set a register to complement itself or other (Y = -ABS(X)). EX: LNR, LNDR. P Positive - set register to positive value from self or other (Y = ABS(X)). EX: LPR, LPER. T Test - set register to value from self or other, L,ST M Multiple - several registers are loaded or stored in one operation. EX: LM, STM , CS102M1 - 04 3. DATA TYPES As noted previously, a data type character is usually the same as that used in a DC or DS statement to obtain a given type of data. If a type character is omitted, it usually implies that the instruction operates on 32-bit, fullword, binary quantities (such as A, C, S, etc). DATA TYPE MEANING, COMMENTS -------- --------------------------------------------------------- C Character - usually a contiguous string of bytes in memory, treated as printable characters or a string of bits. (FORTRAN LOGICAL*1). EX: MVC, CLC, OC, IC, STC. USUALLY IMPLIES SS INSTRUCTION FORMAT (all except IC, STC). D Double precision floating point (Doubleword, 64 bit) (FORTRAN REAL*8). EX: AD, SD, LTDR, LD. IMPLIES RR OR RX INSTRUCTION FORMAT. E Exponent - single precision floating point (fullword, 32 bit, FORTRAN REAL*4). EX: AE, LER, ME. IMPLIES RR OR RX INSTRUCTION FORMAT. H Halfword - 16 bit binary number (FORTRAN INTEGER*2) EX: AH, MH, STH, CH. IMPLIES RX FORMAT. P Packed decimal format (2 decimal digits per byte). EX: AP, SP, CP. IMPLIES SS INSTRUCTION FORMAT OF TWO-LENGTH TYPE. 4. MACHINE FORMATS Several characters are used to denote the specific type of operand format being used (note that the data types can also imply specific formats. If they imply one of several, the last character distinguishes among them). FORMAT MEANING, EXAMPLES -------- ---------------------------------------.---------------------- I Immediate - IMPLIES SI FORMAT. EX: MVI, CLI, OI. R Register - IMPLIES RR FORMAT. EX: AR, BCR, DDR. , CS102M1 - 05 III. EXAMPLE OF FAMILY OF RELATED OPCODES This section lists all the members of the 'Compare' family of menemonics, showing their relationships adn the elements present in each name. The letters V M D F stand for Verb, Modifier, Data type, and machine Format. OP-CODE V M D F TYPE COMMENTS ---- - - - - -- ----------------------------------------------- C C RX fullword algebraic compare, the basic one. CL C L RX fullword logical comparison (logical modifier) CD C D RX compare double precision floating numbers CE C E RX compare single precision floating numbers CH C H RX compare a register algebraicly with halfword from storage (with sign extension) CP C P SS compare two packed decimal numbers CR C R RR compare two fullword values algebriacly, gotten from C by adding R. CLC C L C SS compare logically character strings CLI C L I SI compare logical immediate (a byte in memory with the one inside the instruction) CDR C D R RR compare double precision (in registers) CER C E R RR compare single precision (in registers) The Sytem/370 computers have some additional opocdes: CLM C L M RS compare logical masked (from register to mem) CLCL C L C L RR compare logical character strings long (up to 16 million bytes in one compare) Consider the problem of writing a FORTRAN program which would simulate the operation of the instructions above (i.e., maintain variables representing PSW, Memory, GP Registers, etc, and go through the Fetch-Instruction, Decode, Fetch-Operands, Execute cycle). The arrangement of the opcodes would make it easy to share code, i.e., it would not be necessary to code each instruction separately. As an example, consider the following related instructions: MNEMONIC HEX CODE BINARY CODE SAMPLE INSTRUCTION/ASSEMBLED -------- -- -------- ------------------------------------- CR 19 0001 1001 CR 0,1 1901 CH 49 1000 1001 CH 0,2(3,4) 49034002 C 59 1001 1001 C 0,4(5,6) 59056004 Examine the bit patterns above. The first teo bits give the Machine Format (00-RR, 10-RX), the third and fourth give a Data Type (01-Fullword,00-Halfword in this case). The fifth-eighth bits give the Verb (1001 - algebraic Compare). In essence, there is only 1 Compare, which is branched to after the operands are obtained. , 00001000 CS102TPA - 01 00001010 00001020 COMPUTER SCIENCE 102 - TOPICS COVERED, HANDOUTS 00001030 WINTER TERM 1972 - MASHEY 00001040 00001050 The handouts given are described in file CS102HN. 00001060 00001070 # DATE TOPICS, HANDOUTS, READING ASSIGNMENTS 00001080 -- --/--/72 ---------------------------------------------------------00001090 00001100 1 01/07 introduction to course. prerequistites (101, 401, equiv)00001110 listed text materials for course: 00001120 1) STRUBLE: ASSEMBLER LANGUAGE PROGRAMMING: IBM SYSTEM/360 00001130 2) IBM: SYSTEM/360 PRINCIPLES OF OPERATION (POP) 00001140 3) IBM: S/360 OS ASSEMBLER LANGUAGE 00001150 4) PSU: ASSIST INTRODUCTORY ASSEMBLER USER'S MANUAL 00001160 (25 cents, at 426 McAllister) 00001170 5) IBM: S/360 REFERENCE CARD (GREEN CARD- BRING TO CLASS) 00001180 00001190 introduction to information representation in computer. 00001200 memory, addressing, similiarity to FORTRAN vector wit1 index 00001210 beginning at 0 rather than 1. elements of memory in S/360: 00001220 byte, halfword, fullword, doubleword. 00001230 positional notation. number systems (binary, octal, decimal, 00001240 hexadecimal). conversion between them, uses. 00001250 representations of binary numbers: Two's complement, One's 00001260 complement, Sign-magnitude. advantages and disadvantages: 00001270 (TC - 1 zero, but harder for people; OC - 2 zeroes, but easier00001280 to handle; SM - easiest to handle, but slower circuitry) 00001290 00001300 READING: STRUBLE CHAPTER 1. Look at ASSIST PART III. 00001310 00001320 00001330 2 01/10 more on information representation; introduction to 00001340 machine structure. 00001350 00001360 meanings of bit patterns: 1,2,4-byte binary numbers; charcters00001370 packed decimal (good for people, but wastes space); floating 00001380 point (sign, characterisitc, and fraction). 00001390 00001400 structure of a very simple machine: memory of 16-bit words; 00001410 1 register; 1 program coiunter. a few instructions, each with00001420 opcode and address. explanation of basic instruction cycle: 00001430 1) Fetch instruction from where program counter points. 00001440 2) Increment program counter. 00001450 3) Decode instruction into its parts. 00001460 4) Execute instruction. 00001470 5) Loop back to 1. 00001480 00001490 S/360 machine structure: memory (note abbrev. K), GP and 00001500 floating point registers, PSW. refer to GREEN CARD. 00001510 00001520 Begin instruction types: 00001530 1) RR (names with -R, examples) 00001540 2) RX (give first explanation of base-displacement) 00001550 3) RS 00001560 00001570 READINGS: STRUBLE - CHAPTER 2; POP - pp. 7-15. 00001580 HANDOUTS: CS102M1 - page 01 (run some ASSIST programs for dumps) 00001590 , 00002000 CS102TPA - 02 00002010 00002020 3 01/12 finish operands formats and introduce assembly language. 00002030 00002040 4) SI instructions (examples: MVI, CLI) 00002050 5) SS instructions (examples: MVC, CLC) 00002060 machine language - easy for machine to execute, hard to write 00002070 assembly language converted by assembler to machine code. 00002080 00002090 format of assembly language: label opcode operand comments 00002100 machine instructions - actual operations to be executed 00002110 assembler instructions (pseudo ops) - give information to 00002120 the assembler (ex: CSECT, DS, DC) 00002130 some basic functions of the assembler: 00002140 1) location counter 00002150 2) convert mnemonic opcodes 00002160 a) machine ops - translate to codes, increm location cntr00002170 b) assembler ops - take actions specified, increm loc cnt00002180 3) operands - convert to internal binary, base-displacement 00002190 4) print out a listing 00002200 5) make program ready for execution and pass control to it 00002210 00002220 stepped through complete test program (XREAD, XPRNT, XDECI, 00002230 XDUMP) and explained listing and contents of dump. 00002240 00002250 READINGS: STRUBLE: Chapter 3; ASSIST MANUAL: PARTS II and IV; 00002260 ASSEMBLER LANGUAGE: pp. 1-18. 00002270 HANDOUTS: DOCUMENT (documentation techniques for assembler) 00002280 00002290 4 01/14 go over some dumps and errors; discuss operand fields. 00002300 00002310 go through various dumps, showing 0C1, 0C4, and 0C6 errors. 00002320 cover STRUBLE cahpter 3, pp.50-56: symbols, self-defining 00002330 terms, literals, location counter reference, absolute and 00002340 relocatable terms, expressions. 00002350 00002360 READINGS: STRUBLE: Chapter 4 to page 78. 00002370 ASSIGNMENT: STRUBLE: Chapter 1: problems 5,6,7,8,9. Chapter 2: 00002380 problems 2,3. Chapter 3: problems 1,2,3,4,6. 00002390 INFORMAL ASSN: modify dump program to use XDECO and DUMP storage; 00002400 use program with START to check relocatable vs absolutes. 00002410 modify one of batch programs to get 0C6 rather than 0C4. 00002420 00002430 5 01/17 introduction to arithmetic and data movement instructions00002440 introduce idea of instruction families and regularity of 00002450 mnemonics. Go thru following instructions: LR, LPR, LCR, LNR,00002460 LTR, L, LH, LA. AR, ALR, A, AL, AH, SR, SLR, S, SL, SH. 00002470 mention M and D, also briefly note existence of Condition Code00002480 and show how to test it, without worrying about encoding. 00002490 20-minute question answer and review: questions occurred on 00002500 differences between literals and self-defining terms, and on 00002510 use of symbolic register equates. 00002520 00002530 READINGS: STRUBLE: Chapter 5. 00002540 HANDOUTS: CS102AS1 (pages 01 - 02) first assignment - input, 00002550 output of numbers, calculations in binary. 00002560 CS102M1 (pages 02 - 05) S/360 mnemonic construction. 00002570 , 00003000 CS102TPA - 03 00003010 00003020 6 01/19 quiz and finish up data movement and binary arithemetic. 00003030 Twenty-minute quiz (diagnostic mainly): base conversions (2, 00003040 8, 10, 16); negative numbers, base-index-displacement addrs, 00003050 relocatable vs absolute. 00003060 Instructions: LM, STM, MVC, MVI. M, MR, D, DR, MH and hints 00003070 on what to watch for. 00003080 Programming techniques: review input/output & conversions 00003090 (XREAD, XPRNT, XDECI, XDECO); method for building messages 00003100 and obtaining length for XPRNT via MSGL EQU *-MSG . 00003110 00003120 ASSIGNMENT: indexing and comparison assignment, CS102AS1 - 03, 00003130 due 02/02/72. 00003140 HANDOUTS: CS102AS1 - 03 (labeled CS 102 AS2 also) - indexing. 00003150 READINGS: STRUBLE CHAPTER 5, start on STRUBLE CHAPTER 7. 00003160 00003170 7 01/21 condition code, branching instructions, loops. 00003180 condition code values and encoding. BCR, BC, Extended 00003190 Mnemonics (recommended for use over BC #). BALR, BAL and 00003200 subroutines, BCT, BCTR usage, including decrementing regs. 00003210 example of basic loop to sum array of numbers. 00003220 flowcharting and good design versus kludge programming. 00003230 00003240 READINGS: STRUBLE Chapters 7,8,5. 00003250 00003260 8 01/24 finish loop control, begin on USING/DROP, linkage 00003270 Explain BXH, BXLE instructions, give typical setups: 00003280 forward BXLE loop, backwards BXH loop, BXH scan loop. 00003290 show need for USING command. give rules for computation of 00003300 base displacements: minimum base displacement for those which00003310 are available, higher numberred register if several have same.00003320 begin conventions: exaplin registers 15, 14 usage on entry. 00003330 00003340 HANDOUTS: LINKAGE OS/360 linkage conventions 00003350 READINGS: STRUBLE: Chapter 5, LINKAGE HANDOUT 00003360 00003370 9 01/26 savearea linkage ans ome review. 00003380 Describe 18-fullword save area. go through the standard code 00003390 used at beginning and end of a routine, calling methods. Do 00003400 not work on argument passing, just normal code. 00003410 Misc. instructions: IC, STC, start on Shifts. 00003420 Various review for problems. 00003430 Note general usage of registers: get students into good habits00003440 00003450 READINGS: STRUBLE: Chapter 11. 00003460 00003470 10 01/28 logical/algebraic arithmetic, shifts 00003480 20-minute quiz on previous instructions. 00003490 differences between condition code setting, aroverflow in 00003500 algebraic arithmetic and logical arithmetic. examples. 00003510 shift instructions and how they are used. 00003520 READINGS: STRUBLE: Chapter 11, begin on chapter 10. 00003530 , 00004000 CS102TPA - 04 00004010 00004020 11 01/31 bit manipulation and uses. review on branching 00004030 bit manipulation instructions: NR, XR, OR, N, X, O, NI, XI, 00004040 OI, NC, XC, OC, plus TM. what they do, and how to use them. 00004050 EQU trick for SI instructions and how to use it. 00004060 review: prototypes on loop control, advantages/disadvantages.00004070 00004080 READINGS: STRUBLE: Chapter 10, first 3 sections. 00004090 00004100 12 02/02 assembler housekeeping, misc areas. 00004110 go over all of DC, DS operand formats in detail, showing 00004120 what can exist as duplication factor-type-length-constant, 00004130 including multiple operands and constants, expressions as 00004140 duplication factors and length modifiers. also cover 00004150 TITLE, EJECT, SPACE 00004160 00004170 READINGS: STRUBLE: CHAPTER 6, pp 110-121, problems 7,9,10 00004180 ASM LANG: 3, 7-9, 10-18 (except variable symbols/sequence 00004190 symbols, 19-21, 29-33. section 5: EQU, DC (all except Bit 00004200 Length Modifier, Scale Modifier, Exponent Modifier. all types 00004210 except E, D, L, P, Z,Y, S, Q, complex relocatability). DS, 00004220 ORG, LTORG, END. SPACE, EJECT, TITLE 00004230 POP: pp 24-34 except CVB, CVD. Logical instructions except 00004240 TR, TRT, ED, EDMK. Branching except EX. 00004250 00004260 13 02/04 give out final project, discuss assembler/interpreters 00004270 concepts of assemblers: 2 pass assemblers, how to set up 00004280 opcode and symbol tables (indexed jump methods), output 00004290 desired. 00004300 go over structure of SIGMA 4.5 computer and its interpreter, 00004310 noting indirect addressing in particular. 00004320 00004330 HANDOUTS: CS102FP1 (01 -08) general assembler/interpreter descr 00004340 CS102FP2 (01 -06) specific material for final project 00004350 00004360 ASSIGN: Final project, due 13 March (described in CS102FPx) 00004370 00004380 14 02/07 decimal numbers and conversions 00004390 zoned/packed decimal to and from binary. PACK, UNPK, CVB, CVD00004400 equivalent codes using M, D loops for decimal-binary-decimal. 00004410 examples of various formats/conversions. 00004420 00004430 READINGS: STRUBLE: Chapter 5: 106-110, Chapter 218-228, 228-233.00004440 00004450 15 02/09 misc review, misc instructions, program mask. 00004460 SPM instruction, use of program mask, review BXLE, BXH, etc. 00004470 00004480 00004490 16 02/11 MIDTERM 00004500 covered data representations, most standard instructions, 00004510 hand assembly, etc. 00004520 , 00005000 CS102TPA - 05 00005010 00005020 17 02/14 on midterm and final project 00005030 review of midterm results and problem areas. final project: 00005040 overall structure, useful modules and how to set them up: 00005050 decimal scan and output conversions, symbol scan, symbol table00005060 manager, opcode lookup, hexadecimal output, etc. 00005070 review of BXLE loop control. 00005080 HANDOUT: CS102PX1 (01 - 03) programming exercises: hand assembly, 00005090 interrupts. 00005100 00005110 18 02/16 more on assembly process, location counter control. 00005120 use of ORG to set up tables, timetable for gettting final 00005130 project done, program design process and debugging. 00005140 00005150 19 02/18 quiz, TR, TRT 00005160 30-minute quiz: hand assembly, BXLE loop setup. 00005170 TR uses, setup, workings. 00005180 TRT uses, setup, examples. 00005190 00005200 READINGS: STRUBLE CH 15: pp 342-345, 350-352. prob 1,3,4. 00005210 ASSIGN: write TRT table for scanning over hex digits. 00005220 20 02/21 programming techniques, use of TR, TRT, conversions use of global table pointer, examples on TR, TRT. decimal input conversion, using two TRT's, EX, PACK, CVB. hexadecimal output conversion, using UNPK, TR. ASSIGN: write code to perform conversions, also to read in names, place in table, then search table for later names. READINGS: STRUBLE CH 15: ED, EDMK start. 21 02/23 conversions - hexadecimal input, decimal output, ED go through hexadecimal input, but not in detail (TRT, TRT, EX of MVC right-justified, TR, PACK 9 into 5, ignoring extra byte) decimal output: CVD, UNPK, OI for plus number, with leading zeroes. decimal output: begin on ED, EDMK, doing parts with basic workings of ED, and standard pattern for integer numbers. , CS102AS1 - 01 COMPUTER SCIENCE 102 - ASSIGNMENT 1 DUE __________ This assignment covers simple input/output, binary arithmetic for fullword and halfword numbers, and basic data movement and testing codes for handling such numbers. AI. BASIC PROGRAM The basic program should do the following: A. Read a card (XREAD), and print it out immediately (called an ECHO CHECK - standard practice). The card contains 5 numbers punched on it, which are to be scanned and converted (XDECI) to binary form, and placed in 5 consecutive fullwords in memory. Print the hexadecimal values of these 5 words (20 bytes), using XDUMP. B. Perform the following computations in a straightforward way, storing each result in name given, using RX instructions where you can): 1. F = A + B + C 2. G = -A - B - C (LCR useful) 3. H = A * B * E 4. I = A / B (be careful, watch for negative #'s) 5. J = MOD(A,B) (i.e., remainder from# 4.) 6. K = ((A + E) * (B - C)) / D C. Print all of the above values (F - K) in hexadecimal (XDUMP), then also print them in decimal, using XDECO and XPRNT (print their values an headings all on one line. D. According to the sign of result H, print one of the 3 messages: H IS LESS THAN ZERO, H IS GREATER THAN ZERO, H IS ZERO. II. EXTENDED VERSION OF PREVIOUS PROGRAM Modify the previous program (which only had to read 1 card), to read cards and follow the actions above for each card, until there are no more cards (END-OF-FILE). Keep a count of the number of cards read, and print out this total number before ending the program. III. HALFWORD VERSION OF PROGRAM II. Modify program II to use halfwords wherever possible (i.e., store A - K as halfwords, use AH instead of A, etc. Watch out for divides, since no DH instruction exists). How much storage is saved? IV. REGISTER VERSION OF PROGRAM II. Change program II by saving all values A - F in registers, then use RR instructions rather than RX instructions. Do XDECI commands directly into registers where the values are saved. A useful trick may be to NAME the registers symbolicly: RA EQU 3 REGISTER WHERE VALUE A KEPT XDECI RA,CARD CONVERT VALUE A INTO REG RA This technique will make it clear which value you are using (note that any register reference can be symbolic to an EQU symbol). , CS102AS1 - 02 V. WHAT TO HAND IN By using the BATCH feature in ASSIST, you can run several programs in one run. Turn in one run, with each of the programs II, III, and IV shown in execution, with results and output as requested. The run will use control cards like: // EXEC ASACG,PARM=BATCH //SYSIN DD * $JOB ASSIST PROGRAM VERSION II ..... program II $ENTRY ..... test data *** repeat above, starting at $JOB, for programs III and IV. /* The following test data should be used for each program: A B C D E 5 2 -4 -2 2 -2 -1 10 1 -1 4096 1 1 -1 -1 Note that the columns they are punched in should not matter. , CS102AS1 - 03 COMPUTER SCIENCE 102- ASSIGNMENT 2 This assignment uses the concept of indexing________ into an array of elements. I. BASIC PROGRAM A. Read a card (and echo print) containing a maximum of 20 numbers. Convert the numbers to hex(XDECI) and store them in successive fullwords in memory. Use a loop to eliminate redundant coding. Then, for each card, find the maximum value and the minimum value, printing out these numbers with appropriate labels. B. Form of data 1. Each card contains a maximum of 21 numbers, where the first number =the number of numbers on the card. You will need the first number for a counter in the loop in part A. 2. There are an un__ specified # of data cards. i.e., make your program general to accept any # of data cards. II. DATA FOR _OUR PROGRAM 3 56 76 -76 7 11 123 432 -123 748 -9087 -0 6 33 33 45 10 6 90 4 145 1024 6698 -1024 345 $ ,>AAAINDEX OVERALL INDEX. , 00001000 PRIME INDEX - J R MASHEY 00001010 00001020 THIS FILE PROVIDES THE PRIME INDEX TO FILES WHICH ARE INSTRUCTIONAL00001030 FILES OF MATERIAL TO BE INCLUDED ON THE ASSIST DISTRIBUTION TAPE. 00001040 THE FORMAT OF THIS FILE ALLOWS IT TO BE USED TO PRODUCE PSU JCL 00001050 INCLUDE CARDS TO BE USED TO COPY THESE FILES FROM BAT FILES TO TAPE. 00001060 00001070 EACH FILENAME IS PRECEDED BY '>', AND FOLLOWED BY A PSU RJE ID, 00001080 IF THE FILE IS NOT SAVED UNDER RJE ID JRM02, WHICH IS THE DEFAULT. 00001090 00001100 THE PROGRAM JRM05.BATCOPY READS THIS FILE AND PRODUCES JOBS 00001110 TO COPY THE FILES TO TAPE. ON TAPE, THE FORMAT OF THE FILES IS: 00001120 00001130 ,>FILENAME BEGINNING IN COLUMN 1, ON A SEPARATE CARD 00001140 PRECEDING EACH FILE. THE COMBINATION ',>' IS 00001150 NOWHERE ELSE USED IN THE TAPE FILE, SO THAT IT IS 00001160 EASY TO SEARCH THE FILE FOR A SPECIFIC SECTION 00001170 AND PUNCH OR PRINT IT. 00001180 00001190 NOTES: THE FOLLOWING COMMENTS MAY BEGIN THE DESCRIPTIONS: 00001200 (JCL): THE FILE CONTAINS JOB CONTROL LANGUAGE CARDS FOR USE ON A 00001210 OS/360/370 SYSTEM, PLUS TYPICAL SAMPLE PROGRAMS. 00001220 (TEXT): THE FILE CONTAINS TEXT MATERIAL, WITH EACH PAGE BEGUN BY A 00001230 CARD HAVING ',' IN COLUMN 1. THESE ALSO HAVE LOWER CASE LETTERS, 00001240 AND SO TYPICALLY REQUIRE A 'TN' PRINT TRAIN OR EQUIVALENT FOR 00001250 BEST APPEARANCE. 00001260 00001270 >AAAINDEX OVERALL INDEX. 00001280 00001290 >ASBROPS2 (TEXT) ASSIGNMENT USING ASSIST REPLACE MONITOR 00001300 TO REPLACE THE BASE REGISTER PART OF ASSIST. SEE 00001310 ASREPLGD, AND $ASBROPS2 00001320 >$BRTEST TEST DATA FOR USE WITH ASSIGNMENT ASBROPS2 00001330 00001340 >ASPRGTC1 (TEXT) ASSEMBLER PROGRAMMING TECHNIQUES: LINKAGE, 00001350 MACROS, MODULAR PROGRAMMING. 00001360 00001370 >ATTACH (JCL) - OS/360 SAMPLE PROGRAM- ATTACH, DETACH, ETC 00001380 00001390 >BDAM1 (JCL) - OS/360 BDAM EXAMPLE, PART 1 OF 2 00001400 >BDAM2 (JCL) - OS/360 BDAM EXAMPLE, PART 2 OF 2 00001410 00001415 >BPAM (JCL) - OS/360 BPAM EXAMPLE 00001420 00001430 >BSAM (JCL) -OS/360 BSAM EXAMPLE 00001440 00001450 >CS102AS1 (TEXT) - 1ST ASSEMBLER COURSE ASSIGNMENT 00001460 >CS102FP1 (TEXT) - FINAL PROJECT IN FIRST COURSE - PART1. 00001470 >CS102FP2 (TEXT) - 2ND PART OF FINAL PROJECT (WHICH ISAN 00001480 (ASSEMBLER INTERPRETER FOR SMALL MACHINE) 00001490 >CS102M1 (TEXT) - MISC. WRITEUPS FOR 1ST ASM COURSE 00001500 >CS102TPA (TEXT) - DAY-BY-DAY OUTLINE OF 1ST ASSEMBLER COURSE 00001510 00001520 , 00002000 AAAINDEX - 02 00002010 00002020 >CS411AS1 (TEXT) - 2ND ASSEMBLER COURSE, 1ST ASSIGNMENT: 00002030 LINKAGE BETWEEN FORTRAN/ASSEMBLER, PARM FIELD 00002040 ACCESS. OS/360. 00002050 >CS411GI1 (TEXT) - GENERAL INFORMATION, COURSE OUTLINE, 00002060 INDEX, ETC FOR 2ND ASSEMBLER/SYSTEMS COURSE, 1 OF 2 00002070 >CS411GI2 (TEXT) - GENERAL INFORMATION ETC, PART 2 OF 2. 00002080 00002090 >CS411FP1 (TEXT) - A FINAL PROJECT ASSIGNMENT WRITEUP FOR A 00002100 SIMULATOR FOR MULTIPROGRAMMING OPERATING SYSTEMS, 00002110 FOR USE IN 2ND ASSEMBLER/SYSTEMS COURSE. PART 1 OF 400002120 >CS411FP2 (TEXT) - FINAL PROJECT, PART 2 OF 4 00002130 >CS411FP3 (TEXT) - FINAL PROJECT, PART 3 OF 4 00002140 >CS411FP4 (TEXT) - FINAL PROJECT, PART 4 OF 4 00002150 00002160 >CS411MC1 (TEXT) - MACRO-INSTRUCTION ASSIGNMENTS: WRITE OWN 00002170 VERSIONS OF CALL, SAVE, RETURN; 2ND: WRITE MACRO/ 00002180 MODULE COMBINATIONS FOR HEXADECIMAL CONVERSIONS. 00002190 >CS411MC2 (TEXT) - MACRO-INSTRUCTION ASSIGNMENT: WRITE MACRO 00002200 PACKAGE FOR MANIPULATION OF LINKED LISTS. ALSO 00002210 TO BE USED IN CS411FP1-4. 00002220 00002230 >CS411TPA (TEXT) - COURSE OUTLINE AND DAY-BY-DAY NOTES FOR 00002240 2ND COURSE IN ASSEMBLER/SYSTEMS. 00002250 00002260 >DOCUMENT (TEXT) - HINTS AND GOOD PRACTICES ON DOCUMENTATION 00002270 OF ASSEMBLER PROGRAMS. 00002280 00002290 >DSECT (TEXT) - SAMPLE USE OF DSECTS AND EXPLANATIONS. 00002300 00002310 >DUMPSJCL (TEXT) - OS/360 - BRIEF NOTES ON JCL TO BE USED 00002320 FOR ASSEMBLER RUNS; SAMPL DUMPS FOR VARIOUS ERRORS. 00002330 00002340 >EXCP (JCL) - SAMPLE RUN SHOWING EXCP COMMANDS. 00002350 00002360 >FLOTLINK (JCL) - ILLUSTRATES LINKING FORTRAN & ASSEMBLER, 00002370 FLOATING POINT OPERATIONS IN ASSEMBLER 00002380 00002390 >GETMAIN (JCL) - ILLUSTRATES GETMAIN/FREEMAIN MACROS. 00002400 00002410 >HARDWAR1 (TEXT) - DESCRIBES TYPICAL DEVICES USED ON LARGE 00002420 S/360 SYSTEM, WITH DATA RATES, CAPACITIES, ETC. 00002430 00002440 >INDEX102 (TEXT) - INDEX TO MATERIALS FOR 1ST ASM. COURSE 00002450 00002460 >INDEX411 (TEXT) - INDEX TO MATERIALS FOR SYSTEMS COURSE 00002470 00002480 >LINKAGE (TEXT) - TUTORIAL ON OS/360 LINKAGE CONVENTIONS 00002490 00002500 >LINKLOAD (JCL) - OS/360 - ILLUSTRATES USE OF LOAD MODULE 00002510 MANAGEMENT COMMANDS LINK, LOAD, XCTL, ETC. 00002520 , 00003000 AAAINDEX - 03 00003010 00003020 >OSHASP (TEXT) - EXPLAINS JOB SCHEDULING AND FUNCTIONING 00003030 OF OS/360 WITH HASP. 00003040 00003050 >OVLY1 (JCL) - ILLUSTRATES USE OF LINK-EDITOR OVERLAY 00003060 FACILITIES, SHOWING DIFFERENT TREE STRUCTURES. 00003070 00003080 >PTPCHMAC (JCL) - ILLUSTRATES USE OF UTILITY IEBPTPCH TO 00003090 PRINT MACROS FROM LIBRARY. 00003100 00003110 >QSAM (JCL) - SHOWS USE OF OS/360 QSAM MACROS. 00003120 00003130 >RECURASM (JCL) - SHOWS USE OF GETMAIN/FREEMAIN IN MAKING 00003140 RECURSIVE ASSEMBLER PROGRAMS. 00003150 00003160 >SPIESTAE (JCL) - SHOWS USE OF SPIE/STAE MACROS 00003170 00003180 >TIME (JCL) - ILLUSTRATES USE OF TIME, STIMER, TTIMER 00003190 MACROS FOR TIMING. 00003200 00003210 >WTOWTL (JCL) - ILLUSTRATES WTO, WTL MACROS. 00003220 ,>ASBROPS2 (TEXT) ASSIGNMENT USING ASSIST REPLACE MONITOR , ASBROPS2-01 ASSIST BASE REGISTER ASSIGNMENT DUE __________ This assignment is essentially to write the base register handling routine for ASSIST, and run and test it using the ASSIST Replace Monitor. The programmer should first consult the following writeup for general information, ASSIST conventions, and use of the Replace Monitor: ASSIST REPLACEMENT USER'S GUIDE (ASREPLGD) I. S/360 BASE REGISTER ASSIGNMENT This section briefly describes the conversion of program addresses to base-displacement form, as done by S/360 assemblers, particularly ASSIST. The following manual should also be consulted: IBM S/360 OS Assembler Language GC28-6514, pp. 19-21. A. Each control section and each dummy section in an assembly is assigned a unique number or section identification (ID), and every label in a given section has that same section ID associated with it. B. When a register is specified in a USING statement, it is assumed to contain the specified location counter value, and is also flagged with the section ID of the first expression in the USING. C. When a value used in an instruction must be converted to base- displacement form, the only possible registers which are usable are the ones(if any) which have the same section ID as the value to be converted. D. If two or more registers are usable as base registers, and have the same section ID, the register used is that one having a value which results in the smallest displacement (0-4095). E. If two or more registers have the same ID and value, the higher numbered register is used. F. (ASSIST only) - in ASSIST, all values for USING statements are relocatable, and register 0 is handled exactly the same as any other, which is slightly different from the standard handling. Also, the ASSIST section ID's range from 1 to 255 only. , ASBROPS2-02 II. ASSIST INTERFACE REQUIREMENTS FOR BROPS2 General register conventions are given in ASREPLGD. This section describes the module to be written, with the specific requirements for each of the entry points of the BROPS2 module. The register notation used is that from ASREPLGD. CSECT NAME: BROPS2 ENTRY POINTS: BRINIT, BRUSIN, BRDROP, BRDISP ENTRY AND EXIT CONVENTIONS A. BRINIT - is called one time at beginning of asembly, to perform any initialization required by BROPS2. Must be serially reusable, and so cannot just DC any tables to required values. B. BRUSIN - is called whenever a USING is processed. ENTRY CONDITIONS RA = number of register which can be used. (0-15) RB = address declared for base register. (0-2**24-1) RC = section ID of the address. (1-255) C. BRDROP - is called when a DROP is found. ENTRY CONDITIONS RA = number of register to be dropped. (0-15) EXIT CONDITIONS RB = 0 if register was an active base register. = nonzero value, if register was not usable at the time. D. BRDISP - is called to convert an address-ID to base-dsiplacement. ENTRY CONDITIONS RA = address to be converted to base-displacement form. (0-2**24-1) RB = section ID of the address to be converted. (1-255) EXIT CONDITIONS RA = base-displacement form of address, if there was one, in low-order halfword of register (bits 16-31). Bits 0-15 should be zeroes. RB = 0 if the address was properly converted. = nonzero value if an addressibility error occurred, i.e., if there was no register with the proper section ID, and a value from 0 to 4095 less than the value to be converted. ***NOTE*** the above rules must be followed exactly. If they are not, error messages will be given by the ASSIST Replace Monitor. , ASBROPS2-03 III. IMPLEMENTATION METHODS This section outlines several different methods of implementing the BROPS2 module. The following are ways in which the assignment may be handled, with the instructor specifying in class which one is to be followed: Write the module in 1 specific way. Write the module in several ways, and compare their performance. Write the module any way at all. Write the module any way, but optimizing for one of several goals. A. REGISTER TABLE ORDERED BY REGISTER NUMBER A fairly simple way to handle the problem is to just keep a table ordered by register number, which can easily be indexed into to change the values, and can be searched by a fairly simple loop. B. REGISTER TABLE - LINKED LIST FORM BY ACTIVE REGISTERS A linked list can be kept of the active registers and their values and section ID's. This can make for faster searches, but can require more space, and more complex code. C. REGISTER TABLE WITH LINKED LIST ORDERED BY SECTION ID's A set of linked lists can be kept, with one for each of the section ID's currently active. Each list links together the register or registers which are active base registers and are flagged with the given section ID. This is potentially the fastest method, but also requires the most complex programming. D. REGISTER TABLE WITH SEPARATE ID TABLE AND TRT USAGE In this method, a separate search is made of a 16-byte table which contains the active section ID's, possibly using the TRT instruction, then computing the register number from the position in the index table, and going to antoher table to computer the value. This method can be fast, but may require more space, unless 256 bytes of TRT table are available elsewhere. POSSIBLE OPTIMIZATION GOALS SPEED - optimize for the fastest program possible. Note that this involves determining the relative frequency of USING, DROP, and base- displacement computations, which can differ depending on the type of programmer producing the test program (i.e., experienced programmers usually have many more USING's and DROP's because they use DSECTs more than do beginners). SPACE - optimize to produce the smallest complete program. PROGRAMMING SIMPLICITY - optimize to produce a running program which is simple and understandable, and can be programmed quickly, i.e. simulating the conditions which require a program to be finished in a short period of time. ,>$BRTEST TEST DATA FOR USE WITH ASSIGNMENT ASBROPS2 TITLE 'ASSIST BASE REGISTER/USING/DROP TEST PROGRAM' BASE0000 * THIS PROGRAM PROVIDES VARIOUES ERROR TESTS FOR BROPS2. BASE0010 * ALL STATEMENTS LEGAL,EXCEPT THOSE WITH ERROR COMMENTS. BASE0020 TEST CSECT BASE0030 BALR 12,0 BASE0040 USING *,12 BASE0050 T1 L 0,AA5 AS100 BASE0060 L 5,AA4 BASE0070 USING AA5,9 BASE0080 ST 3,AA5 BASE0090 USING AA5,10 BASE0100 A 2,AA5 BASE0110 USING AA4,10 BASE0120 SL 3,AA5 BASE0130 ST 3,AA4 BASE0140 DROP 10 BASE0150 USING DSECT1,7 BASE0160 STH 4,DS1 BASE0170 LH 5,DS6 BASE0180 DROP 8,10 TWO AS003 MESSAGES BASE0190 CVB 6,DS8 BASE0200 USING DSECT1,9 BASE0210 CVD 6,DS8 BASE0220 USING DSECT2,10 BASE0230 M 8,DS4 BASE0240 LA 5,CARD BASE0250 D 8,DS5 BASE0260 DROP 10 BASE0270 B T1 BASE0280 IC 10,DS2A AS100 ADDRESSIBILITY BASE0290 LA 11,OUTR AS100 ADDRESSIBILITY BASE0300 USING *,13 BASE0310 ST 5,AA4 BASE0320 AA4 DS F BASE0330 DS 1500F BASE0340 OUTR DS C BASE0350 AA5 DS F BASE0360 EJECT BASE0370 DSECT1 DSECT BASE0380 DS1 DS H BASE0390 DS2 DS HL8 BASE0400 DS4 DS A BASE0410 DS5 DS F BASE0420 DS6 DS CL6 BASE0430 DS8 DS D BASE0440 DSECT2 DSECT BASE0450 CARD DS CL80 BASE0460 DS2A DS P BASE0470 BASE CSECT BASE0480 USING *,13,14,15 BASE0490 DROP 8,12 AS003 REGISTER NOT USED ON 8 BASE0500 AH 6,DS1 BASE0510 AH 4,AA6 BASE0520 L 5,AA5 AS100 ADDRESSIBILITY ERROR BASE0530 DROP 7,9,10 AS003 ON 10 BASE0540 DROP 13,14,15 BASE0550 AA6 DS H BASE0560 TITLE 'OVERALL TEST - STUDENT-WRITTEN PROGRAM' BASE0570 * THIS SECTION CAN BE USED TO TEST BROPS2 - IT PROVIDDES BASE0580 * STUDENT-WRITTEN SAMPLE PROGRAM. BASE0590 MAIN CSECT BASE0600 ENTRY IN,OUT,SUPERVR BASE0610 STM 14,12,12(13) BASE0620 BALR 12,0 BASE0630 USING *,12 BASE0640 ST 13,MAINSAV BASE0650 START LA 9,0 BASE0660 LA 6,0 BASE0670 LA 11,0 BASE0680 L 15,=V(COROUT2) BASE0690 BR 15 BASE0700 OUT ST 14,BIN1 BASE0710 L 15,BOUT1 BASE0720 BR 15 BASE0730 IN ST 14,BOUT1 BASE0740 L 15,BIN1 BASE0750 INX BR 15 BASE0760 SUPERVR L 13,MAINSAV BASE0770 LM 14,12,12(13) BASE0780 BR 14 BASE0790 LTORG BASE0800 DS 0F BASE0810 MAINSAV DS F BASE0820 BOUT1 DS F BASE0830 BIN1 DC V(COROUT1) BASE0840 COROUT2 CSECT BASE0850 ENTRY STORE,STORE1 BASE0860 PRINT NOGEN BASE0870 BALR 13,0 BASE0880 USING *,13 BASE0890 B OUT1 BASE0900 DS 0F BASE0910 BLANK DC 4C' ' BASE0920 OUTPUT DS 64C BASE0930 OUT1 LA 4,0 BASE0940 LA 1,OUTPUT BASE0950 LA 5,BLANK BASE0960 MVC 0(64,1),3(5) BASE0970 LA 3,3 BASE0980 LTR 9,9 BASE0990 BH STORE BASE1000 H1 L 15,=V(IN) BASE1010 BALR 14,15 BASE1020 STORE ST 10,OUTPUT(4) BASE1030 LA 4,1(4) BASE1040 CLI 10,C'.' BASE1050 BE H9 BASE1060 L 15,=V(IN) BASE1070 BALR 14,15 BASE1080 STORE1 BCT 3,STORE BASE1090 LA 3,3 BASE1100 LA 4,1(4) BASE1110 C 4,=F'63' BASE1120 BNE STORE BASE1130 H9 LA 3,3 BASE1140 XPRNT BLANK(3),65 BASE1150 CLI OUTPUT+62,C'.' BASE1160 BE SUPER BASE1170 LA 9,1 BASE1180 B OUT1 BASE1190 SUPER L 15,=V(SUPERVR) BASE1200 BR 15 BASE1210 LTORG BASE1220 COROUT1 CSECT BASE1230 BALR 8,0 BASE1240 USING *,8 BASE1250 B IN1 BASE1260 H2 L 15,=V(OUT) BASE1270 BALR 14,15 BASE1280 IN1 L 15,=V(NEXTCHAR) BASE1290 BALR 14,15 BASE1300 CLI 10,C'0' BASE1310 BL H2 BASE1320 ST 10,NUMBER BASE1330 LA 5,NUMBER BASE1340 PACK DOUBLE(8),0(4,5) BASE1350 CVB 5,DOUBLE BASE1360 L 15,=V(BEGIN) BASE1370 BALR 14,15 BASE1380 REPEAT L 15,=V(OUT) BASE1390 BALR 14,15 BASE1400 S 5,=F'1' BASE1410 BNM REPEAT BASE1420 B IN1 BASE1430 LTORG BASE1440 DS 0F BASE1450 NUMBER DS F BASE1460 DOUBLE DS D BASE1470 NEXTCHAR CSECT BASE1480 ENTRY BEGIN BASE1490 PRINT NOGEN BASE1500 BALR 7,0 BASE1510 USING *,7 BASE1520 B BEGIN BASE1530 DS 0F BASE1540 BLNK DC 4C' ' BASE1550 INPUT DS 16F BASE1560 ASTERICK DS F BASE1570 BEGIN ST 14,ASTERICK BASE1580 CHECK LTR 11,11 BASE1590 BNE F3 BASE1600 LTR 6,6 BASE1610 BE READ BASE1620 F1 C 6,=F'16' BASE1630 BNE F2 BASE1640 LA 6,0 BASE1650 READ XREAD INPUT,64 BASE1660 LA 2,3 BASE1670 XPRNT BLNK(2),65 BASE1680 F2 L 11,INPUT(6) BASE1690 F3 IC 10,C' ' BASE1700 SLDA 10,8 BASE1710 LA 6,1(6) BASE1720 CLI 10,C' ' BASE1730 BNE ASTERICK BASE1740 B CHECK BASE1750 LTORG BASE1760 END BASE1770 ,>ASPRGTC1 (TEXT) ASSEMBLER PROGRAMMING TECHNIQUES: LINKAGE, , 00000050 ASPRGTC1 - 01 00000150 00000200 00000250 S/360 Assembler Language Programming Techniques 00000300 John R. Mashey - Winter l972 00000350 00000400 00000450 Topic: Program Modularity and Parametrization Methods: 00000500 Using Macros, Internal Subroutine, External Subroutines 00000550 This topic: pages 01-08 00000600 00000650 It is generally important in any computer program to avoid coding00000700 any procedure more times than necessary. It is generally best to write00000750 something one time, then have it available for later use in many parts00000800 of a program. In assembler language, there are three main ways of doing00000850 this: macros, internal subroutines, and external subroutines. This00000900 writeup describes each of these techniques, gives the advantages and00000950 disadvantages of each, and notes under what condition each is best.00001000 00001050 I. DESCRIPTION, DEFINITION, AND CALLING 00001100 00001150 A. MACRO INSTRUCTIONS 00001200 00001250 A macro instruction is defined, and either placed at the beginning00001300 of an assembly language program (a USER macro), or entered into a macro00001350 library (a SYSTEM macro). When called, it generates 0 or more assembly00001400 language statements at the point of invocation, and the code generated00001450 may vary greatly from call to call. 00001500 00001550 1. DEFINITION 00001600 00001650 A macro definition begins with MACRO, followed by the PROTOTYPE00001700 STATEMENT, which gives the name of the macro. The body of the macro00001750 includes 0 or more MODEL STATEMENTS, which are assembler commands and00001800 machine instructions to be generated, and macro-operations, which serve00001850 to direct the expansion processing of the macro. The macro definition00001900 is terminated by the MEND statement. The following steps are typical00001950 in defining a macro: 00002000 00002050 a. DETERMINE BASIC PURPOSE AND GENERATED CODE: It is generally00002100 a good idea to write at least some of the statements to be generated00002150 together as a code segment first, to get some feel for what is needed.00002200 00002250 b. DECIDE ON NECESSARY ARGUMENTS AND THEIR USAGE: it may be a goo00002300 idea to write the purpose of each argument in the operand list, punch it00002350 and include it in a block of comments at the beginning of the macro.00002400 This helps the macro to be done to do what it is supposed to do.00002450 00002500 Use POSITIONAL operands for heavily-used arguments, i.e., if an00002550 argument MUST be supplied every time, make it positional. In a group00002600 of positionals, place the most heavily used ones near the front, since00002650 it is much more convenient to omit the later ones than the earlier.00002700 Use KEYWORD arguments for values which may not be needed always, or for00002750 ones which are conveniently supplied with default values which are most00002800 often used. Use SUBLISTS or &SYSLIST for variable numbers of arguments.00002850 00002900 c. WRITE ACTUAL BODY OF MACRO, BUILDING MACRO-TYPE COMMANDS00002950 AROUND THE MODEL STATEMENTS TO BE GENERATED. 00003000 , 00003050 ASPRGTC1 - 02 00003100 00003150 2. INVOCATION 00003200 00003250 A macro can be called merely by writing its name and supplying it00003300 with any needed arguments. Note that a label on a macro call is never00003350 generated (and is thus UNDEFINED) unless the macro definition is made00003400 to generate it on some model statement. 00003450 00003500 B. INTERNAL SUBROUTINES 00003550 00003600 Internal subroutines are sections of code written as parts of a00003650 given control section (CSECT), and are only used inside that CSECT. Like00003700 external subroutines, internal subroutines can of course call others.00003750 They are typically used for small to medium sections of code which are00003800 needed at several places in a CSECT, but are not needed by any other,00003850 or are not big enough to warrant the overhead in making them external00003900 subroutines. 00003950 00004000 1. DEFINITION 00004050 00004100 It is often typical to place a group of internal subroutines near00004150 the end of the code section of a program (just before the data areas).00004200 It is a good idea to set up conventions for the use of internal00004250 subroutines, before writing any. The following are often needed:00004300 return register (either one standard one, or several different ones),00004350 argument registers, and work registers which can be used without saving.00004400 In general, internal subroutines should not need to do much saving and00004450 restoring of registers. They should be able to return via BR REG.00004500 00004550 2. INVOCATION 00004600 00004650 Calling an internal subroutine is usually done by first filling any00004700 argument registers with needed values, then coding: BAL REG, INSUB.00004750 This type of linkage can be fast and small. 00004800 00004850 C. EXTERNAL SUBROUTINES 00004900 00004950 External subroutines are used for major program segments, and00005000 can usually be assembled separately from the rest of the program. In00005050 fact they can be written in a different language (i.e., FORTRAN and00005100 ASSEMBLER combinations). 00005150 00005200 1. DEFINITION 00005250 00005300 An external subroutine may be written in either of two ways in00005350 assembly language: as a CSECT, or as an ENTRY within a CSECT. In the00005400 first case, the subroutine is entered at the CSECT statements and return00005450 at one or more places depending on the desired code. In the second case00005500 each entrypoint may be given control, and may share code or be00005550 totally separate from the other entries. This form is often used for00005600 a group of related routines (like SIN and COS, which are both entries in00005650 a CSECT), or for a routine requiring initialization or termination00005700 functions different from the normal calling function. 00005750 , 00005800 ASPRGTC1 - 03 00005850 00005900 A multiple-entry CSECT is typically set up as follows: 00005950 00006000 CSECTNAM CSECT 00006050 ENTRY ENTRY1,ENTRY2,...ENTRYN 00006100 ..... code for entry at CSECTNAM: multiple-entry routines often00006150 ..... are entered only at the entry points, not at the CSECT.00006200 00006250 ENTRY1 LINKAGE CODE (SAVE, XSAVE, etc) 00006300 ..... executable code when called at ENTRY1..... 00006350 RETURN LINKAGE CODE (RETURN, XRETURN, etc). 00006400 00006450 ..... remaining entrypoint names and code 00006500 00006550 ..... internal subroutines needed by more than one entry point.00006600 00006650 ..... data areas used by various of the entry point routines.00006700 00006750 The following are important points to remember when using multiple00006800 entry CSECTS: 00006850 00006900 THE DIFFERENT ENTRY POINTS NEVER CALL EACH OTHER. In essence, all00006950 of the routines represented by the various entry points are at the same00007000 level in calling structure of an entire program. 00007050 00007100 ONLY ONE SAVE AREA IS ACTUALLY NEEDED. Since the routines inside00007150 the CSECT never call each other, the user can code the save area at the00007200 end of the LAST section of code, so that all of the previous sections00007250 can refer to it (note that if placed on the first, it would be difficult00007300 for the later ones to access it using a LA instruction: address00007350 constants must be used instead). With XSAVE/XRETURN, this means that00007400 the SA=* operand is coded only on the LAST XRETURN. 00007450 00007500 CARE MUST BE TAKEN WITH ADDRESSIBILITY. All of the code sections00007550 can of course address the data areas at the end of the CSECT. However,00007600 the programmer must be very careful with any internal subroutines he00007650 writes, because the BASE REGISTERS USED TO ASSEMBLE INTERNAL SUBROUTINES00007700 MUST HAVE THE CORRECT VALUES IN THEM AT EXECUTION TIME. IF THEY DON'T,00007750 AS WHEN THEY ARE CALLED FROM DIFFERENT SECTIONS HAVING DIFFERENT USING00007800 SETUPS, THEY WILL ASSEMBLE PROPERLY AND THEN BLOW UP AT EXECUTION TIME.00007850 IN PARTICULAR, THE PROGRAMMER SHOULD PLACE INSTRUCTIONS TO BE EXECUTED00007900 (EX operation) WITH THE SECTION OF CODE USING THEM, AND NOT AT WITH THE00007950 DATA AREAS, IF THEY PERFORM ANY SYMBOLIC ADDRESSING. 00008000 00008050 The problems described above are typically handled either by making00008100 all entry point code segments set up the same USING conditions, or by00008150 setting a specific register to point to the beginning of the internal00008200 subroutines, EXecuted instructions and data. If register 13 points to00008250 a save area just above these code sections, it can be used this way,00008300 since it will always have that same value. Getting the same USING00008350 conditions across an entire multi-entry CSECT can be done: 00008400 00008450 ENTRYX XSAVE 00008500 L BASEREG,=A(CSECTNAM) 00008550 USING CSECTNAM,BASEREG 00008600 00008650 Note that the above can be accomplished with the XSAVE AD= operand.00008700 , 00008750 ASPRGTC1 - 04 00008800 00008850 D. COMBINED FORMS 00008900 00008950 In some cases, it is convenient to combine the ease of use of the00009000 macro with the small size of internal or external subroutines. In this00009050 case, the macro expansion sets up any needed arguments, saves registers,00009100 etc, then generates code to invoke the subroutine. The subroutine then00009150 provides the major portion of the processing code, any needed large data00009200 areas, etc. 00009250 00009300 Examples of the combined form are the following macros: XDECI,00009350 XDECO, XPRNT, XSNAP, which call XXXXDECI, XXXXDECO, XXXXPRNT, and00009400 XXXXSNAP, respectively. 00009450 00009500 Two different extremes exist in writing combined forms: 00009550 00009600 1. COMBINED FORM - STANDARD LINKAGE 00009650 00009700 In some case, the calling sequence to invoke an external subroutine00009750 essentially includes the CALL macro or equivalent code, i.e., it uses00009800 standard conventions. It typically assumes that registers 0, 1, 14, 1500009850 may be modified without causing trouble. This method is efficient and00009900 general, but can cause trouble if used improperly. 00009950 00010000 2. COMBINED FORM - SPECIAL NONDESTRUCTIVE LINKAGE 00010050 00010100 In some cases, it may be useful to define a macro instruction which00010150 invokes a subroutine, but can be used ANYWHERE without disturbing any00010200 registers, changing the condition code, or requiring that certain of the00010250 registers not be the ones being used as base registers (in particular,00010300 register 15). This is the kind of linkage used from XDECO to XXXXDECO00010350 XPRNT to XXXXPRNT, etc. The following shows the general form of such a00010400 linkage setup, giving first the kind of code to be generated by the00010450 macro part, then the entry and exit code for the associated routine:00010500 (NOTE: label is typically an &SYSNDX-generated unique label)00010550 00010600 STM 14,0,label save registers to be changed 00010650 .... evaluate arguments of macro: any required Load Addresses 00010700 .... must be done using LA 0, argument since doing LA into 00010750 .... any other register could destroy a base register. If 00010800 .... more than one argument is needed, the remaining ones can 00010850 .... be stored into control block after label. Examples: 00010900 LA 0,argument 00010950 ST 0,label+12 2nd argument (one arg left in RO) 00011000 .... after all arguments are evaluated and saved, and ONLY 00011050 .... THEN, it is now possible to modify registers: 00011100 L 15,label-4 V-type adcon for routine 00011150 CNOP 2,4 make sure next inst not on F boundry 00011200 BALR 14,15 call routine, also point 14 at the 00011250 argument list following 00011300 DC V(subroutine entry point) adcon to get there 00011350 label DS 3F 3 words for saving 14, 15, 0 00011400 DS F space for arguments after first 00011450 .... DS OR DC space here for any remaining arguments 00011500 .... the subroutine will return control to next instruction: 00011550 LM 14,0,4(14) reload registers. Note that this is 00011600 only safe way, since 15 might have 00011650 current base register. 00011700 , 00011750 ASPRGTC1 - 05 00011800 00011850 The following shows the typical code used to enter and exit the00011900 supporting module used with the previous macro expansion. Note that the00011950 entry point of the routine might be either a CSECT name, or an ENTRY00012000 name, i.e., one CSECT might contain several entrypoints, one for each00012050 supporting subroutine needed. 00012100 00012150 entrypoint label definition (CSECT, or label DS OH) 00012200 USING entrypoint,15 initial base register 00012250 .... save all registers which may be modified by code. Save 00012300 .... into THIS CSECT (unlike normal OS/360 conventions). 00012350 .... DO NOT SAVE INTO CALLER'S SAVE AREA, since it may not 00012400 .... exist, especially if caller is a lowest-level routine. 00012450 00012500 .... initialization code: if this routine performs I/O, or 00012550 .... calls any others, or requests any supervisor services, it00012600 .... is a good idea to set up another base register than 15, 00012650 .... set up a save area, and put its address into register 13,00012700 .... since any of the above actions may result in registers 00012750 .... being saved at wherever 13 points. 00012800 00012850 .... processing code to perform required actions 00012900 00012950 .... result return code: result may be left in register 0, 00013000 .... in which case it should not be restored (neither here nor00013050 .... in generated code before: i.e., change LM 14,0,4(14) to 00013100 .... LM 14,15,4(14) and STM likewise). 00013150 00013200 .... register restoration: restore all registers modified in 00013250 .... this routine. Especially restore 14. 00013300 00013350 SPM 14 restore original condition code (note00013400 that calling BALR 14,15 saved it) 00013450 00013500 B number(14) branch to displacement number beyond 00013550 address in 14, enough to pass control00013600 to statement: LM 14,0,4(14) 00013650 00013700 It may be useful for the programmer to create a DSECT which00013750 describes the control block generated by the macro expansion. This00013800 would permit the module to refer to arguments and return points using00013850 symbols rather than absolute displacements. A typical DSECT might be:00013900 00013950 dsectnam DSECT 00014000 DS V(routine) space for adcon 00014050 DS 3F space for regs 14, 15, 0 00014100 argument DS F argument value placed here, if any 00014150 .... further arugment DS statements follow. 00014200 return LM 14,0,4(14) return label (YES, THIS IS LEGAL: it does00014250 NOT generate code, but it makes the point 00014300 clear as to description of block). 00014350 00014400 If such a DSECT were used, the routine code would include:00014450 USING dsectnam,14 to set up DSECT addressibility 00014500 B return return (instead of B number(14) 00014550 , 00014600 ASPRGTC1 - 06 00014650 00014700 II. ADVANTAGES AND DISADVANTAGES 00014750 00014800 The following lists the good and bad points of each type:00014850 00014900 A. MACRO INSTRUCTIONS 00014950 00014975 1. ADVANTAGES 00015000 00015050 Code can be tailored to each individual request, i.e., the code00015100 generated by each macro call can vary from a great deal to nothing,00015150 such as debug code eliminated by testing a global set variable.00015200 00015250 SPEED: macro-generated code can be the fastest in execution, since00015300 it can perform its actions without having to set up linkage to another00015350 section of code. 00015400 00015450 VARIABILITY: generated code can vary depending on the nature of00015500 arguments passed to a macro (such as testing the TYPE of arguments to00015550 generate different instructions). 00015600 00015650 2. DISADVANTAGES 00015700 00015750 SLOW ASSEMBLY: macro processing can be very slow. 00015800 00015850 LARGE CODE: if used improperly, macros can generate large amounts00015900 of code very easily. If there are many copies of large blocks of code,00015950 much space can be wasted. 00016000 00016050 OBJECT DECKS: a macro cannot be assembled and an object deck of it00016100 gotten like a subroutine can, i.e., if a call is made to a macro, the00016150 macro definition must be included in the program or in a library, while00016200 a CSECT may be saved as an object deck (which is usually much smaller00016250 than the source deck). 00016300 00016350 B. INTERNAL SUBROUTINES 00016400 00016450 1. ADVANTAGES 00016500 00016550 SPEED: although not as fast as in-line code from a macro, the code00016600 for an internal subroutine is usually faster than the linkage to an00016650 external one. In particular, values can be passed in registers, and00016700 usually registers will not have to be saved. 00016750 00016800 SPACE: internal subroutines require less space than generating the00016850 same code several times via macro expansions. 00016900 00016950 2. DISADVANTAGES 00017000 00017050 SPACE: if the same function is performed by internal subroutines00017100 in several CSECTS, code is thus duplicated and space wasted. 00017150 00017200 COMPLEXITY: in some cases, in order to make efficient use of a00017250 number of internal subroutines, it is necessary to set up fairly00017300 extensive rules on usage of registers in a CSECT, so that the linkage00017350 among them may be fast and small. 00017400 , 00017425 ASPRGTC1 - 07 00017450 00017500 C. EXTERNAL SUBROUTINES 00017550 00017600 1. ADVANTAGES 00017650 00017700 SPACE: if written as an external subroutine, code can be usefully00017750 called from almost anywhere in a program. Thus, there is only one copy00017800 of it, and it generally will occupy the least space. 00017850 00017900 SEPARATE COMPILE/ASSEMBLY: a routine written as a CSECT can be00017950 assembled separately from the rest of the program an object deck can00018000 be obtained, and translation time generally saved. The routine may of00018050 course be written in a different language than the rest of the program.00018100 00018150 2. DISADVANTAGES 00018200 00018250 LINKAGE TIME: if standard OS/360 linkage is followed, a fair amount00018300 of execution time and object code space can be consumed by this linkage.00018350 More efficient nonstandard linkage can be used instead, but this brings00018400 with it the disadvantage of nonuniformity and lack of generality.00018450 00018500 D. COMBINED FORMS 00018550 00018600 1. ADVANTAGES 00018650 00018700 In general, the combined forms can possess all the advantages of00018750 the separate forms especially since the macro portions can generate00018800 different code depending on circumstances; thus the code for the same00018850 macro might expand in-line in one case and generate an out-of-line call00018900 to a routine in another. 00018950 00019000 2. DISADVANTAGES 00019050 00019100 COMPLEXITY: it of course requires somewhat more planning and code00019150 to set up a good combined form system, since both a macro and module00019200 must be created and meshed together properly. 00019250 , 00019300 ASPRGTC1 - 08 00019350 00019400 III. CIRCUMSTANCES FAVORING USE OF THE VARIOUS FORMS 00019450 00019500 A. MACRO INSTRUCTIONS 00019550 00019600 In general, a pure macro instruction is used as follows:00019650 00019700 VARYING CODE: the required code varies radically from call to00019750 call. For example: XSAVE and XRETURN. 00019800 00019850 SHORT CODE: if a macro can generate less in-line code to perform00019900 the required function than is needed to generate a call to the routine,00019950 then it should be written as a macro. In some cases, it takes as much00020000 work to set up the arguments as it does just to perform the operations.00020050 For example: the code to obtain the minimum or maximum of several00020100 arguments is probably most efficiently written as a in-line macro.00020150 00020200 LINKAGE CODE: code for linking to routines is almost necessarily00020250 written as macros, since it makes little sense to call a routine in00020300 order to perform linkage, unless the linkage code required is very00020350 complex (in which case the program is probably going to be SLOW).00020400 00020450 B. INTERNAL SUBROUTINES 00020500 00020550 Internal subroutines are usually used (as opposed to macros which00020600 generate code in-line) under the following circumstances: 00020650 00020700 CODE WITH LITTLE VARIANCE: if the code is not going to be much00020750 different from macro call to macro call, it may be better to let the00020800 macro call generate a BAL to one copy of the code as an internal subr.00020850 00020900 Internal subroutines are usually used (as opposed to EXTERNAL00020950 subroutines) under these circumstances: 00021000 00021050 SHORT CODE, HEAVILY USED: if code must be used many times by00021100 a CSECT, then the faster linkage of internal subroutines usually makes00021150 it worth writing it that way. 00021200 00021250 CODE NEEDED ONLY BY ONE CSECT: if not too long, it is fairly00021300 logical to incorporate it as part of that CSECT. It will probably be00021350 much more efficient since it will have access to the internal variables00021400 of the CSECT, and be able to communicate via register values easily,00021450 rather than requiring long operand lists. 00021500 00021550 C. EXTERNAL SUBROUTINES 00021600 00021650 LONG CODE: if something is long and complex enough, it may be a00021700 good idea to make a separate module of it, test it, get an object deck,00021750 then leave it along thereafter. 00021800 00021850 CODE OF GENERAL USE, NEEDED MANY PLACES: in this case, it is00021900 practically necessary to make code an external subroutine, so that it00021950 can be accessed where needed. 00022000 00022050 D. COMBINED FORMS 00022100 00022150 These are useful anywhere the others are. The nondestructive form00022200 is specially useful if it is to be used by beginning programmers.00022250 ,>ATTACH (JCL) - OS/360 SAMPLE PROGRAM- ATTACH, DETACH, ETC //* ATCH0000 //* THIS JOB WILL RUN WITH TIME= 75 SECONDS ATCH0010 //* RECORDS = 1000 ATCH0020 //* ATCH0030 // EXEC ASGCL ATCH0040 //SOURCE.INPUT DD * ATCH0050 * ATCH0060 * . . . . . . . ATCH0070 * THE PUTPOSE OF THIS JOB IS TO DEMONSTRATE THE MACRO'S LISTEC B ATCH0080 * THE PUTPOSE OF THIS JOB IS TO DEMONSTRATE THE MACRO'S LISTECD ATCH0090 * BELOW: ATCH0100 * ATTACH ATCH0110 * DETACH ATCH0120 * WAIT ATCH0130 * POST ATCH0140 * EXTRACT ATCH0150 * . . . . . . . ATCH0160 * ATCH0170 * ATCH0180 * . . . . . . . ATCH0190 * THE OVERALL FLOW OF THIS PROGRAM IS ATCH0200 * 1 THE CSECTS SECOND AND THIRD ARE COMPILED AND LINKED ATCH0210 * 2 MAIN IS COMPILED AND LINKED EDITED AND EXECUTES. ATCH0220 * 3 DURING THE EXECUTION OF MAIN IT ATTACHES SECOND ATCH0230 * TWICE USING THE ATTACH MACRO. ATCH0240 * BEFORE SECOND IS ATTACHED THE DISPATCH PRIORITY OF MAIN IS ATCH0250 * OBTAINED USING THE EXTRACT MACRO. AFTER IT HAS BEEN OBTAINED ATCH0260 * IT IS DIVIED BY 2 AND WHEN SECOND IS ATTACHED THE PRIORITY OF ATCH0270 * MAIN IS HALVED USING THE DPMOD PARM. WHILE BOTH MAIN AND ATCH0280 * SECOND ARE COMPETING FOR CPU USE, THE TCB'S FOR MAIN AND ATCH0290 * SECOND ARE SNAPPED USING THE EXTRACT MACRO. ATCH0300 * WHEN SECOND AND ATCH0310 * WHEN SECOND IS EXECUTING IS ATTACHED IT IS GIVEN AN ECB AND ATCH0320 * IN MAIN A WAIT MACRO IS ISSUED FOR THIS ECB. ATCH0330 * 4 THEN SECOND IS DETACHED IN MAIN USING THE DETACH ATCH0340 * MACRO. ATCH0350 * 5 THEN THE PRIORITY OF MAIN IS RESTORED. ATCH0360 * 6 THEN SECOND IS ATTACHED AGAIN USING THE ATTACH MACRO ATCH0370 * ONLY THIS TIME SECOND IS GIVEN AN EXIT ROUTINE. IN THE EXIT ATCH0380 * ROUTINE SECOND IS DETACHED AND CONTROL IS RETURNED TO MAIN. ATCH0390 * AGAIN THERE IS AN ECB GIVEN TO SECOND AND A WAIT MACRO ISSUED ATCH0400 * IN MAIN. ATCH0410 * 7 THEN THIRD IS ATTACHED BUT IT IS NOT GIVEN AN ECB. ATCH0420 * AN ADDRESS IS PASSED IN THE ATTACH MACRO FOR THE ECB AND THIRD ATCH0430 * USES A POST MACRO TO SET THE ECB. ATCH0440 * . . . . . . . ATCH0450 * ATCH0460 EJECT ATCH0470 PRINT NOGEN ATCH0480 * ATCH0490 * . . . . . . . ATCH0500 * WHEN SECOND OBTAINS CONTROL IT DETERMINES WHICH CALL IS BEING ATCH0510 * MADE THEN IT OUTPUTS THE APPROPRIATE HEADING AND RETURNS. ATCH0520 * . . . . . . . ATCH0530 * ATCH0540 SECOND CSECT ATCH0550 XSAVE TR=NO ATCH0560 L 2,0(1) GET ADD OF PARM LIST ATCH0570 L 4,4(1) GET SECOND PARM ATCH0580 L 4,0(4) GET VALUE OF SECOND PARM ATCH0590 LTR 4,4 CHECK FOR 0 ATCH0600 BZ SEC IF ZERO THEN SECOND CALL ATCH0610 LA 5,SHEAD1 GET ADD OF OUTPUT FOR FIRST CALL ATCH0620 B OUTPUT GO TO DO OUTPUT ATCH0630 SEC LA 5,SHEAD2 GET ADD FOR OUTPUT OF SECOND CALL ATCH0640 OUTPUT PUT 0(2),0(5) ATCH0650 XRETURN SA=*,TR=NO ATCH0660 SHEAD2 DC CL132'0THIS IS SECOND CALL TO SECOND' ATCH0670 SHEAD1 DC CL132'0THIS IS FIRST CALL TO SECOND' ATCH0680 PRINT GEN ATCH0690 END ATCH0700 /* ATCH0710 /*LOG ATCH0720 //OBJECT.SYSLMOD DD DSNAME=&&LOADMOD(SECOND) ATCH0730 // EXEC ASGCL ATCH0740 //SOURCE.SYSGO DD DISP=(OLD,PASS) ATCH0750 //SOURCE.INPUT DD * ATCH0760 PRINT NOGEN ATCH0770 ECBDSECT DSECT ATCH0780 ECBADD DS F ATCH0790 * ATCH0800 * . . . . . . . ATCH0810 * THE PURPOSE OF THIRD IS GAIN CONTROL AND OUTPUT A MESSAGE ATCH0820 * THEN TO POST THE ECB THEN RETURN ATCH0830 * . . . . . . . ATCH0840 * ATCH0850 THIRD CSECT ATCH0860 XSAVE TR=NO ATCH0870 L 2,0(1) GET ADD OF DCB ATCH0880 L 3,4(1) GET ADDRESS OF ECB ATCH0890 PUT 0(2),THEAD ATCH0900 PRINT GEN ATCH0910 POST 0(3),240 ATCH0920 PRINT NOGEN ATCH0930 XRETURN SA=*,TR=NO ATCH0940 THEAD DC CL132'0THIRD NOW EXECUTING ' ATCH0950 END ATCH0960 /* ATCH0970 //OBJECT.SYSLMOD DD DSNAME=&&LOADMOD(THIRD),DISP=(OLD,PASS) ATCH0980 // EXEC ASGCLG ATCH0990 //SOURCE.SYSGO DD DISP=(OLD,PASS) ATCH1000 //SOURCE.INPUT DD * ATCH1010 PRINT NOGEN ATCH1020 * ATCH1030 * . . . . . . . ATCH1040 * THIS IS THE MAIN JOB STEP. ATCH1050 * MAIN ATTAHCES SECOND TWICE AND THIRD ONCE IT USES ATTACH, ATCH1060 * DETACH,EXTRACT,CHAP,WAIT, AND POST ATCH1070 * DETACH,WAIT,AND EXTRACT. ATCH1080 * IT DOES ALL THREE ONE STEP AT A TIME ATCH1090 * . . . . . . . ATCH1100 * ATCH1110 MAIN CSECT ATCH1120 XSAVE TR=NO ATCH1130 OPEN (OTPT,OUTPUT) ATCH1140 PUT OTPT,MHEAD ATCH1150 PRINT GEN ATCH1160 EJECT ATCH1170 * TCB DESCRIPTION ATCH1180 * ATCH1190 * *---------------------------------------* ATCH1200 * | | | | | ATCH1210 * | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | ATCH1220 * | | | | | ATCH1230 * *---------------------------------------* ATCH1240 * ATCH1250 * ATCH1260 * ANSWER AREA ATCH1270 * ADDRESS---* ATCH1280 * | ATCH1290 * | ATCH1300 * | ATCH1310 * *---------------------------------------* ATCH1320 * | | ADDRESS GENERAL PURPOSE | ATCH1330 * GRS | | SAVE AREA FOR TASKS REG'S | ATCH1340 * | | WHEN TASK NOT ACTIVE | ATCH1350 * *---------------------------------------* ATCH1360 * | | ADDRESS GENERAL PURPOSE | ATCH1370 * FRS | | SAVE AREA FOR TASKS | ATCH1380 * | | FLOATING POINT REGISTERS | ATCH1390 * | | WHEN TASK NOT ACTIVE | ATCH1400 * *---------------------------------------* ATCH1410 * | RESERVED SET TO 0 | ATCH1420 * *---------------------------------------* ATCH1430 * | | ADDRESS OF END OF TASK | ATCH1440 * AETX | | ROUTINE SPECIFIED IN | ATCH1450 * | | ATTACH MACRO - EXTR - | ATCH1460 * *---------------------------------------* ATCH1470 * | | | TASK | TASK | ATCH1480 * PRI | | | LIMIT | DISPATCH| ATCH1490 * | | | PRIORITY|PRIORITY | ATCH1500 * *---------------------------------------* ATCH1510 * | | COMPLETION CODE | ATCH1520 * CMC | 1 IF NOT COMPLETE 0 | ATCH1530 * *---------------------------------------* ATCH1540 * | | ADDRESS OF TASK INPUT AND | ATCH1550 * TIOT | | OUTPUT TABLES | ATCH1560 * *---------------------------------------* ATCH1570 * COMM | | ADDRESS OF COMMAND | ATCH1580 * | | SCHEDULER COMMUNIATIONSS | ATCH1590 * | | LIST | ATCH1600 * *---------------------------------------* ATCH1610 * | | ADDRESS OF TIME SHARING | ATCH1620 * TSO | | FLAGS FIELD IN TCB | ATCH1630 * *---------------------------------------* ATCH1640 * | | ADDRESS OF PROTECTED | ATCH1650 * PSB | | STORAGE CONTROL BLOCK | ATCH1660 * *---------------------------------------* ATCH1670 * | | | THE TERMINAL JOB | ATCH1680 * TJID | | | IDENTIFIER | ATCH1690 * *---------------------------------------* ATCH1700 EJECT ATCH1710 * ATCH1720 * . . . . . . . ATCH1730 * OBTAIN DISPATCH PRIORITY FOR MAIN. ATCH1740 * ATTACH SECOND. ATCH1750 * SNAP THE TCB'S FOR MAIN AND SECOND. ATCH1760 * SET A WIAT MACRO FOR THE ECB OUT OF SECOND ATCH1770 * DETACH SECOND. ATCH1780 * . . . . . . . ATCH1790 * ATCH1800 * ATCH1810 * . . . . . . . ATCH1820 * ATCH1830 * . . . . . . . ATCH1840 * THE ANSWER PARM IS A FULL WORD IN CORE STORAGE FOR THE RESULT ATCH1850 * OF THE EXTRACT MACRO. ATCH1860 * 'S' PARM INDICATES THIS JOB. ATCH1870 * THE FIELDS PARM SPECIFIES WHICH ONE WE DESIRE. ATCH1880 * . . . . . . . ATCH1890 * ATCH1900 EXTRACT ANSWER,'S',FIELDS=(PRI) ATCH1910 SR 10,10 ZERO REGISTER 10 ATCH1920 LA 9,ANSWER GET ADDRES OF ANSWER ATCH1930 IC 10,3(9) GET PRIORITY OF MAIN ATCH1940 SRL 10,1 DIVIDE DISP PRI BY 2 ATCH1950 LNR 10,10 MAKE DISPATCH PRI NEG ATCH1960 * ATCH1970 * . . . . . . . ATCH1980 * THE EP IS THE ENTRY POINT FOR THE LOAD MODULE TO BE ATTACHED. ATCH1990 * PARAM SPECIFIES A LIST OF PARM TO BE PASSED TO THE LOAD MODULE ATCH2000 * AND VL INDICATES AN INDEFINITE NUMBER OF PARMS. ATCH2010 * ECB SPECIFIES THE ADDRESS OF ANDEVENT CONGROL BLOCK TO BE ATCH2020 * ECB SPECIFIES THE ADDRESS OF AND VENT CONGROL BLOCK TO BE ATCH2030 * ECB SPECIFIES THE ADDRESS OF AN EVENT CONGROL BLOCK TO BE ATCH2040 * POSTED WHEN SECOND COMPLETES EXECUTION. ATCH2050 * THE LPMOD SPECIFIES AN INTEGER VALUE TO BE SUBTRACTED FROM ATCH2060 * THE LIMIT PRIORITY OF SECOND. ATCH2070 * THE DPMOD GIVES ANVALUE TO BE ADDED TO DISPATCH PRIORITY OF ATCH2080 * MAIN. IN THIS EXAMPLE A REGISTER VALUE. ATCH2090 * THE ADDRESS OF THE TCB OF SECOND IS RETURNED IN REG 1. ATCH2100 * . . . . . . . ATCH2110 * ATCH2120 ATTACH EP=SECOND,PARAM=(OTPT,ONE),VL=1,ECB=ECB1,LPMOD=1, XATCH2130 DPMOD=(10) ATCH2140 ST 1,TCBADD SAVE TCB ADDRESS. ATCH2150 * ATCH2160 * . . . . . . . ATCH2170 * NEXT SNAP THE TCB FOR MAIN AND SECOND USING EXTRACT MACRO ATCH2180 * SEVEN1 IS THE AREA FOR THE RESULT. ATCH2190 * THE 'S' INDICATES TCB FOR MAIN. ATCH2200 * THE FIELDS SPECIFY THE FIELDS TO BE SNAPPED. ATCH2210 * . . . . . . . ATCH2220 * ATCH2230 EXTRACT SEVEN1,'S',FIELDS=(ALL,TSO,PSB,COMM,TJID) ATCH2240 PRINT NOGEN ATCH2250 XSNAP T=NOREGS,STORAGE=(SEVEN1,SEVEN1+44), XATCH2260 LABEL='TCB FOR MAIN WITH PRIORITY LOWERED' ATCH2270 PRINT GEN ATCH2280 * ATCH2290 * . . . . . . . ATCH2300 * NEXT SNAP THE TCB FOR SECOND ATCH2310 * TCBADD IS A FULL WORD CONTAINING THE ADDRESS OF SECOND TCB. ATCH2320 * . . . . . . . ATCH2330 * ATCH2340 EXTRACT SEVEN1,TCBADD,FIELDS=(ALL,TSO,PSB,COMM,TJID) ATCH2350 PRINT NOGEN ATCH2360 XSNAP T=NOREGS,STORAGE=(SEVEN1,SEVEN1+44), XATCH2370 LABEL='THIS IS TCB FOR SECOND ON FIRST CALL' ATCH2380 PRINT GEN ATCH2390 * ATCH2400 * . . . . . . . ATCH2410 * ISSUE A WAIT MACRO FOR THE EVENT CONTROL BLOCK PASSED TO ATCH2420 * SECOND IN THE ATTACH MACRO. CONTROL PROGRAM WILL POST ECB. ATCH2430 * . . . . . . . ATCH2440 * ATCH2450 WAIT ECB=ECB1 ATCH2460 * ATCH2470 * . . . . . . . ATCH2480 * THE TCBADD IS THE ADDRESS OF THE TCB FOR LOAD MODULE TO BE ATCH2490 * DETACHED ATCH2500 * . . . . . . . ATCH2510 * ATCH2520 DETACH TCBADD ATCH2530 PRINT NOGEN ATCH2540 PUT OTPT,MHEAD1 ATCH2550 LPR 10,10 ATCH2560 PRINT GEN ATCH2570 * ATCH2580 * . . . . . . . ATCH2590 * RESORE PRIORITY FOR MAIN. ATCH2600 * (10) INDICATES THE VALUE TO BE ADDED TO DISPATCH FOR MAIN IS ATCH2610 * IN REG 10. ATCH2620 * THE 'S' INDICATES THE CURRENT LOAD MODULE. ATCH2630 * . . . . . . . ATCH2640 * ATCH2650 CHAP (10),'S' ATCH2660 EJECT ATCH2670 * ATCH2680 * . . . . . . . ATCH2690 * ATTACH SECOND WITH EXIT ROUTINE TO DETACH SECOND. ATCH2700 * SNAP TCB FOR MAIN AND SECOND. ATCH2710 * THEN SET WAIT MACRO IN MAIN BEFORE CONTINUING. ATCH2720 * . . . . . . . ATCH2730 * ATCH2740 * ATCH2750 * . . . . . . . ATCH2760 * EXTR IS THE ONYL NEW PARM IT GIVES THE ADDRESS OF A ROUTINE TO ATCH2770 * BE GIVEN CONTROL WHEN SECOND FINISHES. ATCH2780 * . . . . . . . ATCH2790 * ATCH2800 ATTACH EP=SECOND,PARAM=(OTPT,ZERO),ECB=MECB,ETXR=MEXTR,VL=1 ATCH2810 ST 1,TCBADD PUT ADD OF TCB FOR DETACH ATCH2820 * ATCH2830 * . . . . . . . ATCH2840 * AGAIN SNAP TCB'S FRO MAIN AND SECOND. ATCH2850 * . . . . . . . ATCH2860 * ATCH2870 EXTRACT SEVEN,TCBADD,FIELDS=(ALL) ATCH2880 PRINT NOGEN ATCH2890 XSNAP STORAGE=(SEVEN,SEVEN+28),T=NOREGS, XATCH2900 LABEL='THIS IS TCB FOR SECOND ATTACH OF SECOND' ATCH2910 PRINT GEN ATCH2920 EXTRACT SEVEN,'S',FIELDS=(ALL) ATCH2930 PRINT NOGEN ATCH2940 XSNAP STORAGE=(SEVEN,SEVEN+28),T=NOREGS XATCH2950 LABEL='TCB FOR MAIN WITH ONLY ALL SPECIFIED FOR FIELDS' ATCH2960 PUT OTPT,MHEAD2 ATCH2970 PRINT GEN ATCH2980 * ATCH2990 * . . . . . . . ATCH3000 * WIAT FOR SECOND TO COMPLETE BEFORE ATTACHING THIRD. ATCH3010 * . . . . . . . ATCH3020 * ATCH3030 WAIT ECB=MECB ATCH3040 EJECT ATCH3050 XC MECB(4),MECB CLEAN OUT MECB FOR WAIT AND POST ATCH3060 * ATCH3070 * . . . . . . . ATCH3080 * ATTACH THIRD ATCH3090 * SNAP PRIORITY OF MAIN ATCH3100 * WAIT ON THIRD ATCH3110 * . . . . . . . ATCH3120 * ATCH3130 * HERE ECB IS PASSED AS PARM ATCH3140 * DPMOD IS NEGATIVE INTEGER. ATCH3150 * . . . . . . . ATCH3160 * ATCH3170 ATTACH EP=THIRD,PARAM=(OTPT,MECB),DPMOD=-30 ATCH3180 ST 1,TCBADD SAVE TCB ADDRESS FOR DETACH ATCH3190 * ATCH3200 * . . . . . . . ATCH3210 * EXTRACT PRIORITY FOR MAIN AND SNAP IT. ATCH3220 * . . . . . . . ATCH3230 * ATCH3240 PRINT NOGEN ATCH3250 EXTRACT ANSWER,'S',FIELDS=(PRI) ATCH3260 XSNAP T=NOREGS,STORAGE=(ANSWER,ANSWER+4), XATCH3270 LABEL='PRIORITY SNAPPED FOR MAIN ON ATTACH TO THIRD' ATCH3280 PRINT GEN ATCH3290 * ATCH3300 * . . . . . . . ATCH3310 * WAIT FOR THIRD TO COMPLETE. ATCH3320 * . . . . . . . ATCH3330 * ATCH3340 WAIT ECB=MECB ATCH3350 * ATCH3360 * . . . . . . . ATCH3370 * DETACH THIRD. ATCH3380 * . . . . . . . ATCH3390 * ATCH3400 DETACH TCBADD ATCH3410 * ATCH3420 * . . . . . . . ATCH3430 * CLOSE OUTPUT FILE AND RETURN ATCH3440 * . . . . . . . ATCH3450 * ATCH3460 PRINT NOGEN ATCH3470 CLOSE (OTPT,) ATCH3480 XRETURN SA=*,TR=NO ATCH3490 DROP 12 ATCH3500 EJECT ATCH3510 * ATCH3520 * . . . . . . . ATCH3530 * EXIT ROUTINE FOR SECOND CALL TO SECOND. ATCH3540 * . . . . . . . ATCH3550 * ATCH3560 MEXTR XSAVE TR=NO,SA=NO ATCH3570 PRINT GEN ATCH3580 * ATCH3590 * . . . . . . . ATCH3600 * DETACH SECOND IN EXIT ROUTINE WITH ADD OF TCB OF SECOND ATCH3610 * IN TCBADD. ATCH3620 * . . . . . . . ATCH3630 * ATCH3640 DETACH TCBADD ATCH3650 PRINT NOGEN ATCH3660 XRETURN SA=NO,TR=NO ATCH3670 MECB DC F'0' ATCH3680 ZERO DC F'0' ATCH3690 ONE DC F'1' ATCH3700 ECB1 DC F'0' ATCH3710 TCBADD DC F'0' ATCH3720 ANSWER DC F'0' ATCH3730 SEVEN DC 7F'0' ATCH3740 SEVEN1 DC 7F'0' ATCH3750 MHEAD2 DC CL132'0SECOND WILL ATTACHED AGAIN WITH POST ON COMPLETE' ATCH3760 MHEAD DC CL132'0MAIN IS NOW EXECUTING NEXT OUTPUT SECOND' ATCH3770 MHEAD1 DC CL132'0MAIN EXECUTING WITH DISPATCH PRIORITY HALVED' ATCH3780 OTPT DCB DSORG=PS,MACRF=PM,LRECL=132,BLKSIZE=132,RECFM=FA, XATCH3790 DDNAME=FT06F001,EROPT=ACC ATCH3800 END ATCH3810 /* ATCH3820 //OBJECT.SYSLMOD DD DSNAME=&&LOADMOD(MAIN),DISP=(OLD,PASS) ATCH3830 //DATA.STEPLIB DD DSNAME=&&LOADMOD,DISP=(OLD,PASS) ATCH3840 //DATA.SYSUDUMP DD SYSOUT=A ATCH3850 //DATA.XSNAPOUT DD UNIT=AFF=FT06F001 ATCH3860 ,>BDAM1 (JCL) - OS/360 BDAM EXAMPLE, PART 1 OF 2 //* BDAM0000 //* THIS JOB WILL RUN WITH TIME = 170 SECONDS BDAM0010 //* RECORDS = 1500 BDAM0020 //* BDAM0030 // EXEC ASGCG BDAM0040 //SOURCE.INPUT DD * BDAM0050 /*LOG BDAM0060 * BDAM0070 * . . . . . . . BDAM0080 * TEH PURPOSE OF THIS JOB IS TO DEMONSTRATE BASIC DIRECT ACCESS BDAM0090 * METHOD (BDAM). BDAM0100 * . . . . . . . BDAM0110 * BDAM0120 * BDAM0130 * . . . . . . . BDAM0140 * THE BASIC FLOW OF THIS JOB IS AS FOLLOWS. BDAM0150 * 1 JOB STEP 1 CREATES THE DIRECT ACCESS DATA SET BDAM0160 * 2 JOB STEP 2 ADDS RECORD TO THE DATA SET. BDAM0170 * 3 JOB STEP 3 UPDATES THE DATA SET. BDAM0180 * 4 JOB STEP 4 PRINTS OUT THE DATA SET IN LOGICAL ORDER BDAM0190 * . . . . . . . BDAM0200 * BDAM0210 EJECT BDAM0220 * BDAM0230 * . . . . . . . BDAM0240 * THIS JOB STEP CREATES THE DIRECT ACCESS DATA SET. BDAM0250 * THE INPUT IS CARDS WITH A KEY OF 4 DIGITS BETWEEN 1001 AND BDAM0260 * 1020. THE KEY IS CONVERTED TO A BINARY NUMBER WHICH IS USED BDAM0270 * AS THE BLOCK NUMBER FOR THE INPUT RECORD. FOR EACH INPUT BDAM0280 * THE NEXT 40 CHARACTERS ON THE CARDS ARE WRITTEN TO DISK. BDAM0290 * FOR EACH KEY THAT IS NOT PRESENT A DUMMY RECORD IS WRITTEN ON BDAM0300 * DISK. THUS THERE ARE 20 BLOCKS OF DATA ON THE DISK. BDAM0310 * . . . . . . . BDAM0320 * BDAM0330 SPACE 5 BDAM0340 PRINT NOGEN BDAM0350 EQUREGS BDAM0360 MAIN CSECT BDAM0370 XSAVE BDAM0380 PRINT GEN BDAM0390 * BDAM0400 * . . . . . . . BDAM0410 * OPEN THE INPUT DATA SET AND THE OUTPUT DATA SET. INITIALIZE BDAM0420 * REGISTER 8, 9, AND 7. REGISTER 8 HAS MAX KEY VALUE, REGISTER BDAM0430 * 9 HAS THE MIN KEY VALUE, AND REGISTER 7 HAS ADDRESS OF BDAM0440 * THE COMPARE INSTRUCTION, BDAM0450 * . . . . . . . BDAM0460 * BDAM0470 OPEN (INPT,INPUT,OTPT,OUTPUT) BDAM0480 PRINT NOGEN BDAM0490 LA R7,COMPARE BDAM0500 LA R8,1020 SET R8 TO LAST KEY VAUUE BDAM0510 LA R9,1001 SET R9 TO MIN KEY VALUE BDAM0520 * BDAM0530 * . . . . . . . BDAM0540 * READ IN THE CARD AND CONVERT THE KEY TO BINARY FORM IN BDAM0550 * REGISTER 10. THEN CHECK TO SEE IF THIS IS THE NEXT KEY IN BDAM0560 * THE LIST OF KEYS. BDAM0570 * . . . . . . . BDAM0580 * BDAM0590 LOOP GET INPT,AREA BDAM0600 XDECI R10,AREA BDAM0610 COMPARE CR R9,R10 CHECK FOR KEY BDAM0620 BNE DUMMY IF NOT GO TO OUTPTT DUMMY RECORD BDAM0630 * BDAM0640 * . . . . . . . BDAM0650 * AT THIS POINT WE KNOW THAT THIS IS THE NEXT KEY TO BE WRITTEN BDAM0660 * SO WRITE THE INPUT TO KISK, AND THE CHECK THE DECB WITH A BDAM0670 * CHECK MACRO. THEN INCREASE THE MIN KEY VALUE AND RETURN FOR BDAM0680 * NEXT INPUT. BDAM0690 * . . . . . . . BDAM0700 * BDAM0710 SPACE 5 BDAM0720 * . . . . . . . BDAM0730 * FOR THE WRITE STATEMENT THE DCEB1 IS THE NAME OF THE DATA BDAM0740 * EVENT CONTROL BLOCK, THE SECOND PARAMTTE SF INDICATES NORMAL BDAM0750 * WRITE CONDITION, OTPT IS THE DCB NAME,, AREA IS THE ADDRESS BDAM0760 * WHERE THE OUTPUT DATA IS STORED. BDAM0770 * THE PARAMETER TO THE CHECK MACRO IS THE DECB NAME FOR THE BDAM0780 * WRITE STATEMENT. BDAM0790 * . . . . . . . BDAM0800 * BDAM0810 WRITE DECB1,SF,OTPT,AREA BDAM0820 SPACE 5 BDAM0830 CHECK DECB1 BDAM0840 PRINT NOGEN BDAM0850 LA R9,1(R9) ADD ONE TO KEY COUNT BDAM0860 B LOOP RETURN FOR NEXT INPUT BDAM0870 * BDAM0880 * . . . . . . . BDAM0890 * AT THIS POINT THE KEY JUST READ IS GREATER THAN THE MIN VALUE BDAM0900 * IN REGISTER 9. NOW CHECK THE EXPECTED KEY VALUE TO SEE IF BDAM0910 * IT IS GREATER THAN THE MAX KEY VALUE IN REGISTER 8. BDAM0920 * . . . . . . . BDAM0930 * BDAM0940 DUMMY CR R9,R8 CHECK TO SEE IF LAST INPUT BDAM0950 BH EOJ IF HIGH THEN DONE BDAM0960 PRINT GEN BDAM0970 * BDAM0980 * . . . . . . . BDAM0990 * AT THIS POINT THE LAST KEY READ IN WASA GREATER THAN MIN KEY BDAM1000 * VALUE BUT LWSS THAN MAX KEY VALUE, THEREFORE, WRITE A DUMMY BDAM1010 * RECORD TO THE DATA SET. BDAM1020 * . . . . . . . BDAM1030 * BDAM1040 SPACE 5 BDAM1050 * BDAM1060 * THE FIRST POSITIONAL PARAMETER IS THE DECB NAME TO BE BDAM1070 * CREATED. THE SD INDICATES THAT THIS IS A DUMMY RECORD. BDAM1080 * OTPT IS THE DCB NAME. DUMAREA IS ADDRESS OF 5 BYTES OF CORE BDAM1090 * FOR USE IN DUMMY OUTPUT. BDAM1100 * INCREASE THE MIN KEY VALUE AND RETURN TO CHECK THE CURRENT BDAM1110 * KEY VALUE. BDAM1120 * AGAIN CHECK IS USED TO CHECK THE DECB. BDAM1130 * . . . . . . . BDAM1140 * BDAM1150 WRITE DECB2,SD,OTPT,DUMAREA BDAM1160 SPACE 5 BDAM1170 CHECK DECB2 BDAM1180 PRINT NOGEN BDAM1190 LA R9,1(R9) INCREASE R9 BY ONE BDAM1200 BR R7 GO TO DO NEXT COMPARE BDAM1210 * BDAM1220 * . . . . . . . BDAM1230 * AT THIS POINT WE HAVE JUST READ IN THE LAST INPUT SO GO TO BDAM1240 * FINISH OUTPUTTING DUMMY RECORDS UNTIL THE DATA SET IS FULL. BDAM1250 * . . . . . . . BDAM1260 * BDAM1270 EODADD LA R7,DUMMY BDAM1280 BR R7 RETURN TO CONTINUE DUMMY OUTPUT BDAM1290 PRINT GEN BDAM1300 SPACE 5 BDAM1310 * BDAM1320 * . . . . . . . BDAM1330 * NOW WE HAVE FILLED THE DATA SET SO CLOSE THE DATA SETS AND RE BDAM1340 * NOW WE HAVE FILLED THE DATA SET SO CLOSE THE DATA SETS AND BDAM1350 * RETURN TO OPERATING SYSTEM. BDAM1360 * . . . . . . . BDAM1370 * BDAM1380 EOJ CLOSE (INPT,,OTPT,) BDAM1390 PRINT NOGEN BDAM1400 XRETURN SA=* BDAM1410 PRINT GEN BDAM1420 SPACE 5 BDAM1430 * BDAM1440 * . . . . . . . BDAM1450 * WHEN AN UNCORRECTABLE ERROR HAS OCCURED IN THE WRITE STATEMEN BDAM1460 * THIS ROUTINE IS GIVEN COOTROL BY THE CONTROL PROGRAM. BDAM1470 * SYNADAF RETURNS IN REGISTER 1 THE ADDRESS OF AN AREA THAT BDAM1480 * CONTAINES DEBUGGNNG INFORMATION SO PRINT IT AND RETURN BDAM1490 * THE SYNADRLS MACRO RESTORES THE REGISTERS THAT EXISTED BDAM1500 * WHEN CHECKER RECEIVED CONTROL IT RESTORES THEM FOR YOU. BDAM1510 * THE SYNAD ROUTINE CAN NOT SAVE IN CALLING PROGRAM SAVEAREA. BDAM1520 * . . . . . . . BDAM1530 * BDAM1540 CHECKER SYNADAF ACSMETH=BDAM BDAM1550 PRINT NOGEN BDAM1560 XPRNT 0(1) BDAM1570 PRINT GEN BDAM1580 SPACE 5 BDAM1590 SYNADRLS BDAM1600 BR 14 BDAM1610 AREA DC 10F'0' BDAM1620 DC 10F'0' BDAM1630 DUMAREA DS CL5 BDAM1640 * BDAM1650 * . . . . . . . BDAM1660 * THIS IS DCB FOR BDAM OUTPUT TO CREATE BDAM DATA SET. BDAM1670 * WHEN CREATING THE DATA SET THE DSORG MUST BE PS. BDAM1680 * THE MACRF MUST BE (WL) BDAM1690 * DEVD MUST BE DA. BDAM1700 * DDNAME IS STANDARD. BDAM1710 * SYNAD IS ADDRESS OF ROUTINE TO BE GIVEN CONTROL WHEN ERROR BDAM1720 * BURING EXECUTION OF THE I/O OCCURS. BDAM1730 * . . . . . . . BDAM1740 * BDAM1750 OTPT DCB DSORG=PS,MACRF=(WL),DDNAME=DAOUTPUT,DEVD=DA, XBDAM1760 SYNAD=CHECKER BDAM1770 PRINT NOGEN BDAM1780 INPT DCB DSORG=PS,MACRF=GM,LRECL=80,BLKSIZE=80,RECFM=F, XBDAM1790 DDNAME=INPUT,EROPT=ACC,EODAD=EODADD BDAM1800 LTORG BDAM1810 PRINT GEN BDAM1820 END BDAM1830 /* BDAM1840 //DATA.DAOUTPUT DD DSNAME=&&TEMP,UNIT=SYSDA,DISP=(NEW,PASS), XBDAM1850 // DCB=(DSORG=DA,BLKSIZE=40,KEYLEN=4,RECFM=F),SPACE=(44,(21)) BDAM1860 //DATA.SYSUDUMP DD SYSOUT=A BDAM1870 //DATA.XSNAPOUT DD SYSOUT=A BDAM1880 //DATA.INPUT DD * BDAM1890 1001FIRST RECORD BDAM1900 1003THIRD RECORD BDAM1910 1005RECORD FIVE BDAM1920 1007SEVENTH RECORD BDAM1930 1009NINETH RECORD BDAM1940 1011ELEVENTH RECORD BDAM1950 1013THIRTEENTH RECORD BDAM1960 1015FIFTEENTH RECORD BDAM1970 1017SEVENTEENTH RECORD BDAM1980 1019NINETEENTH RECORD BDAM1990 /* BDAM2000 // EXEC ASGCG BDAM2010 //SOURCE.SYSGO DD DISP=(OLD,PASS,DELETE) BDAM2020 //SOURCE.INPUT DD * BDAM2030 * . . . . . . . BDAM2040 * BDAM2050 * THIS CSECT ADDS RECORD TO THE DATA SET THAT ALREADY EXISTS. BDAM2060 * . . . . . . . BDAM2070 * BDAM2080 PRINT NOGEN BDAM2090 EQUREGS BDAM2100 SECOND CSECT BDAM2110 XSAVE BDAM2120 * BDAM2130 * . . . . . . . BDAM2140 * FIRST OPERN THE INPUT AND OUTPUT DATA SETS. THEN SET REGSTER BDAM2150 * 11 TO 1000 WHICH IS USED TO RELATIVE BLOACK ADDRESS FOR BDAM2160 * THE RECORDS TO BE ADDED TO THE DATA SET. BDAM2170 * . . . . . . . BDAM2180 * BDAM2190 OPEN (INPT,INPUT,DIRECT,OUTPUT) BDAM2200 LA R11,1000 BDAM2210 * BDAM2220 * . . . . . . . BDAM2230 * READ THE INPUT AND CONVERT THE DEY TO BINARY FROM IN REGISTER BDAM2240 * 2, THEN COMPUTE THE RELATIVE BLOCK ADDRESS AND STORE THIS AT BDAM2250 * REF. BDAM2260 * THEN WRITE THE NEW RECORD IN THE PROPER PLACE ON DISK. BDAM2270 * . . . . . . BDAM2280 * . . . . . . . BDAM2290 * BDAM2300 NEXTREC GET INPT,KEY BDAM2310 XDECI R2,KEY BDAM2320 SR R2,R11 BDAM2330 ST R2,REF BDAM2340 PRINT GEN BDAM2350 SPACE 5 BDAM2360 * BDAM2370 * . . . . . . . BDAM2380 * THE POSITIONAL PARAMETER ARE BDAM2390 * 1 NAME OF THE DATA EVENT CONTROL BLOCK TO BE CREATED BDAM2400 * BY THE WRITE MACRO. BDAM2410 * 2 TYPE DA ADD A NEW BLOCK WHEREEVER THERE IS SPACE; BDAM2420 * THE SEARCH FOR AVAILBBLE SPACE STARTS ATTHE DEVICE ADDRESS BDAM2430 * ADDRESS IN THE BLOCK ADDRESS OPERAND.. TYPE SEARC IS BDAM2440 * IN THE OPTCD PARAMETER IN DCB MACRO. BDAM2450 * 3 DCB NAME HERE IT DIRECT. BDAM2460 * 4 AREA ADDRESS ADDRESS OF MAIN CORE CONTAINING THE BDAM2470 * BLOCK TO BE WRITTEN. BDAM2480 * 5 LENGTH - NUMBER OF BYTE TO BE WRITTEN, 'S' INDI- BDAM2490 * CATES THAT THIS IS OBTAINED FROM BLKSIZE IN DCB. BDAM2500 * 6 KEY ADDRESS IS ADDRESS OF MAIN CORE AREA CONTAIN- BDAM2510 * ING THE KEY. BDAM2520 * 7 BLOCK ADDRESS ADDRESS OF THREE BYTES IN AMIN CORE BDAM2530 * THAT CONTAIN THE RELATIVE BLOCK ADDRESS. BDAM2540 * . . . . . . . BDAM2550 * WAIT MACRO HALTS TASK TILL I/O DONE. BDAM2560 * THEN RETURN FOR NEXT INPUT. BDAM2570 * . . . . . . . BDAM2580 * BDAM2590 WRITE DECB,DA,DIRECT,DATA,'S',KEY,REF+1 BDAM2600 PRINT NOGEN BDAM2610 PRINT GEN BDAM2620 SPACE 5 BDAM2630 WAIT ECB=DECB BDAM2640 PRINT NOGEN BDAM2650 B NEXTREC RETURN FOR NEXT INPUT BDAM2660 * BDAM2670 * . . . . . . . BDAM2680 * CLOSE INPUT FILE CLOSE OUTPUT FILE AND RETURN TO SYSTEM. BDAM2690 * . . . . . . . BDAM2700 * BDAM2710 EOJ CLOSE (INPT,,DIRECT,) BDAM2720 XRETURN SA=* BDAM2730 PRINT GEN BDAM2740 SPACE 5 BDAM2750 * BDAM2760 * . . . . . . . BDAM2770 * THIS IS THE ERROR REUTINE FOR DEBUGGING. BDAM2780 * . . . . . . . BDAM2790 * BDAM2800 CHECKER SYNADAF ACSMETH=BDAM BDAM2810 PRINT NOGEN BDAM2820 XPRNT 0(1) BDAM2830 PRINT GEN BDAM2840 SYNADRLS BDAM2850 BR 14 BDAM2860 KEY DS F BDAM2870 DATA DS CL40 BDAM2880 DC CL100' ' BDAM2890 REF DS F BDAM2900 PRINT NOGEN BDAM2910 INPT DCB DSORG=PS,MACRF=GM,LRECL=80,RECFM=F,BLKSIZE=80, XBDAM2920 EROPT=ACC,EODAD=EOJ,DDNAME=INPUT BDAM2930 PRINT GEN BDAM2940 SPACE 5 BDAM2950 * BDAM2960 * . . . . . . . BDAM2970 * THE KEYWORD PARAMETERS FOR DCB ARE BDAM2980 * DSORG IS DA SPECIFYING DIRECT ACCESS. BDAM2990 * RECFM IS FIXED BDAM3000 * KEYLEN - KEY LENGTH IS 4 BYTES. BDAM3010 * BLKSIZE IS 40 BYTES. BDAM3020 * MACRF - WRITE BLOCKS ARE TO BE ADDED TO THE DATA SET. BDAM3030 * OPTCD - E EXTENDED SEARCH R RELATIVE BLOCK ADDRESSING BDAM3040 * LIMCT NUMBER OF BLOCKS TO BE SERRCHED FOR EKY. BDAM3050 * DDNAME - STANDARD. BDAM3060 * SYNAD - ADDRESS OF ROUTINE FOR ERROR DURING WRITE. BDAM3070 * . . . . . . . BDAM3080 * BDAM3090 DIRECT DCB DSORG=DA,RECFM=F,KEYLEN=4,BLKSIZE=40,MACRF=(WA), XBDAM3100 OPTCD=ER,LIMCT=3,DDNAME=DIRADD,SYNAD=CHECKER BDAM3110 LTORG BDAM3120 END BDAM3130 /* BDAM3140 //DATA.DIRADD DD DSNAME=&&TEMP,UNIT=SYSDA,DISP=(OLD,PASS), XBDAM3150 // SPACE=(44,(21)) BDAM3160 //DATA.SYSUDUMP DD SYSOUT=A BDAM3170 //DATA.XSNAPOUT DD SYSOUT=A BDAM3180 //DATA.INPUT DD * BDAM3190 1002SEDOND RECORD BDAM3200 1004FOURTH RECORD BDAM3210 1006SIXTH RECORD BDAM3220 1008EIGHT RECORD BDAM3230 1010TENTH RECORD BDAM3240 1012TWELTH RECORD BDAM3250 1014FOURTEENTH RECORD BDAM3260 1016SIXTEENTH RECORD BDAM3270 1018EIGHTEENTH RECORD BDAM3280 1020TWENTIETH RECORD BDAM3290 /* BDAM3300 // EXEC ASGCG BDAM3310 //SOURCE.SYSGO DD DISP=(OLD,PASS) BDAM3320 //SOURCE.INPUT DD * BDAM3330 * BDAM3340 * . . . . . . . BDAM3350 * THIS CSECT UPDATES THE DATA SET. BDAM3360 * . . . . . . . BDAM3370 * BDAM3380 * BDAM3390 * . . . . . . . BDAM3400 * OPEN THE DATA SET AND SET REGISTER 11 TO 1001 WHICH IS USED BDAM3410 * TO COMPUTE THE RELATIVE BLOCK ADDRESS. BDAM3420 * . . . . . . . BDAM3430 * BDAM3440 PRINT NOGEN BDAM3450 EQUREGS BDAM3460 THIRD CSECT BDAM3470 XSAVE BDAM3480 OPEN (INPT,INPUT,DIRECT,OUTPUT) BDAM3490 LA R11,1001 BDAM3500 * BDAM3510 * . . . . . . . BDAM3520 * READ IN TEH INPUT AND CONVDRT THE KEY TO A RELATIVE BDAM3530 * BLOCK ADDRESS. THEN STORE RELATIVE BLOCK ADDRESS IN REF. BDAM3540 * READ THE RECORD WITH THIS RELATIVE ALOCK ADDRESS. BDAM3550 * THE WRITE THE NEW INPUT IN ITS PLACE THEN RETURN FOR NEXT BDAM3560 * INPUT. BDAM3570 * . . . . . . . BDAM3580 * BDAM3590 LOOP GET INPT,KEY BDAM3600 XDECI R2,KEY BDAM3610 SR R2,R11 BDAM3620 ST R2,REF BDAM3630 PRINT GEN BDAM3640 SPACE 5 BDAM3650 * BDAM3660 * . . . . . . . BDAM3670 * THE POSITIONAL PARAMETER FOR READ MACRO ARE: BDAM3680 * 1 DECB NAME TO BE CREATED BY READ STATEMENT. BDAM3690 * 2 TYPE - DI - SEARCH FOR RECORD USES BLOCK BDAM3700 * IDENTIFICATION. BDAM3710 * 3 DCB ADDRESS DIRECT. BDAM3720 * 4 AREA ADDRESS - 'S' INDICATES THAT DYNAMIC BUFFERING BDAM3730 * IS TO BE USED. BDAM3740 * 5 LENGHT - 'S' NUMBER OF BYTES COMES FROM DCB. BDAM3750 * 6 KEY ADDRESS - 0 INDICATES KEY NOT TO BE READ. BDAM3760 * 7 BLOCK ADDRESS - ADDRESS OF THREE BYTES CONTAINING BDAM3770 * RELATIVE BLOCK ADDRESS. BDAM3780 * . . . . . . . BDAM3790 * BDAM3800 READ DECB,DI,DIRECT,'S','S',0,REF+1 BDAM3810 SPACE 5 BDAM3820 CHECK DECB BDAM3830 * BDAM3840 * . . . . . . . BDAM3850 * LOAD REGISTER 3 WITH BUFFER ADDRESS. THEN MOVE NEW DATA TO BDAM3860 * BUFFER AND STORE BUFFER ADDRESS IN DCEB OF WRITE STATEMETN. BDAM3870 * . . . . . . . BDAM3880 * BDAM3890 L R3,DECB+12 BDAM3900 MVC 0(30,3),DATA BDAM3910 ST R3,DECBW+12 BDAM3920 SPACE 5 BDAM3930 * BDAM3940 * . BDAM3950 * . . . . . . . BDAM3960 * POSITIONAL PARAMETERS OF WRITE MACRO ARE: BDAM3970 * 1 DECB NAME TO BE CREATED BY WRITRE MACRO. BDAM3980 * 2 TYPE - DI - WRITE THE BLOCK AT THE DEVICE ADDRESS BDAM3990 * PROVIDED AT THE BLOCK ADDRESS OPERAND. DATA AND KEYS ARE BDAM4000 * WRITTEN. BDAM4010 * 3 DCB ADDRESS - DIRECT. BDAM4020 * 4 AREA ADDRESS - 'S' INDICATES DYNAMIC BUFFERING BDAM4030 * ADDRESS PROVIDED IN DECB +12 PREVIOUSLY BY READ AND STORE. BDAM4040 * 5 LENGTH - - 'S' INDICATES LENGTH CMMES FROM BLKSIZE BDAM4050 * IN DCB. BDAM4060 * 6 KEY ADDRESS - 0 INDICATES KEY NOT WRITTEM. BDAM4070 * 7 BLOCK ADDRESS ADDRESS OF THREE BYTES OF MAIN CORE BDAM4080 * CONTIANING RELATIVE BLOCK ADDRESS. BDAM4090 * . . . . . . . BDAM4100 * BDAM4110 WRITE DECBW,DI,DIRECT,'S','S',0,REF+1 BDAM4120 SPACE 5 BDAM4130 CHECK DECBW BDAM4140 B LOOP BDAM4150 PRINT NOGEN BDAM4160 * BDAM4170 * . . . . . . . BDAM4180 * CLOSE DATA SETS AND RETURN TO OS. BDAM4190 * . . . . . . . BDAM4200 * BDAM4210 EOJ CLOSE (INPT,,DIRECT,) BDAM4220 XRETURN SA=* BDAM4230 * BDAM4240 * . . . . . . . BDAM4250 * ERROR ROUTINE PROVIDED BY SYNAD PARM IN DCB. BDAM4260 * . . . . . . . BDAM4270 * BDAM4280 CHECKER SYNADAF ACSMETH=BDAM BDAM4290 XPRNT 0(1) BDAM4300 SYNADRLS BDAM4310 BR 14 BDAM4320 KEY DC F'0' BDAM4330 DATA DC 10F'0' BDAM4340 DC CL100' ' BDAM4350 REF DC F'0' BDAM4360 INPT DCB DSORG=PS,MACRF=GM,LRECL=80,BLKSIZE=80,RECFM=F, XBDAM4370 DDNAME=INPUT,EROPT=ACC,EODAD=EOJ BDAM4380 PRINT GEN BDAM4390 SPACE 5 BDAM4400 * BDAM4410 * . . . . . . . BDAM4420 * THE KEYWORD PARAMETERS FOR DCB ARE BDAM4430 * DSORG DA DIRECT ACCESS. BDAM4440 * DDNAME STANDARD DIRECTDD BDAM4450 * MACRF BDAM4460 * R READ BDAM4470 * I SEARCH TO BE MADE BY BLOCK IDENTIFICATION. BDAM4480 * S DYNAMIC BUFFERING. BDAM4490 * C CHECK ABSENCE DENOTES WAIT. BDAM4500 * W WRITE BDAM4510 * I SEARCH TO BE MADE BY BLOCK IDENTIFICATION. BDAM4520 * C HCECK ABSECCE DENTOES WAIT. BDAM4530 * BUFL BUFFER LENGTH 40 BDAM4540 * OPTCD - R - SEARCH TO BE MADE BY BLOCK IDENTIFICATION. BDAM4550 * BUFNO - NUMBER OF BUFFERS. BDAM4560 * SYNAD - ERROR ROUTINE ADDRESS. BDAM4570 * . . . . . . . BDAM4580 * BDAM4590 DIRECT DCB DSORG=DA,DDNAME=DIRECTDD,MACRF=(RISC,WIC),BUFL=40, XBDAM4600 OPTCD=R,BUFNO=1,SYNAD=CHECKER BDAM4610 LTORG BDAM4620 END BDAM4630 /* BDAM4640 //DATA.XSNAPOUT DD SYSOUT=A BDAM4650 //DATA.SYSUDUMP DD SYSOUT=A BDAM4660 //DATA.DIRECTDD DD DSNAME=&&TEMP,DISP=(OLD,PASS),SPACE=(44,(21)), XBDAM4670 // UNIT=SYSDA BDAM4680 //DATA.INPUT DD * BDAM4690 1020CGANGE RECORD TWENTY BDAM4700 1002CHANGE RECORD TWO BDAM4710 1010CHANGE RECORD TEN BDAM4720 /* BDAM4730 // EXEC ASGCG BDAM4740 //SOURCE.SYSGO DD DISP=(OLD,PASS) BDAM4750 //SOURCE.INPUT DD * BDAM4760 * BDAM4770 * . . . . . . . BDAM4780 * THIS JOB STEP READS IN THE CURRENT RECORDS AND PRINTS THEM BDAM4790 * OUT. BDAM4800 * . . . . . . . BDAM4810 * BDAM4820 PRINT NOGEN BDAM4830 EQUREGS BDAM4840 FOUR CSECT BDAM4850 XSAVE BDAM4860 * BDAM4870 * OPEN INPUT AND OUTPUT DATA SETS. BDAM4880 * SET R11 TO NUMBER OF BLOCKS BDAM4890 * SET R3 TO 0 THE RELATVVE ADDRESS OF FIRST BLOCK. BDAM4900 * STORE R3 AT REF. BDAM4910 * . . . . . . . BDAM4920 * BDAM4930 OPEN (INPT,INPUT,OTPT,OUTPUT) BDAM4940 LA R11,20 BDAM4950 SR R3,R3 BDAM4960 ST R3,REF BDAM4970 PRINT GEN BDAM4980 SPACE 5 BDAM4990 ,>BDAM2 (JCL) - OS/360 BDAM EXAMPLE, PART 2 OF 2 * BDAM5000 * . . . . . . . BDAM5010 * THE POSITIONAL PARAMETERS FOR THE READ MACRO ARE BDAM5020 * 1 DECB NAME TO BE CREATED BY READ MACRO. BDAM5030 * 2 TYPE DIRECT ADDRESS ING BY RELATIVE BLOCK. BDAM5040 * 3 DCB ADDRESS NNPT BDAM5050 * 4 AREA ADDRESS AREA WHERE RETRIEVED DATA TO BE PUT. BDAM5060 * 5 LENGTH - 'S' TO BE TAKEN FROM DCB. BDAM5070 * 6 KEY ADDRESS - 0 INDICATES KEY NOT TO BE READ. BDAM5080 * 7 BLOCK ADDRESS ADDRESS OF THREE BYTES OF CORE BDAM5090 * CONTAINING THE RLLATIVE KEY ADDRESS. BDAM5100 * . . . . . . . BDAM5110 * BDAM5120 LOOP READ DECB,DI,INPT,INPTT,'S',0,REF+1 BDAM5130 SPACE 5 BDAM5140 CHECK DECB BDAM5150 * BDAM5160 * . . . . . . . BDAM5170 * INCREASE RELATIVE BLOCK ADDRESS, THEN OUTPUT THE RECORD BDAM5180 * RETURN FOR NEXT INPUT. BDAM5190 * . . . . . . . BDAM5200 * BDAM5210 L R3,REF BDAM5220 LA R3,1(R3) BDAM5230 ST R3,REF BDAM5240 PRINT NOGEN BDAM5250 PUT OTPT,INPTT-1 BDAM5260 BCT R11,LOOP BDAM5270 * BDAM5280 * . . . . . . . BDAM5290 * CLOSE DATA SETS AND RETURN TO OS. BDAM5300 * . . . . . . . BDAM5310 * BDAM5320 CLOSE (INPT,,OTPT,) BDAM5330 XRETURN SA=* BDAM5340 * BDAM5350 * . . . . . . . BDAM5360 * ERROR REOUTINE FOR USE WHEN ERROR OCCURS. BDAM5370 * . . . . . . . BDAM5380 * BDAM5390 CHECKER SYNADAF ACSMETH=BDAM BDAM5400 XPRNT 0(1) BDAM5410 SYNADRLS BDAM5420 BR 14 BDAM5430 REF DC F'0' BDAM5440 DC X'00' BDAM5450 INPTT DC 10F'0' BDAM5460 OTPT DCB DSORG=PS,MACRF=PM,LRECL=40,BLKSIZE=40,RECFM=FA, XBDAM5470 DDNAME=FT06F001,EROPT=ACC BDAM5480 PRINT GEN BDAM5490 SPACE 5 BDAM5500 INPT DCB DSORG=DA,MACRF=(RIC),RECFM=F,BLKSIZE=40, XBDAM5510 OPTCD=ER,LIMCT=3,DDNAME=DIRECTDD,SYNAD=CHECKER BDAM5520 LTORG BDAM5530 END BDAM5540 /* BDAM5550 //DATA.FT06F001 DD SYSOUT=A BDAM5560 //DATA.DIRECTDD DD DSNAME=&&TEMP,DISP=(OLD,DELETE),SPACE=(44,(21)), XBDAM5570 // UNIT=SYSDA BDAM5580 //DATA.SYSUDUMP DD SYSOUT=A BDAM5590 ,>BPAM (JCL) - OS/360 BPAM EXAMPLE //* 00000050 //* THIS PROGRAM IS AN EXAMPLE OF THE BPAM ACCESS METHOD 00000100 //* IT USES THE BLDL MACRO AND THE TWO KINDS OF FIND MACROS 00000150 //* TIMING AND RECORD CONSIDERATIONS: 40 SECONDS, 2500 RECORDS 00000200 //* 00000250 // EXEC ASGCG,PARM='NOXREF' 00000300 //SYSIN DD * 00000350 * THIS PROGRAM IS DESIGNED TO ILLUSTRATE THE USE OF THE 00000400 * PARTITIONED ACCESS METHOD. IT HAS TWO SECTIONS; 00000450 * SECTION 1, 00000500 * USES THE BLDL MACRO INSTRUCTION TO BUILD A LIST THAT 00000550 * CONTAINS A RELATIVE TRACK ADDRESS FOR EACH USER CREATED 00000600 * ENTRY. THE LIST MUST BEGIN ON A HALF-WORD BOUNDRY WITH 00000650 * A USER SUPPLIED FULL-WORD OF CONTROL INFORMATION: 00000700 * HALF-WORD 1 -- CONTAINS THE COUNT OF LIST ENTRIES (MAX. 00000750 * 12) 00000800 * HALF-WORD 2 -- CONTAINS THE LENGTH (IN BYTES, MAX. 76) 00000850 * OF EACH ENTRY 00000900 * THE USER SUPPLIES AT LEAST 14 CONTIGUOUS BYTES FOLLOW- 00000950 * ING THE LIST DISCRIPTOR FULL-WORD FOR EACH LIST ENTRY. 00001000 * BYTES 0-7 CONTAIN THE MEMBER NAME LEFT JUSTIFIED AND 00001050 * RIGHT PADDED WITH BLANKS IF NECESSARY. BYTES 8-13 ARE 00001100 * LEFT UNALTERED. THE BLDL MACRO INSTRUCTION COMPLETES 00001150 * EACH LIST ENTRY AND SUPPLIES THE RELATIVE TRACK ADDRESS 00001200 * AND BLOCK NUMBER ON THAT TRACK OF THE MEMBER NAME, THE 00001250 * CONCATENATION NUMBER, WHERE FOUND (PRIVATE,LINK,OR JOB 00001300 * LIBRARIES), WHETHER ENTRY NAME IS A MEMBER NAME OR AN 00001350 * ALIAS, AMOUNT AND TYPE OF USER DATA IN THE PDS DIRECTORY 00001400 * ENTRY. THIS INFORMATION IS PLACED IN BYTES 8-13 OF EACH 00001450 * LIST ENTRY. A FIND MACRO INSTRUCTION IS ISSUED WHICH 00001500 * CONVERTS THE RELATIVE ADDRESSES IN THE BLDL LIST INTO 00001550 * ABSOLUTE ADDRESSES AND INSERTS THEM INTO THE DCB (THIS 00001600 * ALLOWS SUBSEQUENT READS/WRITES OR GETS/PUTS TO DEAL 00001650 * WITH THE DESIRED MEMBER). 00001700 * 00001750 * *NOTE* ALL MEMBER ENTRIES MUST BE IN ALPHAMERIC ORDER 00001800 * SECTION 2, 00001850 * ISSUES A FIND MACRO INSTRUCTION ONLY THIS TIME THE FIND 00001900 * IS DIRECTED TO DO THE PDS DIRECTORY SEARCH ITSELF. THE 00001950 * RELATIVE ADDRESS IS CONVERTED AS IN SECTION 1 AND 00002000 * INSERTED INTO THE DCB. 00002050 * 00002100 * THIS PROGRAM USES MACROS: 00002150 * XSAVE 00002200 * XRETURN 00002250 * XPRNT 00002300 * READ 00002350 * BLDL 00002400 * FIND 00002450 * CHECK 00002500 * LISTHD (PROGRAM LOCAL) 00002550 * LIST (PROGRAM LOCAL) 00002600 * DCB 00002650 * DCBD 00002700 * EACH OCCURRANCE IS EXPLAINED IN THE PROGRAM TEXT. 00002750 * REGISTER USAGE IS EXPLAINED IN THE EQUATE SECTION. 00002800 * 00002850 * 00002900 * PROGRAM LOGIC: 00002950 * 00003000 * THIS PROGRAM RECOVERS FROM THE SYS1.MACLIB AND THE 00003050 * CMACLIB PROGRAM LIBRARIES THE DEFINITIONS FOR FOUR 00003100 * SYSTEM MACROS: CALL, RETURN, SAVE, AND DCB. 00003150 * MACROS CALL, RETURN, AND SAVE ARE RECOVERED 00003200 * USING THE BLDL-FIND MACRO COMBINATION. THE DCB MACRO 00003250 * IS RECOVERED USING THE 'D' TYPE FIND MACRO INSTRUCTION. 00003300 * THE PROGRAM BUILDS THE BLDL LIST FOR CALL, RETURN, 00003350 * AND SAVE, AND DOES THE BLDL ON THAT LIST. A LOOP 00003400 * IS ENTERED THAT DOES A FIND ('C' TYPE) ON THE FIRST 00003450 * LIST ENTRY. AN INNER LOOP STARTS UP THAT READS A 00003500 * BLOCK OF DATA AND DOES DE-BLOCKING AND PRINTS THE 00003550 * DATA. ON E-O-F, THE LOOP FOOT (AEODAD) IS ACTIVATED 00003600 * WHICH TESTS TO SEE IF THE BLDL LIST HAS BEEN PROCESSED 00003650 * IF YES, THE PROGRAM DOES THE 'D' TYPE FIND FOR THE 00003700 * DCB MACRO LISTING AND READS, DE-BLOCKS, AND PRINTS 00003750 * UNTIL IT IS FINISHED, THE PROGRAM THEN TERMINATES. 00003800 * 00003850 * PROGRAM BY: RICHARD FORD 00003900 * JULY,1972 00003950 * 00004000 EJECT 00004050 MACRO 00004100 LISTHD &NAME,&NUM,&LNGTH 00004150 GBLA &LEN 00004200 SPACE 2 00004250 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00004300 * * 00004350 * THIS MACRO EXPANSION WILL CREATE THE LIST DISCRIPTOR FIELD * 00004400 * AS REQUIRED BY THE BLDL MACRO INSTRUCTION * 00004450 * * 00004500 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00004550 SPACE 2 00004600 .* ROUND GLOBAL VARIABLE &LNGTH TO EVEN NUMBER IF NECESSARY 00004650 &LEN SETA (((&LNGTH+1)/2)*2) 00004700 .* 00004750 .* ATTACH BLDL LIST TO &NAME 00004800 &NAME DS 0H . ALIGN TO HALF-WORD BOUNDRY AND 00004850 * STICK TO &NAME 00004900 DC H'&NUM' . NUMBER OF BLDL LIST ENTRIES 00004950 DC H'&LNGTH' . DEFINE LENGTH IN BYTES OF EACH 00005000 .* ENTRY 00005050 MEND 00005100 SPACE 10 00005150 MACRO 00005200 LIST &ENTRY 00005250 GBLA &LEN 00005300 LCLA &T1 00005350 SPACE 2 00005400 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00005450 * THIS MACRO CAUSES EACH LIST ENTRY TO BE PLACED INTO THE BLDL * 00005500 * LIST AND TO ALLOCATE STORAGE FOR EACH ENTRY INTO WHICH THE * 00005550 * CONTROL PROGRAM WILL PLACE ANY DIRECTORY INFORMATION IT CAN * 00005600 * FIND ABOUT EACH ENTRY. EACH ENTRY IS &LNGTH BYTES LONG. * 00005650 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00005700 SPACE 2 00005750 .* SET &T1 TO &LNGTH-8 FOR CORRECT FILL LENGTH AFTER ENTRY NAME 00005800 .* DEFINITION 00005850 &T1 SETA (&LEN-8) GET LENGTH -8 00005900 .* 00005950 DC CL8'&ENTRY' . ENTRY NAME IN CHARACTER, LEFT- 00006000 * JUSTIFIED AND RIGHT PADDED WTH BLANK 00006050 DC XL&T1'FF' . GENERATE CORRECT ENTRY LENGTH 00006100 MEND 00006150 TITLE 'BPAM I/O EXAMPLE' 00006200 * THE DCB DSECT IHADCB FOLLOWS 00006250 SPACE 2 00006300 DCBD DSORG=PO,DEVD=DA 00006350 SPACE 2 00006400 BPAMIO CSECT 00006450 SPACE 2 00006500 PRINT NOGEN 00006550 BPAM XSAVE TR='BPAM I/O EXAMPLE' 00006600 PRINT GEN 00006650 SPACE 5 00006700 * MNEMONIC REGISTER EQUATES FOLLOW 00006750 SPACE 2 00006800 R1 EQU 1 WORK REGISTER 00006850 DCBADD EQU 2 DCB ADDRESS POINTER 00006900 FNDADD EQU 3 TRACK ADDRESS POINTER 00006950 DECB EQU 4 ALWAYS POINTS TO THE DECB 00007000 AREA EQU 5 ALWAYS HAS INTERNAL BUFFER ADDRESS 00007050 ONE EQU 6 USEFUL CONSTANT 1 00007100 HEADING EQU 7 EACH PRINT HEADING ADDRESS 00007150 NEXTHD EQU 8 OFFSET TO NEXT HEADING 00007200 BLDLCNT EQU 9 COUNTING REGISTER FOR PROGRAM CNTRL 00007250 RCRDPT EQU 10 RECORD POINTER REGISTER 00007300 END EQU 11 BUFFER END POINTER 00007350 BASE EQU 12 BASE REGISTER 00007400 SAVE EQU 13 SAVE AREA POINTER 00007450 RETADD EQU 14 RETURN ADDRESS POINTER 00007500 ENTRY EQU 15 ENTRY POINT ADDRESS POINTER 00007550 SPACE 5 00007600 * INITIALIZE REGISTERS WHERE POSSIBLE 00007650 SPACE 2 00007700 LA DCBADD,BPAMDCB GET DCB ADDRESS 00007750 LA FNDADD,BLDLLIST+12 GET BLDL RELATIVE ADDRESS 00007800 LA DECB,MAC GET DECB ADDRESS 00007850 LA AREA,BUFFER GET INTERNAL BUFFER AREA ADDRESS 00007900 LA ONE,1 USEFULL CONSTANT 00007950 LA HEADING,CALLHD FIRST PAGE HEADING ADDRESS 00008000 LA NEXTHD,81 OFFSET TO NEXT HEADING 00008050 LA BLDLCNT,0 INITIALIZE COUNT 00008100 B OPDCB SKIP BLDL LIST SPACE 00008150 SPACE 5 00008200 * NEXT, USE OUR MACROS TO GENERATE BLDL LIST SPACE 00008250 SPACE 2 00008300 * GENERATE LIST HEAD(DISCRIPTOR WORD) 00008350 LISTHD BLDLLIST,3,76 00008400 * GENERATE EACH LIST ENTRY 00008450 LIST CALL 00008500 SPACE 5 00008550 LIST RETURN 00008600 SPACE 5 00008650 LIST SAVE 00008700 SPACE 5 00008750 * OPEN SYS1.MACLIB AND CMACLIB DATA SETS 00008800 SPACE 2 00008850 OPDCB OPEN ((DCBADD),(INPUT)) 00008900 TM BPAMDCB+48,X'10' DID DCB GET OPEN OK 00008950 BNO EXIT IF NOT OPEN QUIT 00009000 SPACE 5 00009050 * CONSTRUCT BLDL LIST WITH THE BLDL MACRO INSTRUCTION 00009100 SPACE 2 00009150 BLDL (DCBADD),BLDLLIST 00009200 SPACE 5 00009250 * ALL INITIALIZATION AND PROGRAM SETUP IS DONE 00009300 * BEGIN BY PRINTING THE FIRST HEADING TO LABEL OUR OUTPUT 00009350 SPACE 2 00009400 PRINT NOGEN 00009450 CFIND XPRNT 0(HEADING),81 PRINT THE HEADING 00009500 XPRNT THRESKP,3 SKIP SOME LINES 00009550 SPACE 5 00009600 PRINT GEN 00009650 * DO FIND ON EACH LIST ENTRY TO RECOVER THE ACTUAL TRACK 00009700 * ADDRESS OF THE MEMBER INTO THE DCB SO THAT IT CAN BE 00009750 * ACCESSED BY QSAM(GET/PUT) OR BSAM(READ/WRITE) 00009800 SPACE 2 00009850 FIND (DCBADD),(FNDADD),C 00009900 SPACE 2 00009950 * THE 'C' PARAMETER INDICATES TO THE FIND MACRO THAT IT IS 00010000 * DEALING WITH THE LIST PRODUCT OF THE BLDL MACRO INSTRUCTION 00010050 * EXECUTION 00010100 SPACE 5 00010150 * NOW READ THE FIRST BLOCK OF THE RETRIEVED DATA INTO SOME 00010200 * INTERNAL BUFFER AREA SO THAT IT CAN BE HANDLED IN SOME 00010250 * USEFULL FASHION 00010300 SPACE 2 00010350 BREAD READ MAC,SF,(DCBADD),(AREA),'S' 00010400 SPACE 5 00010450 * NOW CHECK THE COMPLETION OF THE I/O INITIATED BY THE 00010500 * READ AS NO DE-BLOCKING OF THE RECOVERED DATA CAN BE DONE 00010550 * UNTIL THE TRANSFER IS COMPLETE 00010600 SPACE 2 00010650 CHECK (DECB) 00010700 SPACE 2 00010750 * THE READ RETURNS THE BLOCK SIZE INTO THE DCB FOR USE 00010800 * IN RECORD DEBLOCKING AND OTHER DATA MANAGEMENT 00010850 SPACE 5 00010900 USING IHADCB,DCBADD NOTE USING ON DCB DSECT 00010950 SPACE 5 00011000 * NEXT FOUR INSTRUCTIONS ALLOW THE PROGRAM TO CORRECTLY 00011050 * ACCESS NEXT BUFFER FULL OF INFORMATION ALSO TO DETECT 00011100 * SHORT BLOCKS AT END OF THE CURRENT MEMBER 00011150 SPACE 2 00011200 LH END,DCBBLKSI GET BLOCK SIZE FROM DCB 00011250 L ENTRY,16(DECB) GET IOB ADDRESS 00011300 SH END,14(ENTRY) GET RELATIVE END OF NEW BUFFER 00011350 AR END,AREA GET ABSOLUTE ENDING ADDRESS 00011400 SPACE 2 00011450 LR RCRDPT,AREA COPY AREA POINTER INTO RECORD 00011500 * POINTER REGISTER 00011550 DPRINT MVC PRNTAREA+1(80),0(RCRDPT) DE-BLOCK RECORDS INTO 00011600 * 81 BYTE PRINTING BUFFER 00011650 PRINT NOGEN 00011700 XPRNT PRNTAREA,81 PRINT THE LOGICAL RECORD 00011750 PRINT GEN 00011800 SPACE 5 00011850 LA RCRDPT,80(RCRDPT) UPDATE POINTER BY 80 BYTE LRECL 00011900 CR RCRDPT,END FIND OUT IF BUFFER IS EMPTY 00011950 BNL BREAD IF AT END READ NEW BLOCK 00012000 B DPRINT OTHERWISE-CONTINUE PRINTING 00012050 * OUT OF BUFFER AREA 00012100 SPACE 10 00012150 AEODAD AR BLDLCNT,ONE INCREMENT MEMBER COUNTER 00012200 C BLDLCNT,=F'3' IS BLDL SECTION COMPLETE 00012250 BL UPDATE YES-GO TO UPDATE FIND MACRO 00012300 * POINTER 00012350 TM TERMFLAG,X'FF' OTHERWISE-IS TERMINATION FLAG 00012400 * SET 00012450 BNO DRECTSCH NOT SET-GO FOR DIRECTORY 00012500 * SEARCH EXAMPLE 00012550 SPACE 2 00012600 * OTHERWISE IT IS TIME TO END EXECUTION SO CLOSE THE 00012650 * OPEN DATA SET AND RETURN TO THE SYSTEM 00012700 SPACE 2 00012750 EXIT CLOSE (DCBADD) 00012800 SPACE 2 00012850 * TERMINATE NORMALLY 00012900 SPACE 2 00012950 PRINT NOGEN 00013000 XRETURN SA=* 00013050 PRINT GEN 00013100 SPACE 10 00013150 UPDATE LA FNDADD,76(FNDADD) UPDATE POINTER TO NEXT LIST 00013200 * ENTRY 00013250 AR HEADING,NEXTHD UPDATE HEADING POINTER REG 00013300 * TO NEXT HEADING 00013350 B CFIND DO NEXT FIND, ETC. 00013400 SPACE 5 00013450 * FOLLOWING SECTION DOES A DIFFERENT TYPE OF FIND MACRO 00013500 * INSTRUCTION WHICH FORCES A SEARCH OF THE DATA SETS 00013550 * DIRECTORY IMMEDIATELY. IT TENDS TO BE SOMEWHAT LESS 00013600 * LESS EFFICIENT(SLOWER) THAN A BLDL-FIND COMBINATION, 00013650 * BUT MAY BE EASIER TO ORGANIZE AND CODE. 00013700 SPACE 5 00013750 DRECTSCH OI TERMFLAG,X'FF' SET TERM FLAG TO STOP 00013800 SPACE 5 00013850 FIND (DCBADD),NAME,D 00013900 SPACE 2 00013950 * NOTE THAT THE 'C' PARAMETER IN THE FIND MACRO 00014000 * HAS CHANGED TO A 'D'. THIS INDICATES TO THE SYSTEM 00014050 * THAT THE MEMBER NAME EXISTS ON A DOUBLE-WORD 00014100 * BOUNDRY AND IS A DOUBLE-WORD, LEFT-JUSTIFIED AND 00014150 * RIGHT PADDED WITH BLANKS IF NECESSARY. 00014200 SPACE 2 00014250 PRINT NOGEN 00014300 XPRNT DISRCH,81 PRINT NEW HEADING 00014350 XPRNT THRESKP,3 SKIP SOME LINES 00014400 PRINT GEN 00014450 B BREAD GO BACK TO PROCESS AS BEFORE 00014500 SPACE 2 00014550 LTORG START LITERAL POOL HERE 00014600 SPACE 2 00014650 DS 0D GET DOUBLE-WORD ALIGNMENT 00014700 NAME DC CL8'GET' DEFINE NAME FOR FIND 00014750 SPACE 5 00014800 BPAMDCB DCB DSORG=PO, INDICATE PARTITIONED DATA SET X00014850 DDNAME=MACLIB, LOGICALLY CONNECT TO DD CARD X00014900 EODAD=AEODAD, ON END-OF-DATA GO HERE X00014950 MACRF=R INDICATE MACRO TYPE 00015000 * ALL OTHER REQUIRED INFORMATION WILL BE TAKEN FROM 00015050 * EITHER THE DD CARD OR THE DATA SET LABEL. 00015100 SPACE 5 00015150 CALLHD DC CL81'3********** CALL MACRO LISTING' 00015200 DC CL81'1********** RETURN MACRO LISTING' 00015250 DC CL81'1********** SAVE MACRO LISTING' 00015300 SPACE 2 00015350 DISRCH DC CL81'1********** GET MACRO LISTING USING DIRECT FIND' 00015400 PRNTAREA DC CL1' ' PRINTING BUFFER 00015450 DS 80C RECORD SPACE 00015500 TERMFLAG DC X'00' INITIALIZE TERM FLAG TO OFF 00015550 THRESKP DC CL3'3 ' LINE SKIPPER 00015600 CNOP 0,8 BUFFER ALIGNMENT AND SPACE 00015650 BUFFER DS 500D 00015700 END BPAMIO 00015750 /* 00015800 //DATA.MACLIB DD DSN=SYS1.MACLIB,DISP=SHR,UNIT=2314,VOL=SER=PSU01 00015850 // DD DSN=CMACLIB,DISP=SHR,UNIT=2314,VOL=SER=PSU02 00015900 /*LOG 00015950 /*DUMP 00016000 //DATA.SYSUDUMP DD SYSOUT=A 00016050 /* 00016100 ,>BSAM (JCL) -OS/360 BSAM EXAMPLE //* 0000 //* 0010 //* 0020 //* THIS PROGRAM DEMONSTRATES THE BSAM I/O TECHNIQUES. 0030 //* 1. USES MACROS READ, WRITE, CHECK, POINT, DCB, OPEN, 0040 //* CLOSE, AND A READ-POINT READ FORM. 0050 //* 2. WE WILL READ A CARD FROM THE READER, THEN ECHO 0060 //* PRINT IT TO THE PRINTER. THE CARD IMAGE IS THEN 0070 //* WRITTEN TO DISK USING THE READ-POINT FORM . 0080 //* AT EOD, A POINT MACRO IS ISSUED TO REPOSITION THE 0090 //* DISK SO THAT THE FIRST RECORD CAN BE RECOVERED. 0100 //* AT EOD FROM THE DISK, THE DCBS ARE CLOSED AND 0110 //* CONTROL IS RETURNED TO THE CALLING PROGRAM. 0120 //* 3. TIMEING CONSIDERATIONS: 50 SECONDS,1000 RECORDS 0130 //* 0140 //* 0150 //* 0160 // EXEC ASGCG,PARM.DATA=MAP 0170 //SOURCE.INPUT DD * 0180 TITLE 'BSAM I/O EXAMPLE' 0190 BSAMIO CSECT 0200 * SET STANDARD OS LINKAGE 0210 XSAVE TR=NO 0220 SPACE 5 0230 * OPEN ALL DCBS, CARDCB TO READ DATA, PRNTDCB TO ALLOW WRITE 0240 * TO THE PRINTER, AND THE INTERMEDIATE DISK STORAGE. OUTIN 0250 * OPTION IN OPEN MACRO ALLOWS A WRITE OPERATION FOLLOWED BY 0260 * A READ OPERATION WITHOUT AN ADDITIONAL OPEN-CLOSE SET. 0270 SPACE 5 0280 OPENDCBS OPEN (CARDCB,(INPUT),PRNTDCB,(OUTPUT),DISKDCB,(OUTIN)) 0290 SPACE 5 0300 * TEST THE OPEN, IF OPENS DID NOT GO, TERMINATE WITH ABEND 0310 * GIVING USER 500 COMPLETION CODE 0320 SPACE 5 0330 TM CARDCB+48,X'10' DID THE CARD READER OPEN GO 0340 BNO ABTERM ABNORMALLY TERMINATE 0350 TM PRNTDCB+48,X'10' DID PRINTER OPEN GO 0360 BNO ABTERM ABNORMALLY TERMINATE 0370 TM DISKDCB+48,X'10' DID DISK OPEN GO 0380 BNO ABTERM ABNORMALLY TERMINATE 0390 SPACE 5 0400 * READ A CARD ON THE READER 0410 SPACE 5 0420 LA 5,0 SET UP CARD COUNTER 0430 READ READ CARDECB,SF,CARDCB,BLOCK READ A CARD IMAGE INTO BLOC 0440 SPACE 5 0450 * ISSUE CHECK TO TEST COMPLETION OF I/O OPERATION 0460 SPACE 5 0470 CHECK CARDECB CHECK FOR I/O COMPLETION 0480 SPACE 5 0490 LA 5,1(5) COUNT CARDS COMMING IN 0500 * DO A WRITE TO PRINTER FOR ECHO PRINT 0510 SPACE 5 0520 WRITE DISKDECB,SF,DISKDCB,BLOCK WRITE TO DISK FROM BLOCK 0530 SPACE 5 0540 * ISSUE CHECK AS ABOVE 0550 SPACE 5 0560 CHECK DISKDECB IS I/O OPERATOON COMPLETE 0570 SPACE 5 0580 * SAVE CARD IMAGE ON DISK 0590 SPACE 5 0600 WRITE PRNTDECB,SF,PRNTDCB,BLOCK-1 WRITE TO THE PRINTER 0610 SPACE 5 0620 * CHECK AS BEFORE 0630 SPACE 5 0640 CHECK PRNTDECB IS I/O OPERATION COMPLETE 0650 SPACE 5 0660 B READ LOOP TO GET ALL DATA 0670 SPACE 5 0680 * PRINT A LITERAL INDICATING EOD ON CARD READER, BEGIN 0690 * READING FROM THE DISK 0700 SPACE 5 0710 ENDATA WRITE PRNTDEC1,SF,PRNTDCB,LITERAL 0720 SPACE 5 0730 * ISSUE CHECK AS ABOVE 0740 SPACE 5 0750 CHECK PRNTDEC1 0760 SPACE 5 0770 * SINCE DISK DCB WAS NOT CLOSED AT EOD A POINT MACRO MUST 0780 * BE ISSUED TO REPOSITION THE THE DISK AT THE FIRST RECORD 0790 SPACE 5 0800 POINT DISKDCB,POINT REPOSITION DISK TO GET 1ST REC. 0810 SPACE 5 0820 * 0830 * NOW READ FROM DISK AND WRITE TO PRINTER USING SAME DATA 0840 * 0850 SPACE 5 0860 DISKRD READ DISKDEC1,SF,DISKDCB,BLOCK 0870 SPACE 5 0880 * CHECK FOR END OF I/O OPERATION 0890 SPACE 5 0900 CHECK DISKDEC1 CHECK I/O COMPLETION 0910 SPACE 5 0920 * WRITE TO PRINTER AS CARDS COME OFF DISK 0930 SPACE 5 0940 WRITE PRNTDEC2,SF,PRNTDCB,BLOCK-1 0950 SPACE 5 0960 * CHECK I/O DONE 0970 SPACE 5 0980 CHECK PRNTDEC2 I/O COMPLETION CHECK 0990 SPACE 5 1000 BCT 5,DISKRD WRITE ONLY THE CARDS THERE 1010 SPACE 5 1020 END CLOSE (CARDCB,,PRNTDCB,,DISKDCB) CLOSE ALL ACTIVE DCBS 1030 * SET UP RETURN TO CALLER (OS) 1040 XRETURN SA=*,TR=NO 1050 SPACE 5 1060 ABTERM ABEND 500,DUMP GET ABEND DUMP IN CASE OF TROUBL 1070 DC 0F'0' 1080 POINT DC X'00000100' CONTROL WORD FOR POINT MACRO 1090 DC C' ' ASA CARRIAGE CONTROL CHAR. 1100 BLOCK DC 80C' ' BUFFER AREA 1110 LITERAL DC C'-REPEAT READ DATA FROM DISK',80C' ' 1120 SPACE 5 1130 CARDCB DCB RECFM=F, DATA FORMAT IS FIXED X 1140 BLKSIZE=80, PHYSICAL BLOCK SIZE IS 80 BYTES X 1150 LRECL=80, LOGICAL RECORD SIZE IS 80 BYTES X 1160 DDNAME=INPUT, LOGICALLY CONNECT TO INPUT DATA S 1170 EODAD=ENDATA, ON EOD GO TO ENDATA X 1180 SYNAD=ABTERM, I/O ERROR GO TO ABTERM X 1190 MACRF=(R), BSAM I/O USES READ/WRITE MACROS X 1200 DSORG=PS DATA SET ORGANIZATION 1210 * PHYSICAL SEQUENTIAL. 1220 SPACE 5 1230 PRNTDCB DCB RECFM=FA, RECORD FORMAT FOR OUTPUT X 1240 BLKSIZE=80, PHYSICAL BLOCK SIZE X 1250 LRECL=80, LOGICAL RECORD SIZE X 1260 DDNAME=FT06F001, CONNECT TO OUTPUT DEVICE X 1270 SYNAD=ABTERM, I/O ERROR GO TO ABTERM X 1280 DSORG=PS, DATA SET ORGAN. IS PHYS. SEQU. X 1290 MACRF=(W) END PRINTER DCB 1300 SPACE 5 1310 DISKDCB DCB RECFM=F, RECORD FORMAT FOR DISK I/O X 1320 BLKSIZE=80, PHYSICAL BLOCK 80 BYTES X 1330 LRECL=80, LOGICAL RECORD LENGTH X 1340 DDNAME=FT09F001, LOGICALLY CONNECT TO DEVICE X 1350 EODAD=END, ON EOF GO TO END X 1360 SYNAD=ABTERM, PERMANENT I/O ERROR GO TO ABTERMX 1370 DSORG=PS, DATA ORGAN. IS PHYS. SEQU. X 1380 MACRF=(RP,W) READ WRITE COMBINATION 1390 SPACE 5 1400 * END OF DCBS FOR I/O OPERATION 1410 END BSAMIO 1420 /* 1430 //DATA.FT09F001 DD UNIT=SYSDA,SPACE=(CYL,1),DSN=&&TEMP, X 1440 // DISP=(NEW,DELETE) 1450 /*LOG 1460 //DATA.XSNAPOUT DD SYSOUT=A 1470 //DATA.SYSUDUMP DD SYSOUT=A 1480 //DATA.INPUT DD * 1490 I AM THE FIRST CARD TO BE READ 1500 I AM THE SECOND CARD TO BE READ 1510 I AM THE THIRD CARD TO BE READ 1520 CARDS ARE ECHO PRINTED AND WRITEN TO DISK 1530 THEN ARE READ FROM THE DISK AND PRINTED AGAIN 1540 THIS IS THE LAST CARD 1550 /* 1560 ,>CS102AS1 (TEXT) - 1ST ASSEMBLER COURSE ASSIGNMENT , CS102AS1 - 01 COMPUTER SCIENCE 102 - ASSIGNMENT 1 DUE __________ This assignment covers simple input/output, binary arithmetic for fullword and halfword numbers, and basic data movement and testing codes for handling such numbers. AI. BASIC PROGRAM The basic program should do the following: A. Read a card (XREAD), and print it out immediately (called an ECHO CHECK - standard practice). The card contains 5 numbers punched on it, which are to be scanned and converted (XDECI) to binary form, and placed in 5 consecutive fullwords in memory. Print the hexadecimal values of these 5 words (20 bytes), using XDUMP. B. Perform the following computations in a straightforward way, storing each result in name given, using RX instructions where you can): 1. F = A + B + C 2. G = -A - B - C (LCR useful) 3. H = A * B * E 4. I = A / B (be careful, watch for negative #'s) 5. J = MOD(A,B) (i.e., remainder from# 4.) 6. K = ((A + E) * (B - C)) / D C. Print all of the above values (F - K) in hexadecimal (XDUMP), then also print them in decimal, using XDECO and XPRNT (print their values an headings all on one line. D. According to the sign of result H, print one of the 3 messages: H IS LESS THAN ZERO, H IS GREATER THAN ZERO, H IS ZERO. II. EXTENDED VERSION OF PREVIOUS PROGRAM Modify the previous program (which only had to read 1 card), to read cards and follow the actions above for each card, until there are no more cards (END-OF-FILE). Keep a count of the number of cards read, and print out this total number before ending the program. III. HALFWORD VERSION OF PROGRAM II. Modify program II to use halfwords wherever possible (i.e., store A - K as halfwords, use AH instead of A, etc. Watch out for divides, since no DH instruction exists). How much storage is saved? IV. REGISTER VERSION OF PROGRAM II. Change program II by saving all values A - F in registers, then use RR instructions rather than RX instructions. Do XDECI commands directly into registers where the values are saved. A useful trick may be to NAME the registers symbolicly: RA EQU 3 REGISTER WHERE VALUE A KEPT XDECI RA,CARD CONVERT VALUE A INTO REG RA This technique will make it clear which value you are using (note that any register reference can be symbolic to an EQU symbol). , CS102AS1 - 02 V. WHAT TO HAND IN By using the BATCH feature in ASSIST, you can run several programs in one run. Turn in one run, with each of the programs II, III, and IV shown in execution, with results and output as requested. The run will use control cards like: // EXEC ASACG,PARM=BATCH //SYSIN DD * $JOB ASSIST PROGRAM VERSION II ..... program II $ENTRY ..... test data *** repeat above, starting at $JOB, for programs III and IV. /* The following test data should be used for each program: A B C D E 5 2 -4 -2 2 -2 -1 10 1 -1 4096 1 1 -1 -1 Note that the columns they are punched in should not matter. , CS102AS1 - 03 COMPUTER SCIENCE 102- ASSIGNMENT 2 This assignment uses the concept of indexing________ into an array of elements. I. BASIC PROGRAM A. Read a card (and echo print) containing a maximum of 20 numbers. Convert the numbers to hex(XDECI) and store them in successive fullwords in memory. Use a loop to eliminate redundant coding. Then, for each card, find the maximum value and the minimum value, printing out these numbers with appropriate labels. B. Form of data 1. Each card contains a maximum of 21 numbers, where the first number =the number of numbers on the card. You will need the first number for a counter in the loop in part A. 2. There are an un__ specified # of data cards. i.e., make your program general to accept any # of data cards. II. DATA FOR _OUR PROGRAM 3 56 76 -76 7 11 123 432 -123 748 -9087 -0 6 33 33 45 10 6 90 4 145 1024 6698 -1024 345 $ ,>CS102FP1 (TEXT) - FINAL PROJECT IN FIRST COURSE - PART1. , 00000010 CS102FP1-01 00000020 COMPUTER SCIENCE 102 FINAL PROJECT 00000030 DUE ____________ 00000040 Pages 1-8 00000050 00000060 00000070 00000080 00000090 I. INTRODUCTION 00000100 00000110 00000120 One of the concerns of a programmer is to design computer 00000130 systems, languages, and translators for the languages. The monitor 00000140 is that part of the system which controls the running of the 00000150 translators and interpreters.It examines the JCL to determine the 00000160 beginning and end of a job. 00000170 The function of the translator, or assembler, is to accept as 00000180 input a source language(e.g. IBM 360 Assembler Language) and 00000190 generate equivalent code in some target language (e.g. machine 00000200 language). This code is called object code. In addition to 00000210 translating, the assembler should have the capability of detecting 00000220 syntactic errors in the source listing. The interpreter however 00000230 executes the intructions of the target language. 00000240 00000250 II. LANGUAGE FORMAT 00000260 00000270 00000280 A. Control Cards 00000290 00000300 00000310 1. Control cards will be used in TRIVIAL. These cards direct the00000320 monitor about how to process a job. On the IBM s/360 these cards are00000330 called Job Control Language cards(JCL). Also included with the JCL 00000340 cards will be control cards used by the assembler. 00000350 00000360 2. These cards indicate the start of a program, end of assembly 00000370 and start and end of data. 00000380 00000390 B. Assembly Language 00000400 00000410 00000420 There are two types of instructions: 00000430 1. Machine instructions-can be executed by the computer hardware 00000440 The instruction consists of a mnemonic opcode followed by one or 00000450 more operands. A label field is optional. All are in free format, 00000460 i.e. one or more blanks in between. 00000470 00000480 ex- LABEL OPCODE OPERAND(S) COMMENT 00000490 separated by 00000500 commas 00000510 00000520 2. Assembler Instructions-or pseudo-instructions, or pseudo-ops. 00000530 These are instructions to the assembler. Examples are reserving 00000540 storage(DS), reserving storage with initial value(DC), setting the 00000550 location counter (ORG and START instruction ). 00000560 ## 00000570 , 00000580 CS102FP1-0200000590 00000600 00000610 C. Machine Code (or Object Code) 00000620 00000630 00000640 1. Machine code is the output of the assembler. The format of the 00000650 code varies from machine to machine, but in general consists of the 00000660 following: 00000670 00000680 OPCODE- coded form of the operation to be performed. 00000690 REGISTER-part of an operand 00000700 ADDRESS-part of the operand. It can consist of 00000710 00000720 a. base and displacement 10(2) 00000730 b. an actual address 100 00000740 c. an indirect address 00000750 d. an indexed register form 0(11,12) reg 11 index 00000760 e. shift counter SLA 2,4 00000770 f. immediate operand CLI 2,x'F0' 00000780 00000790 00000800 III. IMPLEMENTATION 00000810 00000820 A. Monitor 00000830 00000840 00000850 1. The monitor examines the control cards to determine the start 00000860 and end of a job. 00000870 00000880 2. The monitor usually examines switches to determine what to do. 00000890 e.g. If the assembler sets the switch for valid assembly done. 00000900 the monitor then calls for execution of the program. 00000910 3. The monitor skips to the next job if the current job can not 00000920 be executed as shown by flags.(may skip data cards) 00000930 00000940 B. Assembler 00000950 00000960 Assemblers vary as to the number of passes it performs. The number00000970 is a function of the size of the machine, the speed(wanted) and the 00000980 complexity if the source language. We will be interested in a 2-pass00000990 assembly, which is most common. 00001000 00001010 1. The first pass 00001020 00001030 a. In the first pass, the opcodes are checked for validity 00001040 (e.g. an opcode may not exist or may not be implemented on a 00001050 certain machine). 00001060 00001070 b. Symbols (statement labels,variable names) are entered in the 00001080 symbol table. 00001090 00001100 c. Storage is reserved for constants. Note that some storage 00001110 requested must be on a specified boundary as in the 360(fullword,..)00001120 ## 00001130 , 00001140 CS102FP1-0300001150 00001160 00001170 d. The location counter is incremented according to the length 00001180 of the instruction or storage(allocated). Note instructions may 00001190 vary in length for some computers (like the 360). 00001200 00001210 e. The source statements are saved so that a listing may be 00001220 printed at a later pass. Information added to each source statement 00001230 would be the opcode type, statement number, the location counter 00001240 value, or anything else. 00001250 00001260 f. Assembler instructions are recognized and appropriate 00001270 action is taken. 00001280 00001290 g. A copy of these source statements may reside in core if there00001300 is enough space, or may be put on disk or magnetic tape. 00001310 00001320 2. The second pass-first it must retreive the source statements fo00001330 further processing. 00001340 a. The operands are then processed according to their type & 00001350 and type of op-code they are with. 00001360 b. Object code is then created for the instructions and data 00001370 definitions; It then resides in core or is put on disk or tape. 00001380 00001390 c. A listing is printed. It contains the location counter, 00001400 generated code, and source statment for each source statement. 00001410 Error messages are also printed on the listing. 00001420 00001430 d. The errors to check for (assembly time errors) 00001440 1. multiply defined symbols 00001450 2. undefined symbols 00001460 3. invalid opcode 00001470 4. invalid values e.g. if a machine has 16 registers and 00001480 program uses register 17 00001490 5. invalid labels-in Fortran, a label of 9 letters 00001500 00001510 3. During assembly a table (which will remain fixed) will contain 00001520 all of the legal opcodes. Information included could be the name 00001530 of the opcode (mnemonic ) and type (machine or pseudo-op). 00001540 00001550 4. A symbol table is also formed. It contains the symbol, the 00001560 location counter value, and maybe other flags. Each symbol is entere00001570 when it appears and when a reference is made in an operand the 00001580 symbol is looked up and the value obtained. 00001590 ## 00001600 , 00001610 CS 102FP1-04 00001620 00001630 00001640 C. Interpreter/Execution monitor 00001650 00001660 1. If the target language is executable of the 360, then merely 00001670 branch to the program. 00001680 00001690 2. Otherwise, initialize the program counter (location counter) 00001700 to BEGIN and execute the object code using pseudo registers and 00001710 pseudo storage. You will also need a Program Status Word(PSW) 00001720 containing necessary flags.Execution is as follows: 00001730 00001740 1. Fetch the next instruction & increment location counter 00001750 according to the length of the instruction 00001760 2. Decode the instruction & evaluates address(es). 00001770 3. Execute the instruction 00001780 4. Go to 1. 00001790 00001800 3. During execution there is to be error checking for: 00001810 00001820 a. reading beyond end of file 00001830 00001840 b. executing too many instructions (a limit will be set on 00001850 the job card) 00001860 c. invalid op-code (by branching into data area) 00001870 00001880 d. address out of range of program 00001890 00001900 4. A dump should be provided at the end of each job. Information 00001910 included will be the value of the program counter, the contents of th00001920 registers, and the storage. 00001930 ## 00001940 , 00001950 CS 102FP-05 00001960 00001970 00001980 00001990 IV. FLOWCHARTS 00002000 00002010 A. General Flow of Monitor 00002020 00002030 00002040 00002050 TRIVIAL 00002060 MONITOR 00002070 00002080 00002090 00002100 00002110 read a card 00002120 00002130 (flush) 00002140 00002150 is it /*,$*, ----------->$* or anything else 00002160 or job card 00002170 ? 00002180 /*-------------->print end of 00002190 processing message 00002200 00002210 job card STOP 00002220 00002230 00002240 00002250 PASS 1 00002260 assemble opcode,res, 00002270 create symbol table 00002280 00002290 call TRIVIAL assembler 00002300 00002310 PASS 2 00002320 assemble operands 00002330 00002340 00002350 00002360 EXECUTE 00002370 execute assembled call TRIVIAL interpreter 00002380 program 00002390 ## 00002400 , 00002410 CS102FP1-0600002420 00002430 00002440 00002450 B. TRIVIAL assembler-Initialization and Pass 1 00002460 00002470 00002480 00002490 TRIVIAL ASSEMBLER 00002500 00002510 00002520 initialize symbol 00002530 table to blanks 00002540 00002550 00002560 00002570 set flag that prog 00002580 is executable 00002590 00002600 00002610 00002620 read next card <------------------ B 00002630 00002640 00002650 00002660 END card ---------->yes -------> Pass 2 00002670 00002680 no 00002690 00002700 is there a 00002710 a label? 00002720 ------> yes ---> LOOK UP ---> in ---->no exec00002730 symbol set flag00002740 not in 00002750 00002760 00002770 enter symbol & set flag 00002780 displacement in print err00002790 table.Note whether message i00002800 an RES. PASS 2. 00002810 00002820 00002830 determine type RES? 00002840 of stmt;create convert operand to binary 00002850 partial obj. code 00002860 update loc. update location counter fo00002870 counter illegal opcode proper boundary(if necessar00002880 00002890 00002900 00002910 B store number 00002920 00002930 00002940 00002950 set flag for update loc counter 00002960 .false. for 00002970 execution B 00002980 00002990 B 00003000 ## 00003010 , 00003020 CS102FP1-07 00003030 00003040 00003050 00003060 TRIVIAL Assembler Pass 2 00003070 00003080 00003090 PASS 2 00003100 00003110 00003120 00003130 00003140 E ---------> get next card image 00003150 00003160 00003170 00003180 end stmt? --------> yes ----> return to Monitor 00003190 00003200 00003210 no 00003220 00003230 process operands 00003240 using LOOK UP 00003250 00003260 00003270 00003280 illegal operand? -------> yes -----> set flag 00003290 also flag=.fa00003300 no for execute 00003310 00003320 00003330 finish object code 00003340 for stmt D 00003350 00003360 00003370 D ------> print card image& 00003380 error message(s) 00003390 00003400 00003410 update loc counter 00003420 00003430 00003440 E 00003450 00003460 00003470 LOOK UP 00003480 00003490 00003500 find symbol 00003510 in table? -----> yes ----> return displacement return 00003520 & flag 00003530 00003540 no 00003550 00003560 00003570 RETURN 00003580 00003590 00003600 00003610 ## 00003620 , 00003630 CS102FP1-08 00003640 EXEC 00003650 00003660 00003670 00003680 no <----------------- execute=.false.? ---> yes ---> print terminatio00003690 message 00003700 00003710 00003720 set up psedo-reg 00003730 & storage flush cards unti00003740 $* 00003750 00003760 00003770 00003780 execute instructions 00003790 00003800 00003810 00003820 wait stmt? ------> no TRIVIAL 00003830 00003840 00003850 yes 00003860 Print dump 00003870 00003880 00003890 Return to monitor 00003900 00003910 ## 00003920 ,>CS102FP2 (TEXT) - 2ND PART OF FINAL PROJECT (WHICH ISAN , CS102FP2 - 01 V. SPECIFIC LANGUAGE DETAILS FOR THE TRIVIAL SYSTEM This section describes the exact details for the various parts of the TRIVIAL system. The monitor (main program) processes various control cards, which direct further processing. The TRIVIAL assembly language is converted by the assembler into machine code for a computer system called the SIGMA 4.5 . The interpreter portion then simulates the operation of the SIGMA 4.5, using S/360 instructions. A. CONTROL CARDS 1. JOB CARD - SHOWS BEGINNING OF TRIVIAL PROGRAM This card has the following format (starting in column 1): $$JOB jobname number $$JOB identifies this as a JOB card jobname is a sequence of up to 20 nonblank characters which identify this JOB. number gives a maximum limit on the number of instructions which can be executed by the user program on the simulated SIGMA 4.5 . There may be any number of blanks before and after jobname, i.e., these cards are FREE FORMAT. 2. $* CARD - INDICATES END OF A JOB This card is of following format, beginning in column 1: $* rest of card is ignored. 3. OVERALL DECK SETUP The input to TRIVIAL is made up of 1 or more JOBS, each as follows: $$JOB jobname#1 # instructions limit for job 1 ..... TRIVIAL assembly program END card (showing end of assembly program) ..... 0 or more data cards to be read by program $* Note that any user program cannot be allowed to read beyond a $* or $$JOB card into the next user's program. Test decks will be supplied to the students. , CS102FP2 - 02 B. TRIVIAL ASSEMBLY LANGUAGE The following describes the format of a TRIVIAL assembly program, giving in detail the forms of mnemonic opcodes, operands, and labels. NOTE: the reader should probably first consult Part C, since it gives the machine code formats used by the SIGMA 4.5 . 1. MACHINE INSTRUCTIONS There are essentially two formats for machine instructions: RX format, which is similiar to S/360 RX format, and RI format, which operates on a register and an immediate operand field. a. RI INSTRUCTIONS These instructions follow the format below: label opcode register,immediate label is an optional statement label opcode is one of the immediate operand instructions (like AI) register is a decimal number from 0 - 15 (no leading zeroes. immediate is a signed or unsigned decimal number from -1048576 to +1048575 to be used as an immediate value. b. RX INSTRUCTIONS This format is basically like S/360 RX format, with some restrictions plus an addition for indirect addressing. label opcode register,address label is optional statment label opcode is one of the RX opcodes, like AW. register is decimal number from 0 - 15 (like register in RI above). address represents an address in memory, and may have any of the forms given below. Note that symbol represents any legal label, n represents any unsigned number representable in 17 bits, and index represents any decimal number from 0 to 7, giving an index register. The formats are then: symbol implying direct addressing, index = 0 symbol+n " " " " " " " symbol-n " " " " " " " n " " " " " " " any of the above followed by (index), i.e, symbol+n(index) implying index register of given value. any of the above preceded by *, indicating INDIRECT ADDRESS. Any place symbol appears above, the character $ can appear, which refers to the location counter value (like S/360 *). EXAMPLES: AI 0,1000 ; AW AREA+12(7) ; BCS 8,LOOP1 ; BDR 2,LOOP ; LW 1,*VECTOR+5(2) , BCS 15,$+2 , CS102FP2 - 03 2. ASSEMBLER INSTRUCTIONS (PSEUDO OPS) a. ORG - sets location counter to value specified in operand, which may be any of the forms symbol, symbol+n, symbol-n, n, $, $+n, $-n allowed by first section of RX operand format. EXAMPLES: ORG LABEL+2 NOTE: may not have a LABEL field specified, and any symbols used must be previously defined. b. END - signifies end of TRIVIAL program, may have no label. c. RES (REServe) - similiar to S/360 DC and DS, reserves storage and may fill in constants. It may have any r of the following forms: label RES number The statement above reserves number words of storage, number being a positive integer from 0 to 1023 . label RES W'number' This statement causes the decimal number (signed/unsigned) to be converted to binary and assembled at the given location. (corresponds to S/360 DC F'number' ). label RES numberW'number' The first number gives a duplication factor from 1 - 1023, and causes that many copies of the constant to be assembled (like S/360 DC numberF'number' ). 3. MISCELLANEOUS The label field may contain any label usable on S/360, except that $. @, # are excluded , i.e., a label begins with a letter, and then containues with 0-7 letters/digits. NOTE THAT ALL STATEMENTS ARE FREE FORMAT: they may have 1 or more blanks between fields, but no blanks inside each field. , CS102FP2 - 04 C. DESCRIPTION OF THE SIGMA 4.5 COMPUTER SYSTEM 1. MEMORY, REGISTERS, AND PROGRAM STATUS BITS The MEMORY of the SIGMA 4.5 (model W72), is composed of 1024 WORDS, (addressed at locations 0, 1, 2, ..... 1023). Each is 32 BITS long. The SIGMA 4.5 contains 16 REGISTERS, each 32 bits long, numbered from 0 to 15. Of These, all may be used for holding operands and doing arithmetic, while registers 1-7 only may be used as INDEX REGISTERS in address calculations. A PROGRAM STATUS WORD is used to keep the current status of the SIGMA 4.5 computer. Of the 32 bits in this word, the following uses are made of: BITS NAME USAGE 0-1 CONDITION CODE exactly like S/360 condition code. 2-14 UNUSED 15-31 PROGRAM COUNTER 17-bit address of the next instruction in memory to be executed. NOTE: all numbers are encoded as 32-bit signed numbers, using two's complement notation. 2. INSTRUCTION FORMATS, ENCODING, ACTIONS The SIGMA 4.5 has two basic instruction formats: RX (Register to Storage, Indexed, almost exactly like S/360 RX). RI (Register Immediate - uses Immediate operand in instruction). The layout of the RX-format instruction is as follows: 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 BIT # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - ------------- ------- ----- --------------------------------- NAME I OP R X M - ------------- ------- ----- --------------------------------- SIZE 1 7 4 3 17 bits The various fields above are used as follows: I INDIRECT ADDRESS: 0 => direct addressing, 1 => indirect (see below) OP OPCODE: number from 0 to 127 noting which operation to be done. R REGISTER: number from 0 - 15 specifying a register (usually), or sometimes a Branch Mask or other value. X INDEX REGISTER: number from 0-7 specifying an index register, with 0 specifying NO indexing. M MEMORY ADDRESS: number from 0 - 128K, specifying the actual location in memory of an operand. , CS102FP2 - 05 EFFECTIVE ADDRESS CALCULATION: RX INSTRUCTIONS In general, the SIGMA 4.5 calculates an EFFECTIVE ADDRESS (EA) using the I, X, and M fields in the procedure below, then operates in some way on the word at the EA and the word in register R. The EA is determined by the following steps: First, the M field is taken either as the address of a word in memory, or the address of an address of a word in memory, depending on the I bit, as follows: If I=0, then EA1 = M (Direct addressing) If I=1, then EA1 = low-order 17 bits of word at location M. (This is called INDIRECT ADDRESSING). Now, EA1 is either taken as the EA, or is modified by adding to it the contents of an index register X, as follows: If X=0, EA = EA1 (no indexing). If X ^= 0, EA = EA1 + contents of register X. NOTE: EA1 is a positive 17 bit number, while value in register X may be either positive or negative. Thus, if M=100, X=1, and register 1 contains -10, the location referenced should be 90 = 100 + -10 . NOTES AND GENERAL INFORMATION: The SIGMA 4.5 stops at doing only 1 indirect address step, and thus uses ONE-LEVEL INDIRECT ADDRESSING. Some other machines would extend this by testing the I bit in a word, and if on, perform another indirect addressing step, until a word was found wit1out I=1, in which case that word would have the address of the word finally used as an operand. This type is called MULTILEVEL or CASCADED INDIRECT ADDRESSING. Also, since SIGMA 4.5 adds the index register X AFTER any indirect addressing is done, it is called POST-INDEXING. Some machines perform indexing before indirect addressing, and are thus called PRE-INDEXING systems. The RI (Register Immediate format) instructions are basically similiar to the RX, except: The I bit is ignored. The X and M fields together form a two's-complement, signed, 20-bit number, which is extended to 32 bits, then used as the operand in combination with the register R. This allows numbers from -1048576 to +1048575 to be specified in the instruction. , CS102FP2 - 06 3. OPCODE TABLE The following table lists the mnemonic opcode for each machine instruction, the machine code for each operation (hexadecimal, 7-bits), the instruction format (RX, RI), whether or not the instruction sets the condition code, and finally, exactly what the instruction does. If an instruction corresponds to an S/360 instruction, it sets the CC in the same way, unless otherwise specified. NAME CODE TYPE CC SET ACTION ---- -- -- --- ----------------------------------------------- AI 20 RI YES ADD IMMEDIATE : add Immediate field to reg R. LI 22 LI NO LOAD IMMEDIATE : extend immedaite field to 32 bits, load that value into register R. MI 23 RI YES MULTIPLY IMMEDIATE : extend immedaite field, multiply with register R, truncate to botain low-order 32 bits in R, setting CC for result. WAIT 2E RX NO WAIT: execution terminates, EA placed into specified register as a completion code. AW 30 RX YES ADD WORD: like S/360 A. CW 31 RX YES COMPARE WORD : like S/360 C. LW 32 RX NO LOAD WORD : like S/360 L. MTW 33 RX YES MODIFY AND TEST WORD: the R field does not refer to a register; instead, it is taken as a signed, 4-bit number ( -8 to +7), extended to 32 bits, and added to word at EA, setting CC STW 35 RX NO STORE WORD : like S/360 ST. MW 37 RX YES MULTIPLY WORD: like MI, except operand taken from EA location instead of immediate field. SW 38 RX YES SUBTRACT WORD : like S/360 S. BDR 64 RX YES BRANCH ON DECREMENTING REGISTER: Modify reg R by subtracting 1. Set CC according to result and branch to EA location if result > 0. AWM 66 RX YES ADD WORD TO MEMORY : add contents of register R to word at location EA. BCS 69 RX NO BRANCH CONDITIONS SET : uses R as a Mask field to branch or not : same as S/360 BC RD 6C RX YES READ DIRECT : read a card (set CC = 0), if no more remain, CC = 1. A single signed number anywhere on the card is converted to binary and placed in the register specified by R. EA is totally ignored, and may have any value. WD 6D RX NO WRITE DIRECT : the number in register R is converted to decimal and printed. $$JOB LEGALOPS1 0 *********************************************************************** 00010010 ********** ATTENTION: USE LARGE PARAMETER IF YOU ARE GETTING AS999, 00010020 ********** SIMILIAR MESSAGE ABOUT EXCEEDING SPACE - SEE ASSIST MANUAL. 00010030 ********* NOTE EXTENSION/EXTENSION/EXTENSION: FINAL PROJECTS DUE AT * 00010040 ********* 11AM WEDNESDAY, NOT MONDAY. * 00010050 *********************************************************************** 00010060 * THIS PROGRAM CONTAINS NO ERRORS. IT IS A TEWST FOR THE * RECOGNITION OF ALL LEGAL OPCODES. THE PROGRAM WILL NOT * BE EXECUTED AI 1,-2 AW 1,3(2) LI 1,2 CW 1,2 LABEL MI 1,2 LW 1,3(2) MTW 1,3(2) STW 1,2 ORG LABEL MW 1,2 SW 1,2 BDR 1,3(2) AWM 1,3(2) BCS 1,3(2) RD 1,3(2) WD 1,3(2) WAIT 2,2 WORD RES 2 RES W'2' RES 2W'2' END $* $$JOB LEGALOPS2 0 * THIS PROGRAM TEST THE RECOGNITION OF LEGAL OPERANDS MI 1,2 MI 1,-2 MI 1,+2 AW 1,2 AW 1,*2 AW 1,2(3) AW 1,*2(3) AW 1,$ AW 1,*$ AW 1,$(3) AW 1,*$(3) AW 1,$+2 AW 1,*$+2 AW 1,*$+2(3) AW 1,$+2(3) AW 1,SYMBOL AW 1,*SYMBOL AW 1,SYMBOL+7 AW 1,*SYMBOL+7 AW 1,SYMBOL+1(2) AW 1,*SYMBOL+1(2) AW 1,*SYMBOL-1(2) SYMBOL RES 5 END $* $$JOB PASS1ERR 0 * THIS PROGRAM CONTAINS ERRORS IN LABELS AND ASSEBLER OPS LI 5,0 LI 3,0 SWR 3,0(2) ILLEGAL OPCODE AI 2,4 LOOP MI 2,CONST 7LAB SW 2,CONST+1 ILLEGAL LABEL STW 2,SAVE UNDEFIND SYMBOL ORGLINE ORG LOOP NO LABEL ALLOWED RD 3,AREA1 UNDEFINED LABEL STW 3,SUM OUT WD 3,AREA AWM 3,SUM BRANCH BDR 2,LOOP READ 2,AREA ILLEGAL OPCODE BADLABEL LW 5,SUM LABEL TOO LONG OUT WD 5,SUM MULTIPLY DEFINED LABELS * NOTE- BLANK CARD FOLLOWS MTW 0,OUT ORG $-100 ORG TO NEGATIVE ADDRESS SUM RES 1 RES W'-9999' * THE FOLLOWING RES STMTS ARE IN ERROR AREA RES 1100 TOO LARGE RES 0W'1' RES 10W RES W'10 ' RES W' RES W'12345A' RES -10W THISLABELISTOOLONG ANDSOITTHISOPCODE MTW 0,0 ENDLABEL END ILLEGAL LABEL FIELD $* $$JOB PASS2ERR 0 * THIS PROGRAM CONTAINS ERRORS IN THE OPERANDS * RI FORMATS * OMMITTED OPERAND FOLLOWS AI LI 16,0 REGISTER TOO LARGE LI 15 OPERAND OMITTED LI 15, OPERAND OMMITTED LI ,0 OMITTED REGISTER LI 15,524288 TOO BIG LI 15,-524289 LI 15,524287 LEGAL LI 15,-524288 LEGAL LI 15,0, INVALID DISPLACEMENT * * RX FORMAT AW 16,0 REGISTER TOO LARGE AW 15 AW 15, OMITTED OPERAND AW 15,* OMITTED OPERAND AW 15,*(1) OMITTED SYMBOL X AW 15,5+X WRONG ORDER AW 15,5+1 AW 15,X+ ILLEGAL OPERAND AW 15,X+(3) AW 15,*X-(3) AW 15,X-(3, AW ,X-X OMITTED REGISTER AW 15,0(8) AW 15,X+5(8) INDEX ERG TOO LARGE AW 15,$(8) INDEX REG TOO LARGE AW 15,$-2, AW 15,0(7)+ AW 15,$-20000 BAD ADDRESS AW -1,0 ILLEGAL REG SPECIFICATION AW 0,-1 AW 0,1(-1) AW 0,131071 LEGAL AW 0,131072 TOO BIG END $* $$JOB READBEYONDEND 100 00011360 LOOP RD 0,0 READ A CARD 00011370 WD 0,0 WRITE IT BACK OUT 00011380 BCS 15,LOOP LOOP FOREVER, OR UNITL CARDS RUN OUT 00011390 END 00011400 1 THIS IS THE ONLY DATA CARD 00011410 $* 00011420 $$JOB PROGRAMLOOPS 10 00011430 BCS 15,$ SAME AS B * 00011440 END 00011450 $* 00011460 $$JOB BRANCHTOBADOPCODE 5 00011470 BCS 15,$+1 BRANCH TO NEXT STMT 00011480 RES W'0' NOT A LEGAL OPCODE 00011490 END 00011500 $* 00011510 $$JOB ADDRESSOUTSIDE 5 00011520 LI 1,100000 BIG NUMBER 00011530 SW 0,$(1) TOO BIG - ADDRESSING ERROR 00011540 END 00011550 $* 00011560 $$JOB ADDRESSINGTEST 20 00011570 LI 1,1 FOR INDEXING 00011580 LI 2,-1 FOR INDEXING 00011590 LW 8,X(1) LOAD AN 8 INTO R8 00011600 LW 7,X(2) LOAD A 7 INTO R7 00011610 LW 6,*X LOAD A 6 INTO R6 00011620 LW 5,*X(1) LOAD A 5 INTO R5 00011630 LI 3,512 ANOTHER INDEX VALUE 00011640 AWM 1,*Y(2) BOMB OUT OF RANGE 00011650 WAIT 0,0 NEVER REACH HERE 00011660 * 00011670 RES W'7' 00011680 X WAIT 0,X6 FOR INDIRECT ADDRESSING 00011690 RES W'8' 00011700 X6 RES W'6' 00011710 RES W'5' 00011720 Y RES W'10000000' BIG 00011730 END 00011740 $* 00011750 $$JOB COMPUTEXCUBED 100 00011760 RD 0,0 GET NUBMER IN 00011770 STW 0,X SAVE THE VALUE 00011780 LOOP MW 0,X MULITPLY 1 TIME 00011790 MTW 15,CNT DECREMENT CNT TO CNT-1 00011800 BCS 7,LOOP BRANCH IF NOT ZERO 00011810 WD 0,0 WRITE RESULT OUT 00011820 X RES 1 00011830 CNT RES W'2' 00011840 END 00011850 $* 00011860 ,>CS102M1 (TEXT) - MISC. WRITEUPS FOR 1ST ASM COURSE , 00001000 CS102M1 - 01 00001010 00001020 COMPUTER SCIENCE 102 - RUN ASSIGNMENT 00001030 00001040 1. Punch up the following program and run: 00001050 // YOUR JOB CARD 00001060 // EXEC ASACG 00001070 //SYSIN DD * 00001080 MAIN CSECT 00001090 * THIS PROGRAM ILLUSTRATES XDUMP AND PROGRAM INTERUPTION 00001100 BALR 12,0 THESE TWO STMTS ARE FOR 00001110 USING *,12 COMMON LINKAGE CONVENTIONS 00001120 LA 3,CARD PTR TO CARD IMAGE READ IN 00001130 XREAD CARD,80 READ DATA CARD 00001140 XPRNT CARD,80 ECHO PRINT 00001150 XDECI 4,0(3) CONVERT DECIMAL TO INTERNAL HEX 00001160 XDECI 5,0(1) CONVERT NEXT # ON CARD 00001170 * THE NEXT STMT PRINTS CONTENTS OF USERS REGISTERS. 00001180 * NOTE REG 4,5 00001190 XDUMP 00001200 B 4000 ABEND-BRANCH OUT OF PROGRAM 00001210 CARD DS 80C 00001220 END 00001230 /* 00001240 //DATA.INPUT DD * 00001250 100 -1024 00001260 /* 00001270 00001280 00001290 00001300 2. This next program is a batch run of 5 jobs, each terminating 00001310 abnormally. The program is stored on RJE file. Punch up the 00001320 follwoing cards EXACTLY to run the program 00001330 // YOUR JOB CARD 00001340 // EXEC ASACG,PARM=BATCH 00001350 //SYSIN DD * 00001360 /*INCLUDE RAB01.BATCH 00001370 /* 00001380 00001390 3. To merely get a listing of the prog in 2., use the following cards: 00001400 // YOUR JOB CARD 00001410 /*INCLUDE RAB01.PRINT 00001420 /*INCLUDE RAB01.BATCH 00001430 /* 00001440 , CS102M1 - 02 A GUIDE TO S/360 MNEMONIC OPERATION CODES I. INTRODUCTION The beginning programmer facing the variety of operations available on a modern large computer is often overwhelmed by the large number of operations and complexity thereof. In some cases, a few hints can be helpful in learning and remembering the names, purposes, and usage of the various operations. In particular, certain properties of S/360 menemonics can help the learner a great deal. Some of them are: A. REGULAR SCHEME FOR NAMING OPCODES In general, a fairly coherent and regular method has been used in naming operations. In some cases, it is possible to determine the bit pattern and operation of a mnemonic just from looking at it. Related operations usually have related mnemonics. B. COMMONLY USED MNEMONICS The designers apparently went to some effort to make the most often used mnemonics the shortest and easiest to remember. Most of these have 1 or 2 letter mnemonics. II. NAMING OF MNEMONIC OPCODES A. VERB (MODIFIER) (DATA TYPE) (MACHINE FORMAT) The mnemonics generally follow the format given above, with the VERB always present, while the others may be omitted. The general meanings of the fields are given below. 1. VERB: specifies a general type of action performed, such as addition, subtraction, comparison, data movement. 2. MODIFIER: specifies a modification of the general action given by the verb, such as logical addition (rather than algebraic), moving multiple registers rather than single ones, and performing different actions while loading one register into another. 3. DATA TYPE: specifies the type of data being operated on, and is usually the same letter as that used to define a constant of the given type, such as H (halfword), P (packed decimal), etc. 4. MACHINE FORMAT: gives the type of machine instruction being used. This is most typically done by adding R or I to an RX mnemonic to obtain a similiar RR or SI instruction. In general, the RX instructions, which are the heaviest used, have the shortest mnemonics, and most of the other instructions can be built from them by adding more letters. , CS102M1 - 03 B. EXAMPLES OF COMMONLY USED MNEMONIC ELEMENTS The following sections explain the common mnemonic elements. 1. VERBS VERB MEANING, COMMENTS ---- -------------------------------------------------------------- A Add two numbers (which may be binary, decimal, or floating) B Branch to another instruction (like GOTO) C Compare two fields (numbers or character strings) CV ConVert a number from one base to another D Divide one number by another L Load a quantity into a register from another or from storage M Multiply one number by another MV MoVe information from one area in storage to another. N aNd information together (logical AND) O Or information together (logical OR) S Subtract one number from another ST STore a register (or part of one) into storage X eXclusive or information together (logical exclusive OR) For example, note that a given VERB may begin many instructions, which immediately shows they are related to each other. For example, the following are all comparison operations: C, CD, CE, CH, CL, CP, CR, CDR, CER, CLC, CLR. 2. MODIFIERS The following lists verbs and their common modifiers. VERBS MODIFIERS MEANING, EXAMPLES -------- -------- ---------------------------------------------------- A,C,S L Logical addition, comparison, or subtract is used rather than algebraic. EX: AL, CL, CLC, SLR. B AL And Link - form of branch for doing linkage to subroutine so it can return. EX: BAL, BALR C Condition - branch or not depending on a previously set condtion (IF(--) GOTO --). EX: BC, BCR. CT Count - branch form used to decrement a register and branch if value not zero (DO LOOP). EX: BCT, BCTR. X indeX - branch form for incrementing and testing index quantities. (DO LOOP). EX: BXH, BXLE. L C Complement - used to set a register to complement itself or other (Y = -ABS(X)). EX: LNR, LNDR. P Positive - set register to positive value from self or other (Y = ABS(X)). EX: LPR, LPER. T Test - set register to value from self or other, L,ST M Multiple - several registers are loaded or stored in one operation. EX: LM, STM , CS102M1 - 04 3. DATA TYPES As noted previously, a data type character is usually the same as that used in a DC or DS statement to obtain a given type of data. If a type character is omitted, it usually implies that the instruction operates on 32-bit, fullword, binary quantities (such as A, C, S, etc). DATA TYPE MEANING, COMMENTS -------- --------------------------------------------------------- C Character - usually a contiguous string of bytes in memory, treated as printable characters or a string of bits. (FORTRAN LOGICAL*1). EX: MVC, CLC, OC, IC, STC. USUALLY IMPLIES SS INSTRUCTION FORMAT (all except IC, STC). D Double precision floating point (Doubleword, 64 bit) (FORTRAN REAL*8). EX: AD, SD, LTDR, LD. IMPLIES RR OR RX INSTRUCTION FORMAT. E Exponent - single precision floating point (fullword, 32 bit, FORTRAN REAL*4). EX: AE, LER, ME. IMPLIES RR OR RX INSTRUCTION FORMAT. H Halfword - 16 bit binary number (FORTRAN INTEGER*2) EX: AH, MH, STH, CH. IMPLIES RX FORMAT. P Packed decimal format (2 decimal digits per byte). EX: AP, SP, CP. IMPLIES SS INSTRUCTION FORMAT OF TWO-LENGTH TYPE. 4. MACHINE FORMATS Several characters are used to denote the specific type of operand format being used (note that the data types can also imply specific formats. If they imply one of several, the last character distinguishes among them). FORMAT MEANING, EXAMPLES -------- ---------------------------------------.---------------------- I Immediate - IMPLIES SI FORMAT. EX: MVI, CLI, OI. R Register - IMPLIES RR FORMAT. EX: AR, BCR, DDR. , CS102M1 - 05 III. EXAMPLE OF FAMILY OF RELATED OPCODES This section lists all the members of the 'Compare' family of menemonics, showing their relationships adn the elements present in each name. The letters V M D F stand for Verb, Modifier, Data type, and machine Format. OP-CODE V M D F TYPE COMMENTS ---- - - - - -- ----------------------------------------------- C C RX fullword algebraic compare, the basic one. CL C L RX fullword logical comparison (logical modifier) CD C D RX compare double precision floating numbers CE C E RX compare single precision floating numbers CH C H RX compare a register algebraicly with halfword from storage (with sign extension) CP C P SS compare two packed decimal numbers CR C R RR compare two fullword values algebriacly, gotten from C by adding R. CLC C L C SS compare logically character strings CLI C L I SI compare logical immediate (a byte in memory with the one inside the instruction) CDR C D R RR compare double precision (in registers) CER C E R RR compare single precision (in registers) The Sytem/370 computers have some additional opocdes: CLM C L M RS compare logical masked (from register to mem) CLCL C L C L RR compare logical character strings long (up to 16 million bytes in one compare) Consider the problem of writing a FORTRAN program which would simulate the operation of the instructions above (i.e., maintain variables representing PSW, Memory, GP Registers, etc, and go through the Fetch-Instruction, Decode, Fetch-Operands, Execute cycle). The arrangement of the opcodes would make it easy to share code, i.e., it would not be necessary to code each instruction separately. As an example, consider the following related instructions: MNEMONIC HEX CODE BINARY CODE SAMPLE INSTRUCTION/ASSEMBLED -------- -- -------- ------------------------------------- CR 19 0001 1001 CR 0,1 1901 CH 49 1000 1001 CH 0,2(3,4) 49034002 C 59 1001 1001 C 0,4(5,6) 59056004 Examine the bit patterns above. The first teo bits give the Machine Format (00-RR, 10-RX), the third and fourth give a Data Type (01-Fullword,00-Halfword in this case). The fifth-eighth bits give the Verb (1001 - algebraic Compare). In essence, there is only 1 Compare, which is branched to after the operands are obtained. ,>CS102TPA (TEXT) - DAY-BY-DAY OUTLINE OF 1ST ASSEMBLER COURSE , 00001000 CS102TPA - 01 00001010 00001020 COMPUTER SCIENCE 102 - TOPICS COVERED, HANDOUTS 00001030 WINTER TERM 1972 - MASHEY 00001040 00001050 The handouts given are described in file CS102HN. 00001060 00001070 # DATE TOPICS, HANDOUTS, READING ASSIGNMENTS 00001080 -- --/--/72 ---------------------------------------------------------00001090 00001100 1 01/07 introduction to course. prerequistites (101, 401, equiv)00001110 listed text materials for course: 00001120 1) STRUBLE: ASSEMBLER LANGUAGE PROGRAMMING: IBM SYSTEM/360 00001130 2) IBM: SYSTEM/360 PRINCIPLES OF OPERATION (POP) 00001140 3) IBM: S/360 OS ASSEMBLER LANGUAGE 00001150 4) PSU: ASSIST INTRODUCTORY ASSEMBLER USER'S MANUAL 00001160 (25 cents, at 426 McAllister) 00001170 5) IBM: S/360 REFERENCE CARD (GREEN CARD- BRING TO CLASS) 00001180 00001190 introduction to information representation in computer. 00001200 memory, addressing, similiarity to FORTRAN vector wit1 index 00001210 beginning at 0 rather than 1. elements of memory in S/360: 00001220 byte, halfword, fullword, doubleword. 00001230 positional notation. number systems (binary, octal, decimal, 00001240 hexadecimal). conversion between them, uses. 00001250 representations of binary numbers: Two's complement, One's 00001260 complement, Sign-magnitude. advantages and disadvantages: 00001270 (TC - 1 zero, but harder for people; OC - 2 zeroes, but easier00001280 to handle; SM - easiest to handle, but slower circuitry) 00001290 00001300 READING: STRUBLE CHAPTER 1. Look at ASSIST PART III. 00001310 00001320 00001330 2 01/10 more on information representation; introduction to 00001340 machine structure. 00001350 00001360 meanings of bit patterns: 1,2,4-byte binary numbers; charcters00001370 packed decimal (good for people, but wastes space); floating 00001380 point (sign, characterisitc, and fraction). 00001390 00001400 structure of a very simple machine: memory of 16-bit words; 00001410 1 register; 1 program coiunter. a few instructions, each with00001420 opcode and address. explanation of basic instruction cycle: 00001430 1) Fetch instruction from where program counter points. 00001440 2) Increment program counter. 00001450 3) Decode instruction into its parts. 00001460 4) Execute instruction. 00001470 5) Loop back to 1. 00001480 00001490 S/360 machine structure: memory (note abbrev. K), GP and 00001500 floating point registers, PSW. refer to GREEN CARD. 00001510 00001520 Begin instruction types: 00001530 1) RR (names with -R, examples) 00001540 2) RX (give first explanation of base-displacement) 00001550 3) RS 00001560 00001570 READINGS: STRUBLE - CHAPTER 2; POP - pp. 7-15. 00001580 HANDOUTS: CS102M1 - page 01 (run some ASSIST programs for dumps) 00001590 , 00002000 CS102TPA - 02 00002010 00002020 3 01/12 finish operands formats and introduce assembly language. 00002030 00002040 4) SI instructions (examples: MVI, CLI) 00002050 5) SS instructions (examples: MVC, CLC) 00002060 machine language - easy for machine to execute, hard to write 00002070 assembly language converted by assembler to machine code. 00002080 00002090 format of assembly language: label opcode operand comments 00002100 machine instructions - actual operations to be executed 00002110 assembler instructions (pseudo ops) - give information to 00002120 the assembler (ex: CSECT, DS, DC) 00002130 some basic functions of the assembler: 00002140 1) location counter 00002150 2) convert mnemonic opcodes 00002160 a) machine ops - translate to codes, increm location cntr00002170 b) assembler ops - take actions specified, increm loc cnt00002180 3) operands - convert to internal binary, base-displacement 00002190 4) print out a listing 00002200 5) make program ready for execution and pass control to it 00002210 00002220 stepped through complete test program (XREAD, XPRNT, XDECI, 00002230 XDUMP) and explained listing and contents of dump. 00002240 00002250 READINGS: STRUBLE: Chapter 3; ASSIST MANUAL: PARTS II and IV; 00002260 ASSEMBLER LANGUAGE: pp. 1-18. 00002270 HANDOUTS: DOCUMENT (documentation techniques for assembler) 00002280 00002290 4 01/14 go over some dumps and errors; discuss operand fields. 00002300 00002310 go through various dumps, showing 0C1, 0C4, and 0C6 errors. 00002320 cover STRUBLE cahpter 3, pp.50-56: symbols, self-defining 00002330 terms, literals, location counter reference, absolute and 00002340 relocatable terms, expressions. 00002350 00002360 READINGS: STRUBLE: Chapter 4 to page 78. 00002370 ASSIGNMENT: STRUBLE: Chapter 1: problems 5,6,7,8,9. Chapter 2: 00002380 problems 2,3. Chapter 3: problems 1,2,3,4,6. 00002390 INFORMAL ASSN: modify dump program to use XDECO and DUMP storage; 00002400 use program with START to check relocatable vs absolutes. 00002410 modify one of batch programs to get 0C6 rather than 0C4. 00002420 00002430 5 01/17 introduction to arithmetic and data movement instructions00002440 introduce idea of instruction families and regularity of 00002450 mnemonics. Go thru following instructions: LR, LPR, LCR, LNR,00002460 LTR, L, LH, LA. AR, ALR, A, AL, AH, SR, SLR, S, SL, SH. 00002470 mention M and D, also briefly note existence of Condition Code00002480 and show how to test it, without worrying about encoding. 00002490 20-minute question answer and review: questions occurred on 00002500 differences between literals and self-defining terms, and on 00002510 use of symbolic register equates. 00002520 00002530 READINGS: STRUBLE: Chapter 5. 00002540 HANDOUTS: CS102AS1 (pages 01 - 02) first assignment - input, 00002550 output of numbers, calculations in binary. 00002560 CS102M1 (pages 02 - 05) S/360 mnemonic construction. 00002570 , 00003000 CS102TPA - 03 00003010 00003020 6 01/19 quiz and finish up data movement and binary arithemetic. 00003030 Twenty-minute quiz (diagnostic mainly): base conversions (2, 00003040 8, 10, 16); negative numbers, base-index-displacement addrs, 00003050 relocatable vs absolute. 00003060 Instructions: LM, STM, MVC, MVI. M, MR, D, DR, MH and hints 00003070 on what to watch for. 00003080 Programming techniques: review input/output & conversions 00003090 (XREAD, XPRNT, XDECI, XDECO); method for building messages 00003100 and obtaining length for XPRNT via MSGL EQU *-MSG . 00003110 00003120 ASSIGNMENT: indexing and comparison assignment, CS102AS1 - 03, 00003130 due 02/02/72. 00003140 HANDOUTS: CS102AS1 - 03 (labeled CS 102 AS2 also) - indexing. 00003150 READINGS: STRUBLE CHAPTER 5, start on STRUBLE CHAPTER 7. 00003160 00003170 7 01/21 condition code, branching instructions, loops. 00003180 condition code values and encoding. BCR, BC, Extended 00003190 Mnemonics (recommended for use over BC #). BALR, BAL and 00003200 subroutines, BCT, BCTR usage, including decrementing regs. 00003210 example of basic loop to sum array of numbers. 00003220 flowcharting and good design versus kludge programming. 00003230 00003240 READINGS: STRUBLE Chapters 7,8,5. 00003250 00003260 8 01/24 finish loop control, begin on USING/DROP, linkage 00003270 Explain BXH, BXLE instructions, give typical setups: 00003280 forward BXLE loop, backwards BXH loop, BXH scan loop. 00003290 show need for USING command. give rules for computation of 00003300 base displacements: minimum base displacement for those which00003310 are available, higher numberred register if several have same.00003320 begin conventions: exaplin registers 15, 14 usage on entry. 00003330 00003340 HANDOUTS: LINKAGE OS/360 linkage conventions 00003350 READINGS: STRUBLE: Chapter 5, LINKAGE HANDOUT 00003360 00003370 9 01/26 savearea linkage ans ome review. 00003380 Describe 18-fullword save area. go through the standard code 00003390 used at beginning and end of a routine, calling methods. Do 00003400 not work on argument passing, just normal code. 00003410 Misc. instructions: IC, STC, start on Shifts. 00003420 Various review for problems. 00003430 Note general usage of registers: get students into good habits00003440 00003450 READINGS: STRUBLE: Chapter 11. 00003460 00003470 10 01/28 logical/algebraic arithmetic, shifts 00003480 20-minute quiz on previous instructions. 00003490 differences between condition code setting, aroverflow in 00003500 algebraic arithmetic and logical arithmetic. examples. 00003510 shift instructions and how they are used. 00003520 READINGS: STRUBLE: Chapter 11, begin on chapter 10. 00003530 , 00004000 CS102TPA - 04 00004010 00004020 11 01/31 bit manipulation and uses. review on branching 00004030 bit manipulation instructions: NR, XR, OR, N, X, O, NI, XI, 00004040 OI, NC, XC, OC, plus TM. what they do, and how to use them. 00004050 EQU trick for SI instructions and how to use it. 00004060 review: prototypes on loop control, advantages/disadvantages.00004070 00004080 READINGS: STRUBLE: Chapter 10, first 3 sections. 00004090 00004100 12 02/02 assembler housekeeping, misc areas. 00004110 go over all of DC, DS operand formats in detail, showing 00004120 what can exist as duplication factor-type-length-constant, 00004130 including multiple operands and constants, expressions as 00004140 duplication factors and length modifiers. also cover 00004150 TITLE, EJECT, SPACE 00004160 00004170 READINGS: STRUBLE: CHAPTER 6, pp 110-121, problems 7,9,10 00004180 ASM LANG: 3, 7-9, 10-18 (except variable symbols/sequence 00004190 symbols, 19-21, 29-33. section 5: EQU, DC (all except Bit 00004200 Length Modifier, Scale Modifier, Exponent Modifier. all types 00004210 except E, D, L, P, Z,Y, S, Q, complex relocatability). DS, 00004220 ORG, LTORG, END. SPACE, EJECT, TITLE 00004230 POP: pp 24-34 except CVB, CVD. Logical instructions except 00004240 TR, TRT, ED, EDMK. Branching except EX. 00004250 00004260 13 02/04 give out final project, discuss assembler/interpreters 00004270 concepts of assemblers: 2 pass assemblers, how to set up 00004280 opcode and symbol tables (indexed jump methods), output 00004290 desired. 00004300 go over structure of SIGMA 4.5 computer and its interpreter, 00004310 noting indirect addressing in particular. 00004320 00004330 HANDOUTS: CS102FP1 (01 -08) general assembler/interpreter descr 00004340 CS102FP2 (01 -06) specific material for final project 00004350 00004360 ASSIGN: Final project, due 13 March (described in CS102FPx) 00004370 00004380 14 02/07 decimal numbers and conversions 00004390 zoned/packed decimal to and from binary. PACK, UNPK, CVB, CVD00004400 equivalent codes using M, D loops for decimal-binary-decimal. 00004410 examples of various formats/conversions. 00004420 00004430 READINGS: STRUBLE: Chapter 5: 106-110, Chapter 218-228, 228-233.00004440 00004450 15 02/09 misc review, misc instructions, program mask. 00004460 SPM instruction, use of program mask, review BXLE, BXH, etc. 00004470 00004480 00004490 16 02/11 MIDTERM 00004500 covered data representations, most standard instructions, 00004510 hand assembly, etc. 00004520 , 00005000 CS102TPA - 05 00005010 00005020 17 02/14 on midterm and final project 00005030 review of midterm results and problem areas. final project: 00005040 overall structure, useful modules and how to set them up: 00005050 decimal scan and output conversions, symbol scan, symbol table00005060 manager, opcode lookup, hexadecimal output, etc. 00005070 review of BXLE loop control. 00005080 HANDOUT: CS102PX1 (01 - 03) programming exercises: hand assembly, 00005090 interrupts. 00005100 00005110 18 02/16 more on assembly process, location counter control. 00005120 use of ORG to set up tables, timetable for gettting final 00005130 project done, program design process and debugging. 00005140 00005150 19 02/18 quiz, TR, TRT 00005160 30-minute quiz: hand assembly, BXLE loop setup. 00005170 TR uses, setup, workings. 00005180 TRT uses, setup, examples. 00005190 00005200 READINGS: STRUBLE CH 15: pp 342-345, 350-352. prob 1,3,4. 00005210 ASSIGN: write TRT table for scanning over hex digits. 00005220 20 02/21 programming techniques, use of TR, TRT, conversions use of global table pointer, examples on TR, TRT. decimal input conversion, using two TRT's, EX, PACK, CVB. hexadecimal output conversion, using UNPK, TR. ASSIGN: write code to perform conversions, also to read in names, place in table, then search table for later names. READINGS: STRUBLE CH 15: ED, EDMK start. 21 02/23 conversions - hexadecimal input, decimal output, ED go through hexadecimal input, but not in detail (TRT, TRT, EX of MVC right-justified, TR, PACK 9 into 5, ignoring extra byte) decimal output: CVD, UNPK, OI for plus number, with leading zeroes. decimal output: begin on ED, EDMK, doing parts with basic workings of ED, and standard pattern for integer numbers. ,>CS411AS1 (TEXT) - 2ND ASSEMBLER COURSE, 1ST ASSIGNMENT: , CS411AS1 - 01 CMPSC 411 - ASSIGNMENT 1 LINKAGE HANDLING, FORTRAN/ASSEMBLER AND OBJECT DECKS DUE ______________ This writeup: pages 01 - 02. I. MAXIM FUNCTION SUBPROGRAM Write a function in assembler language, consisting of 1 CSECT named MAXIM, which accomplishes the following: A. Follows standard OS/360 calling conventions, receiving the address of an argument list in register 1. There may be a variable number of arguments in the list. Each address in the argument list points to a fullword somewhere in storage. B. The program should algebraicly compare the fullwords addressed by the argument list, and place the value of the maximum one in register 0 as a result, then return control to the caller. C. In writing this program, DO NOT USE XSAVE OR XRETURN macros. II. WRITE FORTRAN TEST PROGRAM TO TEST MAXIM This program should test MAXIM by using it as a function, i.e., it will have statements of the form I = MAXIM(1,2,-5,-10,4,5) in it. It should have at least two tests of this form. Print out the results to show they are correct. Use the above set of data plus another of you own choosing. III. WRITE ASSEMBLER MAIN PROGRAM TO TEST MAXIM Write an assembler main program which has the same logic and test values as does the previous FORTRAN program. It should use standard OS/360 linkage, its own save area (of course), and utilize the IBM macros SAVE and RETURN. It should do the following: A. As given by the LINKAGE writeup, obtain the PARM field (see if any exists by testing for zero length). Either print the PARM field, or the message NO PARM EXISTS. Assume first character of PARM is a legitamate carriage control. B. Make same two calls on MAXIM. The first must be hand coded (no macros), while the second uses the IBM macro CALL. IV. JOB CONTROL LANGUAGE Do not punch an object deck until you are sure the MAXIM program is correct. While testing, you can use the following JCL: // EXEC ASGC //SOURCE.INPUT DD * ..... MAXIM program..... // EXEC FGCG,PARM.DATA=MAP //SOURCE.INPUT DD * ..... main program ..... should do a CALL LETDMP before using MAXIM //DATA.SYSUDUMP DD SYSOUT=A (may need XSNAPOUT card following also) , CS411AS1 - 02 An alternate form of the preceding is to use: // EXEC FGC //SOURCE.INPUT DD * ..... FORTRAN main program // EXEC ASGCG,PARM.DATA='MAP' //SOURCE.INPUT DD * ..... MAXIM //DATA.SYSUDUMP DD SYSOUT=A When testing MAXIM with the assembler program, you may either run it and MAXIM as one assembly (1 ASGCG), or as two (1 ASGC and 1 ASGCG). V. WHAT TO HAND IN A. Run a job which produces the object deck for MAXIM, and also does the test using the assembler main program (note that the END card in the second assembly should specify the name of the main program on it so that execution will start there.) Use the following deck setup: // EXEC ASGC,PARM=DECK //SOURCE.INPUT DD * ..... MAXIM // EXEC ASGCG,PARM.DATA='MAP/0I AM A PARM FIELD' //SOURCE.INPUT DD * ..... main program *** sysudump and xsnapout cards, if needed B. Using the object deck produced by the previous program, run this test of MAXIM with FORTRAN: // EXEC FGCG,PARM.DATA='MAP' //SOURCE.INPUT DD * ..... FORTRAN main program //DATA.DECK DD * ..... object deck from MAXIM *** sysudump and xsnapout cards as needed. VI. THOUGHT QUESTIONS A. Suppose that you also wrote MAXIM as a FORTRAN function. What would you do to obtain an object deck of it and use it as a subprogram of your assembler test program? B. Does MAXIM need to have its own save area? If so, why? If not, why not? C. How does the object deck of MAXIM compare with its source deck? Does the answer tell you why people use object decks? D. What reasons can you think of for using a mixture of FORTRAN programs an assembler programs? What does FORTRAN do well that assembler does not, and vice-versa? ,>CS411GI1 (TEXT) - GENERAL INFORMATION, COURSE OUTLINE, , 00001000 CS411GI1 - 01 00001010 01/09/73: date of last revision 00001020 00001030 COMPUTER SCIENCE 411 - GENERAL INFORMATION 00001040 00001050 This writeup provides general information regarding CMPSC 411 - 00001060 SYSTEMS ORGANIZATION AND PROGRAMMING, as currently taught at PSU. It 00001070 notes the prerequisites, text materials, handouts, assignments, and 00001080 generally describes what is taught in this course, and what is expected 00001090 of the students taking it. 00001100 00001110 INDEX 00001120 I. PREREQUISITES .................................... 1 - 01 00001130 II. TEXTBOOKS AND MANUALS ........................... 1 - 02 00001140 III. WRITEUPS ......................................... 1 - 05 00001150 IV. BAT FILES ........................................ 1 - 08 00001160 V. ASSIGNMENTS/DUE DATES ............................ 1 - 10 00001170 VI. COURSE OUTLINE/READINGS .......................... 00001180 VII. MISCELLANEOUS INFORMATION ........................ 00001190 00001200 00001210 I. PREREQUISITES 00001220 A. CMPSC 102 (or 410) or equivalent: effectively, a fairly complete 00001230 introduction to much of System/360 computer structure and assembler 00001240 language programming. The following should have been covered: 00001250 00001260 S/360 structure: registers, PSW, memory organization, common 00001270 interrrupts, two's complement arithmetic. Programming experience with 00001280 most of standard instruction set, possibly some with decimal opcodes 00001290 and conversions. Privileged operations are not expected to be well- 00001300 known, and floating point operations will not be used in the course. 00001310 00001320 S/360 Assembler Language: familiarity with most of the things 00001330 covered in the first half of the OS Assembler Language manual (sections 00001340 1-5). Most of the following terms or operations should be familiar: 00001350 self-defining terms, location counter, literals, absolute versus 00001360 relocatable expressions; USING, DROP, START, CSECT, ENTRY; various 00001370 instruction formats; EQU, DC, DS, TITLE, EJECT, SPACE, PRINT, ORG, 00001380 LTORG, CNOP, END. Some students may have done something with DSECTs, 00001390 MACROs, and linkage of FORTRAN and Assembler modules, but this is not 00001400 necessarily required. It is expected that most incoming students have 00001410 done most of their programming under ASSIST, and are thus not yet 00001420 proficient in debugging programs and reading completion dumps under 00001430 OS/360 directly. Students are expected to have written at least half 00001440 a dozen or more programs in Assembler, including typically a small 00001450 two-pass assembler for a simple assembly language. 00001460 00001470 B. CMPSC 404 or equivalent: data structures: arrays, linked lists; 00001480 tree structures, queues, stacks; perhaps a little on searching and 00001490 sorting methods: hash tables, etc. 00001500 00001510 Anyone who has taken equivalent courses elsewhere or wishes to 00001520 substitute other programming experience for the above should contact the00001530 instructor immediately, to make sure their background is adequate for 00001540 the course. 00001550 , 00002000 CS411GI1 - 02 00002010 00002020 II. TEXTBOOKS AND MANUALS 00002030 00002040 The text materials for the course are listed below. Many of the 00002050 text items are IBM manuals, which are often in a continual state of 00002060 change. Particularly, each time IBM offers an updated version of 00002070 OS/360, many manuals are modified somewhat. It is generally desirable 00002080 to have the manuals appropriate for the current version of OS/360 00002090 (which is Release ___ at this time). However, this is not necessary, 00002100 as there are often only minor changes between one version of a manual 00002110 and the next. In addition, there are combinations of differently-named00002120 manuals which are equivalent to others. In the list below, the most 00002130 desirable manuals are given, but equivalents are noted where possible. 00002140 00002150 Items coded R are definitely required, items coded D are desirable,00002160 while the remaining ones are useful, but can be done without, and may 00002170 not even be available. Abbreviations to be used later are given in 00002180 in brackets for each one. NOTE: for IBM manuals, first six digits show 00002190 the specific manual, while the remaining one(s) indicate the version. 00002200 Normally, (but not always), manuals having close version numbers are 00002210 not very different. 00002220 00002230 D 1. STRUBLE:ASSEMBLER LANGUAGE PROGRAMMING: THE SYSTEM 36000002240 This text will be referenced at most occasionally, but contains 00002250 some more readable explanations than some of the manuals below. It is 00002260 also good for review of CMPSC 102(410). 00002270 00002280 R 2. GC28-6514-8 IBM S/360 OS ASSEMBLER LANGUAGE 00002290 This is heavily used throughout the course. By the 5th week of 00002300 term, students will be expected to understand almost everything in this 00002310 manual, while knowing offhand much of it. Besides the few sections in 00002320 the first half not already known to the students, the entire second 00002330 half (MACROs) will be covered. 00002340 00002350 R 3. GC28-6821-8 IBM S/360 PRINCIPLES OF OPERATION 00002360 This also will be used heavily. The students should be familiar 00002370 with much of the material, but it may be needed for review of some 00002380 operations (such as TR, TRT, ED, EDMK). It will also be needed for the 00002390 following topics: system structure: protection features, I/O; status 00002400 switching: program states, protection, PSW, instructions; 00002410 interruptions: all in this section; input/output operations: most of 00002420 this material: CAW, CSW, CCW, basic operation of channels. 00002430 00002440 R 4. GC28-6534-3 IBM S/360 OS INTRODUCTION 00002450 OR 00002460 R GC28-6535-7 IBM S/360 OS CONCEPTS AND FACILITIES 00002470 These manuals (INTRO is effectively a reworking of the older 00002480 C&F), give an overall view of operating system services, using OS/360 00002490 terms in particular.They do not explain things in detail, but give 00002500 general concepts and vocabulary. The student must be familiar with most00002510 of the concepts and terms in these manuals by the end of the course. 00002520 , 00003000 CS411GI1 - 03 00003010 00003020 The following group of manuals is continually changed around by 00003030 IBM, with various parts shuffled among manuals of same or changing names00003040 or numbers. There are effectively 4 distinct modules of information: 00003050 a) Supervisor Services - description of general concepts. 00003060 b) Supervisor Macro Instructions - coding details for these macros. 00003070 c) Data Management Services - description of general concepts. 00003080 d) Data Management Macro Instructions - coding forms for these. 00003090 00003100 All 4 of the above modules are definitely necessary, but they are 00003110 combined in various ways, with any combination providing all parts 00003120 being generally acceptable, although the first combination is preferred.00003130 Each manual notes which information (a,b,c,d) it contains. Later 00003140 references may refer to (x), where x is a,b,c, or d. In such 00003150 cases, the information can be found in any of the manuals which have 00003160 that section of information. 00003170 00003180 R 5. XXXX-XXXX-X SUPERVISOR AND DATA MANAGEMENT SERVICES 00003190 AND MACRO INSTRUCTIONS 00003200 00003220 R GC28-6646-6 IBM S/360 OS SUPERVISOR SERVICES AND 00003230 MACRO INSTRUCTIONS 00003240 (a,b) This is recommended version, and contains the general 00003250 methods used for management of programs (including linkage conventions),00003260 tasks, and main storage allocation, with the macros for these. 00003270 00003280 R GC26-3746-1 OS DATA MANAGEMENT SERVICES GUIDE 00003290 (c) This is recommended form, and gives the general methods 00003300 and many examples of processing each of the different types of datasets 00003310 in different ways. Good explanatory material is given on various 00003320 characteristics of data sets (record formats, control characters, etc), 00003330 direct-access devices, magnetic tapes, and general procedures of data 00003340 management (OPEN, CLOSE, DCB, GET, PUT, READ, WRITE, etc). 00003350 00003360 R GC26-3794-0 OS DATA MANAGEMENT MACRO INSTRUCTIONS 00003370 (d) This is recommended form, and describes in detail the 00003380 various ways of coding the data management macros. The manual just 00003390 previous is read for understanding; this one is needed for actually 00003400 writing such programs. 00003410 00003420 00003430 R GC28-6646-5 S/360 OS SUPERVISOR SERVICES 00003440 (a) This is explanatory part of , older version. 00003450 00003460 R GC26-3746-1 S/360 OS DATA MANAGEMENT SERVICES 00003470 (c) This is explanatory part of , older version, and 00003480 not as well written as . 00003490 00003500 R GC28-6647-4 IBM S/360 OS SUPERVISOR AND DATA 00003510 MANAGEMENT MACRO INSTRUCTIONS 00003520 (b,d) Older version of material in and . 00003530 00003540 R GC28-6646-3 IBM S/360 OS SUPERVISOR AND DATA 00003550 MANAGEMENT SERVICES 00003560 (a,c) Older version: same as and put together. 00003570 , 00004000 CS411GI1 - 04 00004010 00004020 D 6. GC28-6538-9 IBM OS LINKAGE EDITOR AND LOADER 00004030 This describes how to use the named programs, and is particularly 00004040 useful and necessary for anyone writing overlay programs or concerned 00004050 with management of program libraries. The beginning contains fair 00004060 descriptions of object and load modules and their processing. 00004070 00004080 D 7. GC28-6704-2 IBM S/360 OS JOB CONTROL LANGUAGE 00004090 REFERENCE 00004100 This manual completely defines JCL, gives various coding forms and 00004110 examples of JCL usage. It is somewhat difficult to read as a text, but 00004120 is valuable as a reference. This manual is a rewritten version of the 00004130 combination of the two following manuals (which together contain much 00004140 redundant information). Therefore, any one of these three manuals are 00004150 acceptable, although this is the best. 00004160 00004170 OR 00004180 00004190 D GC28-6704-1 IBM S/360 OS JOB CONTROL LANGUAGE 00004200 REFERENCE 00004210 Although mostly like , this contains fewer examples. 00004220 00004230 OR 00004240 00004250 D GC28-6703- IBM S/360 OS JOB CONTROL LANGUAGE 00004260 USER'S GUIDE 00004270 This version leans more towards examples rather than a reference. 00004280 00004290 00004300 R 8. GX20-1703-9 IBM S/360 REFERENCE DATA 00004310 This is the GREEN CARD, and contains much useful information in 00004320 a compact form, including information on ED/EDMK patterns, contants, 00004330 assembler instructions, condition code setting, interrupt codes, 00004340 radix conversions, formats of PSW, CAW, CCW, CSW, permanent storage 00004350 assignments, most common CCW opcodes, instructions and EBCDIC bytes. 00004360 00004370 R 9. ASSIST INTRODUCTORY ASSEMBLER USER'S GUIDE 00004380 This describes usage of the ASSIST assembler. A slightly outdated 00004390 version (1.0) is available in the CMPSC office (426 McAllister), while 00004400 an updated version may be available on BAT files (ask instructor). 00004410 , 00005000 CS411GI1 - 05 00005010 00005020 III. WRITEUPS 00005030 00005040 This section provides an alphabetic list of various explanatory 00005050 writeups and assignment handouts which are available for use in CMPSC 00005060 411 or other courses. Some of these may be handed out, while others 00005070 can be accessed by anyone who is interested. Names, number of pages, 00005080 source, and description are given for each. 00005090 00005100 The following notations may appear for the SOURCE of each writeup: 00005110 00005120 BAT The writeup exists as as PSU CC BAT file, accessible from RJE or 00005130 batch terminals. An otherwise blank card with a comma in column 00005140 1 indicates the beginning of each page, including the first. Note 00005150 that these normally contain both upper and lower case letters. 00005160 00005170 DTO The writeup exists only as a dittoed handout. 00005180 00005190 TAP The writeup exists on a tape, in which case the tape name, file 00005200 number, and file name are given. 00005210 00005220 CRD The writeup is in a punched card deck. 00005230 00005240 MTS The writeup is on an MT/ST tape. 00005250 00005260 If the description of a BAT file begins with (userid), that is the 00005270 userid under which the file is saved. If not mentioned, the file is 00005280 saved under the following userid: 00005290 00005300 JRM02 00005310 00005320 Several utility programs are available for printing or punching 00005330 any BAT file(s). JRM02.PRINT prints any input, converting lower case 00005340 letters to upper case, while JRM02.PUNCH punches its input. Both will 00005350 run in any category, including category W. The deck setup is: 00005360 00005370 // JOB CARD 00005380 /*INCLUDE JRM02.PRINT substitute PUNCH if desired 00005390 @@INCLUDE userid.filename 1 or more cards like this 00005400 @@ to terminate input 00005410 00005420 The BAT files generally have about 50 lines per page, with a limit 00005430 of 500 lines in any one file. Some writeups consist of several BAT 00005440 files together, while other BAT files contain several distinct writeups.00005450 , 00006000 CS411GI1 - 06 00006010 00006020 NAME PAGES SOURCE DESCRIPTION 00006030 -------- -- --- ----------------------------------------------------00006040 00006050 ASBROPS2 3 BAT assignment using the ASSIST REplace Monitor: each 00006060 student replaces the base register table portion 00006070 of ASSIST: exercies in table search or linked list 00006080 manipulation; USING, DROP, address conversions. 00006090 00006100 ASPRGTC1 8 BAT gives S/360 Assembler programming hints: how to 00006110 use modules, macros, and combined forms; how to set 00006120 up safe, nondestructive linkage to a module. 00006130 00006140 ASREPLGD 11 BAT ASSIST REPLACEMENT USER'S GUIDE : describes in 00006150 general terms how to use the ASSIST Replace Monitor.00006160 00006170 CS411AS1 2 BAT assignment: linkage between FORTRAN and Assembler, 00006180 linkage conventions, argument passing, PARM field 00006190 access. 00006200 00006210 CS411GI1 10 BAT the writeup you are looking at. 00006220 CS411GI2 ## BAT 00006225 00006230 CS411MC1 8 BAT two assignments on macro-writing: pages 01-03 have 00006240 one to write own version of CALL, SAVE, RETURN 00006250 macros and test them; pages 04-08 have combined 00006260 macro/module writing: hexadecimal conversions and 00006270 dumping; various macro features illustrated. 00006280 00006290 CS411MC2 6 BAT assignment: write package of macros to manipulate 00006300 one-way linked lists. each macro is fairly easy. 00006310 00006320 CS411FP1 8 BAT assignment: write simulation of typical batch 00006330 CS411FP2 8 BAT multiprogramming computer system. Many possible 00006340 CS411GP3 8 BAT combinations of scheduling/allocation/resources are 00006350 CS411FP4 7 BAT available. Uses almost all features in BAL. 00006360 CS411FP5 6 DTO example flowcharts for this project. 00006370 00006380 DOCUMENT 4 BAT S/360 Assembler Language documentation hints and 00006390 good practices. 00006400 00006410 DSECT 3 BAT example of use of dsects to trace save areas, also 00006420 showing assembly listing of program. 00006430 00006440 DUMPSJCL 3 BAT gives basic Job Control Language cards for running 00006450 most typical assembler programs; gives several 00006460 useful hints on special JCL available at PSU; gives 00006470 programs to be run to obtain representative system 00006480 completion dumps. 00006490 , 00007000 CS411GI1 - 07 00007010 00007020 NAME PAGES SOURCE DESCRIPTION 00007030 -------- -- --- ----------------------------------------------------00007040 00007050 DUMP1 8 DTO debugging and dump-reading hints for assembler 00007060 DUMP2 7 DTO programmers; concentrates more on use with Link 00007070 Editor, but has some material with Loader. Gives 00007080 examples of hunting down causes of errors. 00007090 (should be upgraded and rewritten) 00007095 00007100 HARDWAR1 5 BAT describes most devices currently part of PSU CC 00007110 360/67 system; gives device addresses, speeds, 00007120 capacities; channel priorities. Page 5 is only 00007130 DTO, and it contains diagram of 360/67 layout. 00007140 00007150 LINKAGE 5 BAT explanation of OS/360 standard linkage conventions 00007160 used by FORTRAN, Assembler, etc programs for entry, 00007170 exit, argument passing. 00007180 00007190 OSHASP 9 BAT OS/360 with HASP: explains how OS/360 is loaded 00007200 into memory (IPL-NIP), how it runs, and how it is 00007210 modified by the use of HASP. 00007220 00007230 XDUMP 5 BAT describes use of XDUMP and XSNAP debugging 00007240 macros (XDUMP is simple form used in ASSIST, 00007250 XSNAP is more complex). (JRM04.XDUMP) 00007260 00007262 XGET 2 BAT describes use of generalized XGET/XPUT I/O macros 00007264 00007266 00007270 XHEXI 3 BAT describes use of XHEXI & XHEXO hexadecimal 00007280 conversion macros (available in ASSIST). 00007290 (JRM04.XHEXI) 00007300 00007310 XREAD 3 BAT describes XREAD, XPRNT, XPNCH I/O macros. 00007320 available in ASSIST. (JRM04.XREAD) 00007330 00007340 XSAVE 7 BAT describes XSAVE and XRETURN linkage macros. 00007350 available in ASSIST only if using the macro 00007360 library. (JRM04.XSAVE) 00007370 00007380 ------------------------------------------------------------------- 00007390 00007400 In addition to the above writeups, the students will normally 00007410 purchase a copy of the ASSIST Introductory Assembler User's Guide. 00007420 The very latest copy of this manual is available in the following 00007430 JRM04. BAT files: 00007440 ASSIST1 00007450 ASSIST1A 14 BAT Part I: describes language availabel in ASSIST 00007460 ASSIST2 8 BAT Part II: describes debug and I/O instructions. 00007470 ASSIST2A BAT 00007475 ASSIST3 00007480 ASSIST3A 9 BAT Part III: control cards, parameter options. 00007490 ASSIST4 00007500 ASSIST4A 17 BAT Part IV: output format, error messages, loader 00007510 , 00008000 CS411GI1 - 08 00008010 00008020 IV. BAT FILES 00008030 00008040 The following lists BAT files which are NOT text material, 00008050 i.e., sample programs, test data for some projects, etc. 00008060 00008070 NAME CARDS SOURCE DESCRIPTION 00008080 -------- -- --- ----------------------------------------------------00008090 00008100 $BRTEST 178 BAT test data for the ASSIST base-register module 00008110 replacement assignment (see assignment ASBROPS2) 00008120 00008130 ATTACH ??? BAT multi-tasking example: shows ATTACH, CHAP,DETACH,etc00008140 00008150 BDAM1,BDAM2 ? BAT run ot illustrate Basic Direct Access Method 00008160 00008170 BPAM 322 BAT an entire run, with JCL, to illustrate use of 00008180 BPAM macros for accessing pPartitioned Data Sets. 00008190 Reads selected macros from macro libraries and 00008200 prints them. Shows FIND, BLDL, READ, CHECK, etc. 00008210 00008220 BSAM 157 BAT entire run to illustrate BASM macros. shows 00008230 READ, WRITE, CHECK, etc. reads cards, writes on 00008240 disk, reads from disk, prints. 00008250 00008260 CS411FPJ 74 BAT test deck of $$JOB cards for Final Project (see 00008270 assignment CS411FP1,2,3,4,5) 00008280 00008290 CS411FPK 110 BAT same as CS411FPJ, but with different $$JOB cards. 00008300 00008310 DUMPTEST 84 BAT contains 4 runs, set up to produce dumps for 00008320 students to look at. (see DUMPSJCL writeup). note 00008330 that each run is preceded by BAT file comma card, 00008340 so that they may be extracted by listing with the 00008350 PAGE= option to find their starting sequence #'s. 00008360 00008370 EXCP 102 BAT contains complete run, set up to read cards and 00008380 print them using EXCP macro and CCW strings. 00008390 00008400 FLOTLINK 152 BAT contains a complete run, set up to show various 00008410 combinations of FORTRAN and assembler linkage. 00008420 illustrates most floating point instructions, by 00008430 computing a function in FORTRAN, then using some 00008440 equivalent assembler code. 00008450 00008460 GETMAIN ??? BAT program to illustrate use of GETMAIN/FREEMAIN 00008470 00008480 LINKLOAD ??? BAT program to illustrate load module management: 00008490 LINK, LOAD, XCTL, DELETE macros, etc. 00008500 , 00009000 CS411GI1 - 09 00009010 00009020 NAME CARDS SOURCE DESCRIPTION 00009030 -------- -- --- ----------------------------------------------------00009040 00009050 OVLY1 276 BAT OVERLAY example: complete run, uses link-editor to 00009060 edit a single object module several different ways, 00009070 showing the amount of storage which can be saved by 00009080 using overlay methods. includes multiple REGIONs. 00009090 00009100 PTPCHMAC 22 BAT uses the IBM utility program to print 3 macros 00009110 from SYS1.MACLIB. illustrates use of IEBPTPCH, 00009120 allows students to look at macros if they want to. 00009130 entire run setup. shows SAVE, RETURN, CALL. 00009140 00009150 QSAM 126 BAT Queued Sequential Access Method: reads from cards, 00009160 writes to disk blocked (illustrating use of DCB from00009170 JCL DD card), reads from disk, prints. shows 00009180 GET, PUT, OPEN, CLOSE, DCB. shows all sources of 00009190 information for DCB. 00009200 00009210 RECURASM ??? BAT illustrates recursive assembler program using 00009220 GETMAIN/FREEMAIN macros 00009230 00009240 SPIESTAE ??? BAT shows use of error-interception macros SPIE/STAE 00009250 00009260 TIME ??? BAT test program to show use of timing macros: 00009270 TIME, STIMER, TTIMER 00009280 00009290 WTOWTL ??? BAT test run to show use of WTO, WTL macros for 00009300 communicating with computer operator 00009310 , 00010000 CS411GI1 - 10 00010010 00010020 V. ASSIGNMENTS/ DUE DATES 00010030 00010040 The following lists the assignments given, approximate due date 00010050 of each (in terms of day number within the 30 class days per term), plus00010060 comments on each. 00010070 00010080 # DUE NAME/DESCRIPTION/COMMENTS 00010090 - -- ---------------------------------------------------------00010100 00010110 1 3 DUMPS - run dump programs as described by DUMPSJCL, 00010120 bring to class: familiarizes students with dump reading. 00010130 00010140 2 6 LINK - assignment CS411AS1 : gives students practice with00010150 linkage, including FORTRAN/aseembler linkage, dumps. gets00010160 them programming again quickly. 00010170 00010180 3 9 SAVE/RETURN - CS411MC1 (pages 01-03) - write own versions00010190 of extended SAVE, RETURN, CALL macros: starts students 00010200 on macros. 00010210 00010220 4 12 HEX: CS411MC1 (pages 04-08) - write hexadecimal 00010230 conversion macros & modules, like XHEXI, XHEXO. 00010240 covers macro/module linkage, TR, TRT, PACK, UNPK instrs. 00010250 00010260 5 15 BASEREG - ASSIST base register replacement - ASBROPS2, 00010270 $BRTEST, ASREPLGD . covers base registers well in short 00010280 program. helps with understanding of DSECTS. 00010290 00010300 6 18 LINKED-LIST: CS411MC2 - linked-list macro package - 00010310 more practice on macros, needed for final project. 00010320 00010330 7 27 FINAL PROJECT: CS411FP1,2,3,4,5, CS411FPJ, CS411FPK - 00010340 operating system simulation. 00010350 ,>CS411GI2 (TEXT) - GENERAL INFORMATION ETC, PART 2 OF 2. , 00001000 CS411GI2 - 01 00001010 00001020 VI. COURSE OUTLINE/READINGS 00001030 00001040 A. OVERALL OUTLINE 00001050 00001060 This section gives a very brief outline of lecture topics by day. 00001070 Several empty days are left for exams, problems, and possible expansion 00001080 of any of the topic areas. 00001090 00001100 DAY TOPICS 00001110 -- --------------------------------------------------------------00001120 1 Introduction to Course; Prerequisistes; Review X-Macros 00001130 2 OS/360 Linkage Conventions 00001140 3 Dump-reading; Debugging & good programming technqiues; Common 00001150 4 interrupts and interpretation of dumps. 00001160 5 Overall macro concepts & structure; FORTRAN analogies. 00001170 6 Details on macros; examples; most statement types. 00001180 7 Finish macros; Aspecial argument handling; character scanning.00001190 8 Miscellaneous cleanup on S/360 Assembler. (CNOP, V-cons ,etc) 00001200 9 Addressibility; DSECTS; Multiple USINGS; Useful techniques. 00001210 *** at this point, S/360 Assembler Language is finished *** 00001220 10 Assembler Comparison: 1,2,4 pass (SPASM, ASSIST, Assembler G) 00001230 11 Introduction to operating systems: history, basic types. 00001240 12 Architecture summary: CPU, Memory, Devices, Channels; Memory 00001250 13 structure and communication; memory protection. 00001260 14 I/O devices: sequential, DASD, capacities, characteristics. 00001270 15 Finish I/O devices; I/O Channels: types and programming; S/36000001280 16 Channel-level programming; Interrupt handling; show examples. 00001290 17 Final Project: explain simulation concepts; system overview. 00001300 18 Module management; types of modules (REENTRANT, etc); loader; 00001310 19 Link-editor; Program Fetch; Overlays. 00001320 20 User overview of OS/360 services. 00001330 21 I/O concepts: buffering, record formats, blocking, etc. 00001340 22 Survey of common OS/360 macros (except data management) 00001350 23 JCL 00001360 24 JCL 00001370 25 OS/360 and HASP internal structure; IPL, NIP, etc. ASP. 00001380 26 Assorted topics: microprogramming; cache and virtual memories.00001390 27 Assorted topics: pipeline and array computers; non-IBM systems00001400 00001410 28,29,30 left for exams, problems, expansion, etc. 00001420 00001430 COMMENTS: the schedule above is fairly tight. It has been useful,00001440 especially in the first several weeks, to give 'help sessions' once a 00001450 week in the evenings, to go over problems, review, etc. This has been 00001460 useful especially to even out differences among 102/410 courses taken 00001470 at different times and/or different campuses. Note that the order of 00001480 topics above seems to work out fairly well, since it gives the students 00001490 the material needed for the assignments fairly early. 00001500 00001510 Note that some explanation of JCL should be given thoughout the 00001520 term, when relevant to specific assignments, etc, so that the two days 00001530 allotted to JCL contain a unified explanation, but assuming that the 00001540 students should have some familiarity with it by then. 00001550 , 00002000 CS411GI2 - 02 00002010 00002020 B. DETAILED OUTLINE, REFERENCES 00002030 00002040 DAY TOPICS 00002050 -- --------------------------------------------------------------00002060 00002070 1 Outline of course; administrative details; grading; exams; 00002080 course prerequsisites; review X-Macros: XREAD, XPRNT, XPNCH, 00002090 XDUMP, XSNAP, XDECI, XDECO, XHEXI, XHEXO, XSET. Note that 00002100 a few of these may NOT be review, but new material. 00002110 REFS: X-MACRO Writeups. 00002120 00002130 2 OS/360 Linkage Conventions: go over in detail; 00002140 ,>CS411FP1 (TEXT) - A FINAL PROJECT ASSIGNMENT WRITEUP FOR A , 00000050 CS411FP1 - 01 00000100 00000150 COMPUTER SCIENCE 411 - FINAL PROJECT 00000200 DUE __________ 00000250 This writeup: CS411FP: 1(01-08), 2(01-08), 3(01-08), 4(01-07), 5(01-06) 00000300 00000350 I. INTRODUCTION 00000400 00000450 A. PURPOSE OF ASSIGNMENT 00000500 00000550 This assignment requires the student to design, code, debug, and 00000600 test a program which simulates the execution of a fairly general 00000650 operating system (OS/411) under a variety of circumstances. It requires00000700 the student to become familiar with a number of different strategies for00000750 implementing operating system components, and provides experience in 00000800 working with programs of nontrivial size and complexity. 00000850 00000900 This project provides experience with the following operating 00000950 system technqiues: job scheduling, storage allocation, processor 00001000 dispatching, I/O request handling, and general job processing. 00001050 00001100 The following programming techniques can be included in this 00001150 program: linked list manipulation, queueing methods, and random number 00001200 applications. 00001250 00001300 In particular, the assignment generally requires the use of the 00001350 S/360 Assembler Language items: multiple CSECTS, DSECTS, heavy use of 00001400 macro definitions, and use of SET variables among macros and in open 00001450 code. 00001500 00001550 B. PROCEDURES FOR WRITING AND RUNNING THIS ASSIGNMENT 00001600 00001650 1. This writeup describes many alternate ways of performing the 00001700 actions needed in an operating system. Although students should study 00001750 the various options performed, they will NOT write the code to implement00001800 all of the options. One option (or several, to be compared), will be 00001850 chosen by the instructor to be coded by the students. THE STUDENTS WILL 00001900 DEFINITELY NOT BE REQUIRED TO WRITE EVERYTHING DESCRIBED HERE, ALTHOUGH 00001950 THEY SHOULD ATTEMPT TO BECOME FAMILIAR WITH THE VARIOUS OPTIONS. 00002000 00002050 2. In some cases, there are variables which are to be given certain00002100 values for test purposes, but which are to be represented by GLOBAL SET 00002150 VARIABLES in the student program. These SET VARIABLES may be referrred 00002200 to in various parts of this writeup. The values to be used will be 00002250 given by the instructor(to fill in chart on page CS411FP4 - 06). 00002300 00002350 3. The student will write ONLY ONE source program to cover all of 00002400 the different options desired. Alternate versions of a particular 00002450 method will be selected or deleted using conditional assembly in open 00002500 code (i.e., using GBLA, GBLB SET VARIABLES and AIF, AGO commands). 00002550 00002600 4. The instructor will supply test decks, and request that they be 00002650 run, given 1 or more sets of options/parameters. The student will then 00002700 generate the required version(s) of his program by changing ONLY a few 00002750 SETA, SETB, SETC statements at the beginning of his program, which will 00002800 create the specific version needed. This process of using SET variables00002850 to generate the system is referred to as a SYSGEN. 00002900 , 00002950 CS411FP1 - 02 00003000 00003050 5. It should be noted that some of the terminology employed in this 00003100 writeup is not exactly standard, in particular the word QUEUE is used 00003150 quite often. This usually is taken to mean a list (usually ordered on 00003200 some key), from which only the first item can be removed, and new items 00003250 only added to the end. Although this may be the most common case, for 00003300 this writeup the items in some queues may be inspected, modified, added 00003350 and deleted in any position. For example, it may be necessary to scan 00003400 a queue in order for the first item meeting a specified test, then 00003450 removing that item. 00003500 00003550 00003600 C. A BRIEF DESCRIPTION OF THE PROGRAM AND WHAT IT DOES 00003650 00003700 The program to be written will read an INPUT STREAM, which is made 00003750 of one or more BATCHes of JOB cards. Each JOB card descibes the needs 00003800 and characteristics of a single JOB. The program will then simulate the00003850 handling of this job by a typical operating system. 00003900 00003950 OS/411 handles each BATCH of one or more JOB cards as follows: 00004000 00004050 First, OS/411 initializes itself to a status in which there are no 00004100 JOBS at all in the system, and all counters, flags, etc are set to 00004150 their desired beginning values. The JOB cards will then be read (either 00004200 immediately or at various intervals during the run), until the BATCH of 00004250 JOBS is finished executing. 00004300 00004350 Reading a JOB card begins a long sequence of actions which must be 00004400 performed to simulate the actions needed to run a JOB. 00004450 00004500 First, the JOB card is scanned, and all information is recorded 00004550 from it. The JOB is entered on a queue of JOBS which are not yet able 00004600 to obtain use of a Central Processing Unit (CPU). Basically, this step 00004650 represents the process of reading in a complete JOB and storing it on 00004700 magnetic disk before it can be executed. 00004750 00004800 Whenever it might be possible that some JOB be loaded into memory 00004850 and EXECUTED, the queue of waiting JOBS is scanned, and a JOB is perhaps00004900 selected (according to one of many possible rules). This JOB is then 00004950 INITIATED, i.e., allocated MEMORY, and made ready for EXECUTION. It is 00005000 thus free to compete with other such ACTIVE JOBS for the use of the CPU 00005050 (or one of several, if such exist). 00005100 00005150 The list of ACTIVE JOBS (ones in memory), is periodically scanned 00005200 (according to one of several algorithms) and a JOB is selected to 00005250 receive control of a CPU for some period of time, i.e., the JOB is 00005300 DISPATCHED. 00005350 00005400 After some length of time during which the JOB has use of the CPU, 00005450 it may make an Input/Output Request, in which case it relinquishes 00005500 control of the CPU (so that another ACTIVE JOB, if any, may get it). 00005550 The IO REQUEST needs the use of an IO CHANNEL, of which there are one 00005600 or more. Depending on the needs of the JOB, it either gains control of 00005650 a CHANNEL, and uses it to perform its IO immediately, or else it enters 00005700 a queue of JOBS competing for the use of CHANNELS. In the latter case, 00005750 it may have to wait a while until it is selected to use the CHANNEL it 00005800 needs. It is said to be in WAIT STATE at any time during which it is 00005850 READY to use a CPU or CHANNEL, but cannot obtain what it needs. 00005900 , 00005950 CS411FP1 - 03 00006000 00006050 When a JOB is finished using a CHANNEL, an IO INTERRUPT is said to 00006100 occur. This means that the JOB relinquishes control of the CHANNEL, 00006150 becomes READY to use a CPU, and thus enters the list of such JOBS, once 00006200 more competing with the others. The CHANNEL thus released of course 00006250 becomes available for use by other JOBS again, and may be used to fill 00006300 a request from some previous JOB, which is WAITING for the CHANNEL. 00006350 00006400 Among the values found on the JOB card is a time limit for the 00006450 execution of the JOB. When this limit is reached, the JOB is considered00006500 to be finished. It is then JOBTERMED, i.e., it is removed from the 000006550 list of JOBS competing for CPU usage, the memory it occupies is freed 00006600 for possible allocation to other JOB(S) (i.e., the ones waiting on 00006650 disk to obtain memory). 00006700 00006750 At various times, calculations are made to determine some values 00006800 indicating the performance and nature of the particular operating system00006850 version being generated. Typical times are the end of a JOB and the 00006900 end of a BATCH of JOBS. 00006950 00007000 00007050 The process described above occurs for every JOB in a BATCH. Each 00007100 BATCH is processed, until none remain. CS411FP5-01 has job flow chart).00007150 00007200 00007250 The remaining portions of the writeup describe: the configuration 00007300 of the computer system begin run by OS/411, the major options possible, 00007350 SET VARIABLES which may be needed, and many hints on the implementation 00007400 of this program. The last includes general methods, ideas on good ways 00007450 to divide the program into modules, sample data structures and DSECTS, 00007500 and overall flowcharts which might be useful. 00007550 00007600 Every option is given a mnemonic name of some sort, and SET 00007650 VARIABLES are of course named as they might be inside OS/411. 00007700 00007750 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00007800 * * 00007850 * NOTE: HINTS, DSECTS, AND FLOWCHARTS GIVEN IN THIS WRITEUP * 00007900 * ARE ONLY SUGGESTIONS. THE STUDENT MAY BE ABLE TO DO THEM MUCH * 00007950 * BETTER THAN THE WAYS OUTLINED. IN PARTICULAR, THESE THINGS ARE * 00008000 * USUALLY WRITTEN TO COVER ALMOST ALL OF THE POSSIBLE OPTIONS GIVEN* 00008050 * IN THIS WRITEUP. AS A RESULT, THEY ARE MUCH MORE GENERAL THAN * 00008100 * WILL EVER BE NEEDED TO COVER ONLY ONE-TWO OPTIONS FROM EACH * 00008150 * GROUP OF OPTIONS. THUS THESE TABLES AND FLOWCHARTS ARE USUALLY * 00008200 * MORE COMPLEX THAN NEEDED FOR THE VERSIONS REQUIRED TO BE TURNED * 00008250 * IN FOR GRADE, LEAVING MUCH ROOM FOR CHANGES. * 00008300 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00008350 , 00008400 CS411FP1 - 04 00008450 00008500 II. COMPUTER CONFIGURATION 00008550 00008600 The OS/411 operating system is to be designed for use with a 00008650 paticular model of the famous (or infamous, depending on viewpoint) 00008700 System/411 series of computers. This section lists the various sizes 00008750 and nature of systems which may occur. 00008800 00008850 A. MEMORY SIZE 00008900 00008950 &MEMSIZE : gives the size of the S/411 computer, in K (1024) 00009000 bytes. &MEMSIZE may range from 1 to 1024, and OS/411 may or may not 00009050 be required to run on different-sized machines. Some versions of OS/41100009100 may be written to run only with one memory size, thus allowing for more 00009150 efficient special-case programming techniques. 00009200 00009250 B. NUMBER OF CENTRAL PROCESSING UNITS (CPU) 00009300 00009350 A CPU is one of the most important resources to be needed for the 00009400 execution of a JOB. A basic S/411 system contains only 1 CPU, while the00009450 bigger models may contain more than one. The possible options are: 00009500 00009550 CPU1 Only 1 CPU exists. 00009600 00009650 CPUv &NUMCPUS gives the number of CPU'S in the system. &NUMCPUS 00009700 may range from 1 to an upper limit to be given. 00009750 00009800 00009850 C. NUMBER OF INPUT/OUTPUT CHANNELS 00009900 00009950 Performing input/output for a user JOB requires the use of an IO 00010000 CHANNEL. The following are the possible options: 00010050 00010100 CHN1 the system is a small one with only 1 IO channel, which all 00010150 user jobs must use when they need IO. 00010200 00010250 CHNx the number of I/O channels is fixed at the number x. Channels00010300 are numbered from 1 to x. 00010350 00010400 CHNv &NUMCHNS gives the number of channels, with &NUMCHNS varying 00010450 from 1 to some given upper limit, and OS/411 must be written 00010500 to handle any possible value. Channels are numbered 1 to 00010550 &NUMCHNS in this case. No system has more than 15 channels. 00010600 , 00010650 CS411FP1 - 05 00010700 00010750 III. INPUT JOB STREAM 00010800 00010850 OS/411 reads a deck of input cards, which contain cards which 00010900 describe JOBS, and may contain other kinds of cards also. The kinds of 00010950 cards possible are as follows: 00011000 00011050 A. JOB CARD - DESCRIBES CHARACTERISTICS OF ONE JOB 00011100 00011150 Each BATCH of JOBS consists of from 0 - to some maximum number of 00011200 JOBS. This maximum number may be a constant or be given by &MAXJOBS . 00011250 Each card is of the following format (starting in column 1): 00011300 00011350 $$JOB jobname T=x,SP=x,IOIN=x,IORL=x,PRIO=x,CHAN=x,CAT=x 00011400 00011450 jobname is a 1-8 character name, separated from other items by 00011500 1 or more blanks on each side. It is a unique name which00011550 is used to identify the specific job in any messages. 00011600 00011650 The rest of the JOB card consists of the parameters shown, WHICH 00011700 MAY OCCUR IN ANY ORDER. The following options are possible: 00011750 00011800 PARM1 all of the parameters will exist on any JOB card, and no 00011850 errors need be tested for in them. 00011900 00011950 PARM2 some parameters may be omitted or in error, in which case 00012000 DEFAULT values are to be set at SYSGEN time and used instead. 00012050 The corresponding SET variables are then named by &, the name 00012100 of the parameter, and DFT, i.e., default T= value is given by 00012150 &TDFT, etc. So value of &PRIODFT is used if PRIO= is omitted.00012200 00012250 PARM3 This includes PARM2 above, except that the defaults are done 00012300 by JOB CATEGORY (the CAT= value), so that omitted options from00012350 JOBS in different categories will have different defaults. 00012400 00012450 All the values of x above are unsigned decimal numbers, and the 00012500 specific meaning of each parameter is given below. 00012550 00012600 T= a number from 1 to 32767, giving the number of milliseconds 00012650 which is a time limit on the execution of the JOB. As will be 00012700 given in a later section, this always counts use of the CPU, but 00012750 may or may not count use of a CHANNEL. 00012800 00012850 SP= (SPace) - a number from 1 - 1024, giving the number of K-byte 00012900 blocks of storage required to execute a JOB. 00012950 00013000 IOIN= (I/O INterval) - a number from 1 - 32767, which describes the 00013050 interval between I/O requests from a job. value is in millisecs. 00013100 00013150 IORL= (I/O Request Length) - number from 1 - 32767 describing the 00013200 duration in milliseconds for one I/O reques