Digital PDFs
Documents
Guest
Register
Log In
XX-A5200-AB
March 1965
103 pages
Original
3.4MB
view
download
Document:
I-85 PDP-8 Course Workbook 196503
Order Number:
XX-A5200-AB
Revision:
Pages:
103
Original Filename:
http://bitsavers.org/pdf/dec/pdp8/pdp8/I-85_PDP-8_Course_Workbook_196503.pdf
OCR Text
1-8 5 3 1 65 PROGRAMMED DATA PROCESSOR-8 DIGITAL EQUIPMENT CORPORATION • MAYNARD, MASSACHUSETTS 1-8 5 PDP-8 COURSE WORKBOOK DIGITAL EQUIPMENT CORPORATION • MAYNARD, MASSACHUSETTS Copyright 1965 by Digital Equipment Corporation The PDP-8 Course Workbook was written and edited by the training department of the Digital Equipment Corporation. ii CONTENTS Chapter Page The Concept of A Digital Computer............................ 1-1 2 The Concepts of Digital Computer Programming ...•...•....•.•... 2-1 3 Introduction to PDP-8 Systems ......•..........••...•.•......•• 3-1 4 Basic PDP-8 Instruction List ........•.........•.•.•.•.••...•... 4-1 5 Introduction to the PDP-8 Assembler (PAL) .•.••.•...........•.•. 5-1 6 Introduction to the PDP-8 Symbolic Tape Editor .......•........•. 6-1 7 Introduction to the PDP-8 Octal Debugging Tape ........•...•..•. 7-1 8 Input-Output Instructions and Routines ...•....•......•....•.•.•. 8-1 9 Program Interrupt Feature of the PDP-8 System ••.•.......•.•.•.•. 9-1 10 Program Library: Subroutines and Programs .•...••..•••...•.••.•• l 0-1 ll Introduction to the PDP-8 DEC Debugging Tape (DDT-8) ......... . l 1- l iii INTRODUCTION This workbook is written to assist the student in understanding PDP-8 computer systems. By using it as a class text, study guide, and workbook in conjunction with the PDP-8 Handbook (F-85) and Program Writeups, al I aspects of the course can be covered and the fundamental concepts of programming the PDP-8 can be mastered. The workbook describes the PDP-8 and gives sample problems in programming and homework assignments. It is suggested that the student solve the problems and retain them for future reference. This book is accompanied by a series of lectures and laboratory periods designed to further assist the student in understanding the operating features of the PDP-8 system. During these periods, the uses and capobil ities of the software packages provided with each computer instol lation ore discussed. By the end of the course, each student should be able to use al I the equipment in the PDP-8 system. IV CHAPTER 1 THE CONCEPT OF A DIGITAL COMPUTER A digital computer can be defined as a device capable of automatically carrying out a sequence of operations on data expressed in discrete {digital) form. Each operation is one of four kinds: l. An input of data from a device outside the computer. 2. An arithmetic or processing operation on data stored within the computer. 3. An output of data from the computer to the external equipment. 4. A sequence-determining operation in which the computer chooses which of two (or more) alternative sequences of operation it will perform. This choice is based upon the condition of the data in the computer or the status of peripheral equipment at the time of sequence determination. Using these four operations, present-day computers are capable of performing extended and varied sequences of arithmetic operations. As such, they are very flexible and useful in rapidly executing computations which would take months or years of tedious work if done by hand. However, even in the solution of simple problems, the machine must be told the step- by-step procedure for arriving at the correct solution. For each machine, such as the PDP-8, there is given set of instructions which may be used to process data and solve problems. The circuitry and wiring within the computer itself determine how each instruction is executed, and the order in which the instructions are carried out is determined by a stored program. When digital computers, such as the PDP-8, execute an instruction, they do it in discrete steps called cycles. During the first cycle, the fetch cycle, the cor:nputer obtains the instruction and determines how to perform it. If the instruction does not require an operand from memory, the instruction wil I be executed during the fetch cycle. 1-1 For al I instructions which refer to a location in the memory, a second cycle must be performed. This execute cycle actually performs the operation specified by the instruction. In the PDP-8, the cycle time is 1 .6 microseconds. Since digital computers operate at high speeds, the sequence of instructions must be available within microseconds. The essential elements of a system which can prestore data are shown in Figure 1. The instructions are fed into the machine via the input and stored in the memory. The operations and data manipulations are performed in the arithmetic element, and processed data is fed to the output element. All elements can be controlled manually from the console or automatically by the computer itself. The control element is not clearly identifiable. In a machine, control is quite dispersed and often involves a heterogeneous mass of circuitry. MEMORY CONTROL UNIT INPUT OUTPUT ARITHMETIC UNIT DATA INFORMATION CONTROL INFORMATION Figure 1 • • Main Elements of PDP-8 System This workbook describes the available means for storing a sequence of instructions in memory and causing the computer to execute these instructions. 1-2 CHAPTER 2 THE CONCEPTS OF DIGITAL COMPUTER PROGRAMMING A. GENERAL Each digital computer has a special code in machine language which tells the computer what to do. The specific codes for the PDP-8 will be described in a later chapter. For the moment, it would be instructive to review the fundamental concepts of digital computer programming. If you do not understand the following concepts, it might be useful to obtain a copy of a reference book in basic programming. Each oreo in the memory of the computer which can contain the unit of information referred to os a word (12 pieces of binary information) is cal led a register. Each register hos a number associated with it, called the address, which determines its position in memory. B. STRAIGHT-LINE PROGRAMMING This type of programming deals with the step-by-step, uninterrupted sequence of program steps. An example of straight-I ine programming is shown below: Example: Program the equation A - B(4-3D) 0/ Load d l/ 2/ Mui f (f contains 3) Complement 3/ Add g (g contains 4) 4/ Mui b 5/ 6/ 7/ Complement Add a Halt NOTE: Each instruction os shown would not necessarily occupy one location in memory. They are shown this way for descriptive purposes only. 2-1 In the above example, registers f and g contain the constants 3 and 4, respectively. Registers a, b, and d contain the parameters A, B, and D, respectively. The registers 0 through 7 contain the program itself. It is important to note that the program will be stored in memory along with the data to be used in the solution of the problem. The computer cannot tel I the difference between stored data and instructions. The programmer enables the computer to differentiate between the two. C. PROGRAM LOOPS Sometimes it is necessary to repeat a portion of a program each time changing only a small portion of the original program to obtain different results. By using a program loop, the programmer can obtain this repetitive operation. Example: Solve the equation 35{A+B) for al I integral values of A starting with 0 and store the solutions in consecutive registers starting at address h. 0/ Load f {f contains 0) 1/ Add b {b contains B) 2/ Mui g {g contains 35) 3/ Deposit into h 4/ Load 3 5/ Add c {c contains l) 6/ 7/ Deposit into 3 10/ Add c 11/ Deposit into f 12/ Jump to 0 Load f The first four instructions actually solve the problem. The next three instructions increment the address of the storage register by one, and the following three instructions increment the value of A by one. Note that the program steps can be treated as data since they may be modified {see steps 5 and l 0). The jump instruction al lows the computer to repeat the above routine endlessly. 2-2 • The jump instruction al lows the programmer to break the normal sequence of program steps. In the above example, the jump back to the beginning is said to be unconditional because each time the control circuitry analyzes the instruction, it wil I always execute the same command, 11 Return to the beginning. 11 The jump instruction can transfer program execution to any location in the sequence of instructions. D. PROGRAM BRANCHING As shown in the previous example, looping is useful in repetitive calculations. It also is used to loop a predetermined number of times and then continue in the main program. This procedure is tallying. Example: Find the 10th power of 2 0/ Load f {f contains -10, the ta 11 y number) 1/ Deposit into g 2/ Load m {m contains 1) 3/ Deposit into k 4/ Load k 5/ 6/ 7/ Mui h {h contains 2) 10/ Add m {m contains 1) 11/ Deposit into g 12/ Skip if zero 13/ Jump to 4 14/ Continue Deposit into k Load g {g contains -10) In the example above, the first four instructions initialize the routine. In this case, for only one pass through the sequence, they could be left out completely; however, they are inserted to show the necessary steps to initialize the tallying routine. A general rule is to initialize any register which is changed during program execution. The next three steps do the actual program work on the data, and the next four steps check to see if the routine has executed ten loops. If it has not, the tally number wil I be negative and the routine will continue to loop. As soon as the tally number becomes zero, the program 2-3 wil I skip instruction 13 and branch back into the main program. The branch is also useful as it enables the computer to make a decision. For example, if the partial answer to a problem is positive, the computer wil I continue with the main sequence. If, the partial answer is negative, the computer will jump to a different portion of the program. Branch instructions may be referred to as conditional skip instructions. They al low the computer to skip or not skip an instruction depending upon existing conditions. E. SYMBOLIC ADDRESSING Symbolic addressing is not a concept in programming but is a means by which the programmer can write understandable programs. The computer uses only machine language and requires that al I data and instruction steps be stored in memory in binary numbers. To avoid the use of only ones and zeros in writing programs, it is useful to have a computer program, as the PAL (PDP-8 Assembler), which can interpret mnemonic codes and symbolic addresses by translating them into their binary equivalent. A symbolic address is an address specified by a letter designation rather than a specific numerical location. The PAL Assembler converts these letters into machine language numbers. The program can begin at any location because al I program locations are relative to each other. A more complete treatment of symbolic addressing on the PDP-8 wil I fol low in Chapter 5. Also, the 3-letter mnemonic names for the instructions themselves (TAD, DCA, ISZ, JMP) will be discussed in a later chapter. Example: A, D, Symbolic Addressing ADD Kl /GET NUMBER DEPOSIT INTO K2 /STORE IT SUBTRACT K3 /SUBTRACT MULTIPLY BY K2 /MULTIPLY JUMP TO A /KEEP LOOPING 2-4 Kl I 230 K2, 0 K3, 56 The above example indicates the format of a program using symbolic addressing. F. FLOW CHART TECHNIQUES 1• General Flow charting is a technique to diagramatically represent an initial phase of creating a program. The detail or extent of flow charting is entirely up to the programmer. An experienced programmer might represent a program in two or three distinct steps; whereas a novice might gain more in thinking through a program by using a block for each basic program function. In either case, a flow-chart block should be a condensation, not a representation of each program step. 2. Flow Chart Symbols Used to represent a program function or operation; one entry, one exit. Used to connect two program points; a convenience symbol or 0 chart label, not a program operation. A decision symbol, one entry, multiple exits, a conditional branch. ( ) Beginning or stopping point of a program. Representation of flow. 3. Example Flow chart of a routine to add numbers together. 2-5 START Case I Case II STOP MODIFY PROGRAM Case Ill 2-6 NO YES STOP Case I represents a brief diagram. Case II and Case Ill present more detailed diagrams. G. SUMMARY Remember that the function of a flow chart is to assist the programmer. If it is not needed, it may be omitted. A flow chart clearly represents all paths of program flow and gives the programmer a tool to do his program coding. REVIEW QUESTIONS - CHAPTER 2 These questions are not necessarily covered in the workbook but review basic terms and ideas that the student should understand before continuing with the workbook. l. What is a word? A bit? A register? An address? A location? 2. What is the octal numbering system? 3. If a computer has 4096 memory locations, what is the largest address in octal? 4. List some common input devices for a computer. 5. In location 340 is stored the instruction tad 350. In location 350 is stored the number 0005. If a program is operating and reaches location 341, what wi 11 be the contents of the accumulator? What is the operand of the instruction in 340? 6. What are the answers to the following problems? 56(8) l 01 (10) + 17 (8) + 101(2) 2-7 CHAPTER 3 INTRODUCTION TO PDP-8 SYSTEMS A. GENERAL The Digital Equipment Corporation PDP-8 computer is a high-speed, sol id-state, digital computer capable of hand Iing up to 64 input-output devices. It uses a 12-bit word and operates on 2 1s complement arithmetic. The input-output devices used most often are a perforated-tape reader, a perforated-tape punch and an on-I ine/off-1 ine teleprinter (Teletype UnitASR-33). The standard memory for the PDP-8 consists of 4096(lO) words and can be expanded in increments of 4096(l0) to 32,768(l0) words. The basic cycle time is l .6 microseconds. B. CENTRAL PROCESSOR ELEMENTS l. Control Element The control element is widely dispersed and not precisely definable. Components that fal I under the control category are associated with most of the other elements and peripheral equipment. The control element governs the complete operation of the prescribed instruction, and initiation of input-output commands. 2. Arithmetic Element The arithmetic element is the central part of the computer and may be compared with a desk calculator. It can add (on demand by an instruction) a given number to whatever number currently is contained in itself. It can make simple logical decisions based on the contents of the arithmetic unit. Finally, the arithmetic element can mechanize operations which have no counterpart in ordinary arithmetic. For example, it performs Boolean AND and OR operations. The arithmetic element is a manipulator of numbers and is composed of the accumulator and the Iink. 3-1 a. Accumulator The accumulator is a 12-bit register that performs addition, logic (negation, and AND), and counting operations. It is connected to the memory module through the memory buffer and can transfer or receive information from the memory module and transfers information from the console. Information from the standard 1/0 devices and most other input-output devices are transferred into the accumulator through the input mixer. When the data interrupt is used with a high-speed device (drum, mag tape, DECtape), the accumulator is bypassed, and information goes directly through the memory buffer. b. Link The link is a 1-bit register used in conjunction with the AC. The link may be rotated along with the AC either to the right or to the left. It may be considered to be left of AC 0 and right of AC 11 • It may be cleared, complemented, and sensed. The latter feature makes it available as a program flag. be regarded as the overflow register for arithmetic addition. The Iink may If overflow occurs, the Ii nk is comp I emented. 3. Memory The memory is not a part of the central processor. However, it is included here as a preview to the description of its associated registers, which are included in the central processor. The memory contains stored information or data to be processed and the instructions of the programs to do the processing. The magnetic core memory of a standard PDP-8 holds 4096 words of 12 binary bits. The memory capacity may be expanded in increments of 4096 words to 32,768 words. Memory may be further supplemented by magnetic tape unit, drum options, or the addressable tape, DECtape. 4. Memory Addressing Element This element is composed of two discrete units. 3-2 a• Memory Address Register The memory address register contains 12 bits and controls the access to memory while each instruction is being executed. During every 1.6-microsecond memory cycle, the memory address register addresses a single core register in the computer memory. The memory cycle is divided into two portions, a read portion and a write portion. During the read portion, a single 12-bit computer word is read from the addressed core register into the memory buffer. During the write portion of the cycle, the word contained in the memory buffer is written back into the addressed core register. For both read and write portions of the memory cycle, the addressed core register is specified by the contents of the memory address register. b. Program Counter Register The program counter is a 12-bit register and may be modified under program control. It indicates to the control circuitry the location of the next instruction to be executed. It can be preset from the switch register by the load address switch. In normal operation, it starts at its preset value and indexes by one each time a program instruction is executed. It can be reset during program execution by a jump instruction. The contents of the program counter are displayed on the console. 5. Memory Buffer Register The memory buffer register contains 12 bits and is connected to core memory. All information which enters and leaves the memory must come through this register. Information can be transferred between the memory buffer, the accumulator, the instruction register, and the program counter. 6. Instruction Register The instruction register contains the 3-bit operation code of the instruction currently being performed by the computer. Information enters this register from the MB. 3-3 C. INPUT-OUTPUT CONTROL The input-output control provides control circuitry enabling input-output {1/0) devices to transmit information into or receive information from the central processor. A brief summary of this unit is given in Section B, .Chapter l of the PDP-8 Handbook {F-85). The discussion of this unit, from a programming point of view, will be left to the chapters on the 1/0 devices and interrupt facility. D. COMPUTER COl'ITROL STATES The computer performs one memory cycle {l .6 microseconds) in one and only one of four states. These states are: Fetch Defer Execute Break The four states of the computer are described in detai I in Chapter l of F-85. 3-4 CHAPTER 4 BASIC A. PDP-8 INSTRUCTION LIST GENERAL The Iist of available instructions for the PDP-8 is shown in Appendix 1 of the PDP-8 Handbook (F-85). The instructions are grouped according to their function. A description of what each instruction does can be found in Section A, Chapter 2 of the PDP-8 Handbook. There are two basic groups of instructions: memory reference and augmented. Memory reference instructions require an operand; augmented instructions do not require an operand. The addressing technique requires a complete understanding of the page addressing of the PDP-8. 1. Page Addressing The memory of the PDP-8 is divided into blocks of 128 10 or 200 8 locations called pages. These pages are not phys ica I pages in memory nor are the areas of the memblocked off in any manner. Pages occur as a result of the size of the address portion of the instruction. In order to minimize needless confusion, a number of definitions are given below. a. Current Page The page containing the instruction being executed. This page is determined by bits 0-4 of the program counter. b. Page Address A 7-bit number contained in bits 5-11 of an instruction which designates one of 200 8 core memory locations. Bit 4 of the instruction indicates the page to which the page address refers. 4-1 Bit 4 Page 0 Page 0 Current page Thus, bits 5-11 specify one of the 2008 locations on the page determined by bit 4. c. Absolute Address A 12-bit number used to address any location in core memory. d. Effective Address The address of the operand as specified in an instruction or by an absolute address. To the programmer, the page feature means that there are 4008 locations available for direct addressing with memory reference instructions. The programmer has 2008 locations on the page where the program is running and all 2008 locations of page 0 (absolute locations 08-177 8) directly addressable. Any location in the entire 4K of memory may be addressed by the use of indirect addressing in the instruction. The absolute address of the operand is placed in the location specified by bits 4-11 of the instruction. Four methods of obtaining the operand at the effective address are used as specified by combinations of bits 3 and 4. Bit 3 Bit 4 Effective Address 0 0 The operand is on page 0 at the address specified by bits 5 through 11. 0 The operand is on the current page at the page address specified by bits 5 through 11. 0 The absolute address of the operand is taken from the contents of the location on page 0 designated by bits 5 through 11. 4-2 Bit 3 Bit 4 Effective Address The absolute address of the operand is taken from the contents of the location on the current page at the page address specified by bits 5 through 11. The augmented instructions in the PDP-8 require more understanding than the specification of each instruction. Their microprogramming feature lends itself to shorter, more powerful programs. 2. Operate Group The operate group, in general, performs its actions on the accumulator and link. These instructions do not require a memory reference. The instructions may be referred to as microinstructions because the performance of an operation is specified by the presence of a l in a bit of the instruction. Specific instructions may be logically ORed together to perform a number of operations. The event times indicate the order in which the operations are performed. Two instructions occurring at the same event time can be combined subject to the restrictions given in Section A, Chapter 2 of the PDP-8 Handbook. Within the operate group itself there are two groups. Group l is principally for clear, complement, rotate, and increment instructions. This group is designated by a 0 in bit 3 of the operate instruction. Group 2 is used in checking the contents of the accumulator and link to determine sequence of operations to be fol lowed. This group is designated by a l in bit 3.• The programmer never needs to worry about the bits being in the correct place when using the assembler; mnemonic symbols for the instruction takes care of this. The instructions from Group l and Group 2 can never be combined because of the use of bit 3. 4-3 Within Group 2, there are two groups of skip instructions. They may be referred to as Group 2a and Group 2b. Group 2a Group 2b SMA SPA SZA SNA SNL SZL Group 2a is designated by a 0 in bit 8; Group 2b, by a 1 in bit 8. Instructions from Group 2a and 2b should never be combined, for the same reason as above. If the programmer does combine legal skip instructions, it is important to note the conditions under which a skip will occur. a. Group 2a If these skips are combined in a single instruction, the inclusive OR of the conditions determines the skip. SNL SZA The next instruction is skipped if: the AC contains 0000, or the Ii nk is a 1, or both conditions exist. b. Group 2b If the skips are combined in a single instruction, the logical AND of the conditions determines the skip. SNA SZL The next instruction is skipped only if: the AC differs from 0000 and the I ink is 0. 4-4 One combination is a skip instruction combined with a CLA instruction. The condition is sensed and the accumulator is cleared to enable a TAD instruction to load the AC in the next instruction. 3. Input-Output Group The instructions in this class are used to enable information transfers between the central processor and external devices via the interface. The mass of circuitry which controls the transfer of information to and from the computer is cal led the input-output control. Specific IOT commands are discussed in a later chapter of this workbook. REVIEW QUESTIONS - CHAPTER 4 l. If you perform a CMA instruction, are you dealing with l's or 2 1 s complement arithmetic? 2. Describe the action and use of: a. The JMS instruction b. the AND instruction c. The combined use of DCA and TAD instruction 3. a. What is the contents of the AC after a C LA CMA instruction? b. What is the contents of the register containing the microinstruction SPA SNL? Would this accomplish the desired function? If not, why not? In the fol lowing programs, the number fol lowed by a slash indicates the address where the given instruction or number is located. The address following any mnemonic instruction is an absolute address. 4. The following program adds some numbers together, stores the total away, and halts. What is the sum and in what location is it stored? 1000/ CLA CLL 1001/ TAD 1020 1002/ IAC 4-5 1003/ 1450 1004/ RAL 1005/ SNL 1006/ 5202 1007/ RAR 1010/ 3603 1011/ HLT 1020/ 4012 1021/ 2000 50/ 1021 Change location 1020/ from 4012 to 1012 and do the problem again. 5. The original contents of AC is 1234; the Iink is l . The fol lowing program is executed. Will the program ever stop? If so, what are the final contents of the AC and the link? 1000/ RTL 1001/ DCA 1021 1002/ ISZ 1017 1003/ TAD 1020 1004/ NOP 1005/ DCA 1011 1006/ TAD 1017 1007/ DCA 1014 1010/ TAD l 021 l 011/ HLT 1012/ IAC 1013/ RAR 1014/ NOP 1015/ RAR 1016/ JMP 1015 1017/ 7401 1020/ 7006 1021/ HLT 4-6 6. The fol lowing program is executed. What are the contents of the PC when the computer halts? 200/ CLA CMA 201/ DCA 213 202/ ISZ 213 203/ HLT 204/ TAD 214 205/ TAD 215 206/ TAD 216 207/ DCA 221 210/ TAD 201 211/ TAD 217 212/ DCA 213 213/ IAC 214/ NOP 215/ 2 216/ 400 217/ TAD 5 220/ HLT 221/ JMP 200 4-7 CHAPTER 5 INTRODUCTION TO THE PDP-8 ASSEMBLER (PAL) A. GENERAL The PAL Assembler is a program which translates a symbolic source program tape into a form suitable for execution by the PDP-8 and punches out this form on a binary output tape (binary object tape). The source program permits the programmer to express the operations for the computer to perform in a more legible form than the binary code in which the PDP-8 must receive its instructions. By using this assembler program (PAL), the programmer may use mnemonic names or symbols for the instructions and assign symbolic addresses in the program. For example, if the programmer uses the characters DCA in his source program, the Assembler wi 11 tra_nslate them to the value 30008 as stored in memory. The Assembler process substitutes the binary value of each symbol for the symbol itself and punches it out on the binary output tape. During assembly, the assembler program keeps a current location counter, which indicates the address of the register where the next instruction or data word will be stored. confuse this with the program counter which is in the PDP-8 machine. assembled, this address is increased by one. Do not For each word The initial address may be preset to al low assembly at any locations and may be reset at any time during assembly by the appropriate control character in the source language program. Unless otherwise specified, assembly starts in location 200. The Assembler performs its action in two passes (the source language tape is processed twice to produce the one binary object tape). Certain functions which cannot be handled on the first pass must be handled by the second pass. The output from Pass l is a symbol table typed on the ASR-33 showing the tags used in the program and their corresponding octal values, and any error indications. 5-1 During Pass 2, the values of the tags are inserted in the corresponding symbolic address within the memory reference instruction, and the binary output tape is generated. The program writeup of the PAL Assembler is available from the program library and should be used during the writing and subsequent assembling of programs. B. HOW TO ASSEMBLE A SYMBOLIC PROGRAM WITH PAL The detailed description of the assembly process is given in the program writeup. For the programmer 1s ease of operation, the assembly procedure is shown as a flow diagram on the following page. C. MISCELLANEOUS 1. Flow Diagrams A flow diagram will save the programmer time in writing and executing his program. It will save space in memory if he draws a flow diagram which clearly illustrates the general sequence of operations, the point of which the various sequence determinations should be made, and the program flow following the sequence determination. It is suggested that no coding be done in the flow diagram; only verbal descriptions of operations in the program should be used. Examples of flow diagrams wil I be given throughout the rest of this workbook. 2. Program Structure Inexperienced programmers, should draw a flow diagram that clearly ii lustrates the sequential operation of the program. Then, the instructions should be written in assembler language to accomplish the function described in each block of the flow diagram. For short, simple programs, such as the ones for homework, the organization in memory is straightforward. There are three distinct portions to each program. For ease of debugging, keep the areas separate and well marked in the symbolic program. The portions are: 5-2 TOGGLE THE READ-IN MODE LOADER INTO MEMORY USE THE RIM LOADER TO LOAD BINARY LOADER INTO MEMORY USE BINARY LOADER TO LOAD PAL INTO MEMORY PUT SYMBOLIC TAPE INTO READER NO SET SWITCH REGISTER BIT 1= 0 BIT O= I SET SWITCH REGISTER TO 200. LIFT "LOAD ADDRESS"SWITCH UP TURN ON PUNCH SET SWITCH REGISTER BIT1=1 BITO=O SET PAGE NUMBER IF DESIRED TURN OFF PUNCH DEPRESS "START" GO TO PASS 2 TURN ON READER AND WAIT FOR END OF PASS 1 AND SYMBOL PRINT NO THERE ANY ERROR PRINTOUTS CORRECT SYMBOLIC TAPE AND REASSEMBLE 5-3 DEPRESS "CONTINUE" WAIT UNTIL LIT CODE IS PUNCHED TURN ON READER AND WAIT FOR END OF PASS 2 FINISHED Initialization Program Constants and Variables The program would be similar to the following for short programs: (l) Initialization (2) Program (3) Constants Variables Start by writing Part 2 first. As the program is written, generate the constants and variables as they are needed. Any storage register which is reserved for data that may change during the program is referred to as a variable. Then, after the program is written, go back to initialize any registers or instructions which have been changed or modified during the programs. Every program should be written so that it could be run a second time and give the correct result. All program examples will contain three segments clearly indicated. 3. Use of Page 0 Since page 0 is directly addressable from any core page in memory, often-used portions of the program should be put on page 0. Examples of such portions would be: Smal I subroutines (type in and typeout) Variables Constants Temporary storage registers Subroutine pointers 5-4 If the program is contained completely on one page, there is no real advantage to the use of page 0. However, if the program takes several pages, the use of page 0 wil I be of great value. D. LOADING PROCEDURES Since the student in the programming class will soon be running programs on the PDP-8, it is wise to fol low the steps in loading and running program. A short description of the loaders and tapes is given below. l. Read-In Mode (RIM) Loader The RIM Loader is a program used to load a RIM format tape from the reader into memory. The RIM Loader must be toggled initially into memory from the console of the computer but should never need to be toggled again. In order to avoid destruction by the maintenance program (Maindec series), the RIM Loader should be toggled into locations 20 through 40. The program and description for loading it are found in F-85, Appendix 5. The RIM Loader can then be used to Ioad the same program into the top end of memory to free page 0 for use in programm rng. Thus the RIM Loader may be located in locations: 0020-0040 (for maintenance program) 7700-7720 (other) The starting address for the respective RIM Loaders is 20, or 7700. To load a tape in RIM Format using the RIM Loader: a. Check to see if the RIM Loader program is correct in memory. If not, toggle it in. b. Put RIM Format tape in reader. c. Always put leader/trailer code over reader head - never blank tape. 5-5 d. Set SR to 20, or 7700 depending upon the location of the loader program. e. Depress the LOAD ADDRESS switch. f • Depress the START switch. g. Computer is now running and waiting to load any program from any tape which is in RIM Format regardless of the starting address of that program. h. Turn on the reader and wait until tape is completely read in. When the reader stops, the program is in memory. From the programmer's viewpoint, the RIM Loader is usually used to load the Binary Format Loader. 2. Binary Format {BIN) Loader The Bl N Loader is a program used to load a PAL Binary Format tape from the reader into memory. The Bl N Loader tape is loaded by the RIM Loader program. A description of the BIN Loader is given in Appendix 5 of F-85. The BIN Loader is loaded into location 7721-7777. The starting address for the BIN Loader is 7777. To load a tape in PAL Binary Format using the Bl N Loader: a. Put PAL Binary Format tape into reader. b. Set SR to 7777. c. Depress LOAD ADDRESS switch. d. Depress START switch. 5-6 e. The computer is now running and waiting to load a program from any tape that is in PAL Binary Format regardless of the starting address of that program. f. Turn on the reader and wait until the tape is read in. When the reader stops, the program is in memory. NOTE: If the AC does not contain 0 when the computer halts, the tape has read in incorrectly and should be loaded again. The BIN loader is used to load: PAL Symbolic Tape Editor Octal Debugging Tape Any tape from Pass 2 of the PAL Assembler Any other tape from the program Iibrary in PAL Binary Format When the program is loaded correctly from the PAL Binary Format tape into memory, determine the starting address (SA) of the program from the label on the tape. Start the program which was just read in by putting the starting address (SA) into the switch register, depress LOAD ADDRESS and START. E. EXAMPLE PROGRAM FOR ASSEMBLER 1. Problem Write a routine using a program loop and a branch condition to add up numbers stored in location 200 8 through 207 8 , and store the answer in location 4108 . Write the program starting in location 600. 5-7 2. Flow Diagram STARTIN 600 INITIALIZE COUNTERS AND POINTERS ADD NEXT NUMBER TO PARTIAL SUM INDEX POINTER TO OBTAIN SUCCEEDING NUMBER NO HALT 3. Program Listing /ADD UP NUMBERS *600 BEGN, HLT /LOAD 200-207 WITH NUMBERS. HIT 11 CONTINUE 11 ON CONSOLE I /THE NEXT FIVE INSTRUCTIONS INITIALIZE THE ROUTINE CLA /CLEAR THE ACCUMULATOR TAD MlO /LOAD AC WITH -10 TO INITIALIZE TALLY DCA CNTR /DEPOSIT IN COl.JNTER TAD 2HUN /LOAD AC WITH FIRST ADDRESS IN BUFFER DCA BUFF I /THE NEXT SEVEN INSTRUCTIONS ARE THE PROGRAM ITSELF ADDR, TAD I BUFF /ADD NEXT NUMBER FROM BUFFER ISZ BUFF /INDEX POINTER ISZ CNTR /INDEX COUNTER. IS IT ZERO? JMP ADDR /NO, JUMP TO ADD NEXT NUMBER DCA I ANSR /YES, DEPOSIT TOTAL IN 410 HLT /STOP. HIT 11 CONTINUE 11 TO REPEAT PROGRAM JMP BEGN+l 5-8 I /THE NEXT THREE REGISTERS CONTAIN THE CONSTANTS FOR THE PROGRAM MlO, 0-10 /NEGATIVE TALLY NUMBER 2HUN, 200 /FIRST ADDRESS IN BUFFER ANSR, 410 I /THE NEXT TWO REGISTERS ARE RESERVED FOR THE VARIABLES IN THE PROGRAM CNTR, 0 BUFF I 0 I $ 4. Output From the Assembler PASS 1: BEGN MlO CNTR 2HUN BUFF ADDR ANSR SYMBOL TABLE 600 615 620 616 621 PASS 2: BINARY TAPE AND "PRINTED MESSAGE (?)" 606 617 BF<: *<*?& ?7 The printed message output has no relevance to the programmer. The binary codes which are being punched on the tape in binary format simply coincide with the codes for the teleprinter output. The same buffer is used for output to the punch and printer. REVIEW QUESTIONS - CHAPTER 5 l. Ten numbers are stored in locations 2008 through 211 8 • The letter B is stored in 212 8 • Wri.te a routine starting in location 6008 which will determine how many of the ten numbers are larger than Band store this quantity in location 5008 • Use a flow diagram to lay out the program. 5-9 2. Deposit 7777 8 in all odd memory locations, and 0000 in all even memory locations, starting with the address set on the switch register, and ending 10008 locations later. Use a flow diagram as above. Assume that the SR setting is such that the program will not be destroyed. 3. Write a subroutine cal led MOVE to move a block of data from one area in memory to another area in memory. The subroutine is entered with the number of words to be relo- cated in the AC. The initial address of the existing block of data and the initial address of the new locatiori are located in the two registers immediately following the JMS MOVE instruction. Return to the main program with the AC cleared. Use auto-index registers. TAD N /NUMBER OF WORDS TO BE MOVED IN AC JMS MOVE /SUBROUTINE CALLED IAl /INITIAL ADDRESS OF ORIGINAL DATA BLOCK IA2 /INITIAL ADDRESS OF MOVED DATA BLOCK /RETURN WITH AC CLEAR 5-10 CHAPTER 6 INTRODUCTION TO THE PDP-8 SYMBOLIC TAPE EDITOR A. GENERAL The PDP-8 Symbolic Tape Editor al lows the programmer to correct or generate symbolic tapes in ASC 11 code with the PDP-8 computer from the keyboard of the ASR-33 teleprinter. Upon command, the Symbolic Tape Editor will punch out the corrected or generated symbolic program on paper tape in a format acceptable to the PAL Assembler. This program greatly reduces the tedious correction of symbolic tapes using the ASR-33 off line. For a complete description of the Editor, see the PDP-8 Symbolic Tape Editor writeup. B. MODES OF OPERATION There are two ways in which characters typed on the ASR-33 are interpreted, depending upon the mode of the Editor. There are two modes of operation-command and text mode. 1• Command Mode Characters typed by the programmer on the ASR-33 wil I be interpreted as commands telling the Editor to perform, or enable the programmer to perform, operations on the text of the program. Commands to the Editor must take one of the fol lowing forms with 0, 1, or 2 arguments where ). is the nonprinting character representing RETURN. If an incorrect form is typed, the Editor wil I type back a ? and return to I is ten for the next command. NOTE: When the RETURN key is depressed while the Editor is operating, the LINE FEED code wil I be generated by the program. 6-1 2. Text Mode Characters typed by the programmer on the ASR-33 wil I be interpreted as text to the symbolic program. The text wil I be inserted in the program in the manner described by the command immediately preceding it. 3. Transition Between Modes When the Editor program is started, it is in command mode {the program wil I be waiting for a command). The means of transferring between modes is shown pictorially below: I / { TYPE A COMMAND OF THE} DESIRED FORM, AND THEN ~ HIT THE RETURN KEY \ I COMMAND MODE TEXT MODE \_{T:~J;~:~~~~:~~~:: }_) WILL RING TO INDICATE THE TRANSITION NOTE: After the operator issues a command to insert, change, or append text to his program, the Editor will remain in the text mode until the CTRL/FORM key combination is depressed. This combination generates a special character cal led form feed, which tel Is the Editor to return to command mode. The Editor returns to the command mode automatically without bel I-ringing after executing a delete or list command. C. LOADING SEQUENCE TO CORRECT A SYMBOLIC TAPE 1. Load the binary format loader. 2. Load Symbolic Tape Editor with binary format loader. 6-2 3. Use locating 0176 8 as the starting address for the Editor. 4. Put symbolic tape of program to be corrected in reader. 5. Type R ); turn on reader. 6. If tape has no form feed code on end, hit CTRL/FORM combination after tape has read in. 7. Editor is now waiting for first command. D. SUMMARY OF COMMANDS l• 2. Input Commands A) Append incoming text from teleprinter. R ) Append incoming text from reader. Editing Commands nl ; K ) ) n,mD ) nD 3. Insert fol lowing text before Iine ~· Delete {kil I) entire page of text. Delete linen of text. Delete I ines ~through~ inclusively. L ) List entire page of text. nL ; List linen of text. n,mL ) List line~ through m of text. nC ; Change I ine ~of text. n,mC ) Change I ine ~through m of text. Output Commands p ) nP ) n,mP ) F ; Punch entire text. Punch linen of text. Punch line~ through~ of text. Punch form feed. 6-3 E. SEQUENCE FOR PUNCHING OUT A CORRECT SYMBOLIC TAPE l. Give the desired punch command: P ~, n,mP) or F ~. The computer will halt. 2. Turn on the punch. 3. If desired, switch the ASR-33 to LOCAL and generate as much Leader/Trailer code as needed. Switch teleprinter to ON-LINE. 4. Hit Continue on computer console. 5. If desired, generate Leader/Trailer. 6. When tape is punched, turn off punch before typing next command. Otherwise, the codes for the letters wi II appear on the symbolic tape. 7. Punching out the symbolic program does not delete it from memory. To read another tape into the buffer, delete the entire page of text (K) ). F. EXAMPLE TO SHOW USE OF SYMBOLIC TAPE EDITOR /ADD UP NUMBERS *600 BEGN, HLT /LOAD 200-207 WITH NUMBERS. HIT 11 CONTINUE 11 ON CONSOLE I /THE NEXT FIVE INSTRUCTIONS INITIALIZE THE ROUTINE CLA /CLEAR THE ACCUMULATOR TAD MlO /LOAD AC WITH -10 TO INITIALIZE TALLY DCA CNTR /DEPOSIT IN COUNTER CLA /CLEAR THE ACCUMULATOR TAD 2HUN /LOAD AC WITH FIRST ADDRESS IN BUFFER DCABUFF I /THE NEXT SEVEN INSTRUCTIONS ARE THE PROGRAM ITSELF BEGN, TAD BUFF /ADD NEXT NUMBER FROM BUFFER ISZ BUFF /INDEX POINTER ISZ I CNTR /INDEX COUNTER. IS IT ZERO? JMP BEGN NO, JUMP TO ADD NEXT NUMBER DCA ANSR YES, DEPOSIT TOTAL IN 410 HLT /STOP. HIT 11 CONTINlJE 11 TO REPEAT PROGRAM JMP BEGN+l 6-4 I /THE NEXT THREE REGISTERS CONTAIN THE CONSTANTS FOR THE PROGRAM MlO, 0-10 /NEGATIVE TALLY NUMBER 2HUN, 200 /FIRST ADDRESS IN BUFFER ANSR 410 I /THE NEXT TWO REGISTERS ARE RESERVED FOR THE VARIABLES IN THE PROGRAM CNTR, BUFF, $ An assembly using PAL was attempted on the above program. On Pass 1, the Assembler typed out BEGN DT and halted. The program listing indicated that BEGN was duplicated. The Symbolic Tape Editor program was read in with the binary loader and the fol lowing sequence of commands was issued. Note that the CTRL/FORM combination and RETURN are nonprinting. Assume that the programmer used these keys correctly. R 15L BEGN, 15C ADDR, 18L TAD BUFF /ADD NEXT NUMBER FROM BUFFER TAD BUFF /ADD NEXT NUMBER FROM BUFFER JMP BEGN NO, JUMP TO ADD NEXT NUMBER JMP ADDR NO, JUMP TO ADD NEXT NUMBER 18C 14 19L /THE NEXT SEVEN INSTRUCTIONS ARE THE PROGRAM ITSELF ADDR, TAD BUFF /ADD NEXT NUMBER FROM BUFFER ISZ BUFF /INDEX POINTER ISZ 1 CNTR /INDEX COUNTER. IS IT ZERO? JMP ADDR NO, JUMP TO ADD NEXT NUMBER DCA ANSR YES, DEPOSIT TOTAL IN 410 I p After typing P; , the complete program Iisting was typed out but it was not included here. As mentioned in Chapter 5, anything that is punched is typed. Punching out the text does not delete it. If an error occurs in punching, simple correct the error in the usual manner and punch out another tape. The corrected tape was assembled, and the output of Pass 1 yielded the following symbol table. 6-5 BEGN 600 MlO 616 621 CNTR 2HUN ADDR BUFF NO JUMP TO ADD NEXT NUMB ANSR YES DEPO TOTA IN 617 607 621 612 UA UA UA UA UA UA 613 UA UA UA There are three things to note. 1. CNTR and BUFF were assigned the same location. This indicates that a violation occurred. The program I isting indicates that the tags C NTR and BUFF are the only words in a statement. (Read the official PAL writeup section entitled "Language Details - 3(c)" to see that this is an illegal format.) 2. Symbolic address ANSR is an undefined address. not interpreted as such. This indicates that the tag ANSR was The program listing indicates that the programmer left out the comma. 3. Comments YES and NO were interpreted as tags. Words following interpreted as address. Observation of I is ting shows that the control character L was omitted. The following is the sequence of instructions used with the Symbolic Tape Editor to correct the listing (see next page). The listing as generated during punchout is also shown. It should be noted that this program is stil I incorrect, it assembled correctly as the symbol table shows. However, the program will not run as the programmer expects. This pro- gram wil I be corrected as an example using ODT in the next chapter. 6-6 /-7L /THE NEXT TWO REGISTERS ARE RESERVED FOR THE VARIABLES IN THE PROGRAM .=0028 29, 30C CNTR, 0 BUFF, 0 26L ANSR 410 26C ANSR, 410 26, 30L ANSR, 410 I /THE NEXT TWO REGISTERS ARE RESERVED FOR THE VARIABLES IN THE PROGRAM CNTR, 0 BUFF, 0 18L JMP ADDR NO, JUMP TO ADD NEXT NUMBER 18, 19C JMP ADDR /NO JUMP TO ADD NEXT NUMBER DCA ANSR /YES, DEPOSIT TOTAL IN 410 I p /ADD UP NUMBERS *600 BEGN, HLT /LOAD 200-207 WITH NUMBERS. HIT 11 CONTINUE 11 ON CONSOLE I /THE NEXT FIVE INSTRUCTIONS INITIALIZE THE ROUTINE CLA /CLEAR THE ACCUMULATOR TAD MlO /LOAD AC WITH -10 TO INTIALIZE TALLY DCA CNTR /DEPOSIT IN COUNTER CLA /CLEAR THE ACCUMULATOR TAD 2HUN /LOAD AC WITH FIRST ADDRESS IN BUFFER DACBUFF I /THE NEXT SEVEN INSTRUCTIONS ARE THE PROGRAM ITSELF ADDR, TAD BUFF /ADD NEXT NUMBER FROM BUFFER ISZ BUFF /INDEX POINTER ISZ I CNTR /INDEX COUNTER. IS IT ZERO? JMP ADDR /NO, JUMP TO ADD NEXT NUMBER DCA ANSR /YES, DEPOSIT TOTAL IN 410 HLT /STOP. HIT 11 CONTINUE 11 TO REPEAT PROGRAM JMP BEGN+l I /THE NEXT THREE REGISTERS CONTAIN THE CONSTANTS FOR THE PROGRAM MlO, 0-10 /NEGATIVE TALLY NUMBER 2HUN, 200 /FIRST ADDRESS IN BUFFER ANSR, 410 6-7 I /THE NEXT TWO REGISTERS ARE RESERVED FOR THE VARIABLES IN THE PROGRAM CNTR, 0 BUFF, 0 I $ BEGN MlO CNTR 2HUN ADDR BUFF ANSR 600 616 621 617 607 622 620 6-8 CHAPTER 7 INTRODUCTION TO THE PDP-8 OCTAL DEBUGGING TAPE A. GENERAL ODT is the debugging program for the PDP-8 computer which allows the programmer to correct binary tapes produced by the PAL Assembler from the console of the ASR-33 teleprinter. This program al lows the programmer to: 1. Print out the contents of the registers in his program in octal. 2. Insert correction in octal. 3. Run his program all under the control of ODT and punch out a corrected binary tape. Refer to the program writeup for a complete description. B. LOADING PROCEDURES 1. Load binary object tape from PAL into memory with binary loader. 2. Load ODT into memory with binary loader. 3. Start ODT at 1200 or 7200 depending on edition use. C. RESTRICTIONS 1. No more than one breakpoint can exist at one time. The last breakpoint specified will be the one that will be in effect when ODT runs the program. 2. A breakpoint may not be inserted at a JMS instruction. 3. The interrupt cannot be on when using ODT to debug a program. The interrupt portions of the program may be debugged using ODT. However, no ION instructions should be encountered in the debugging. If they are, they should be replaced temporarily by NOP instructions. 7-1 If a programmed halt is encountered in the object program, simple start ODT running again from the computer console and proceed as before. D. PUNCH COMMANDS The sequence of instructions for punching a program which has been debugged and is in core is as fol lows: 1. Turn Teletype to off line. Turn punch ON. Punch leader code (200) by depressing the CTRL, SHIFT, REPT. and@ keys simultaneously. 2. Turn Teletype on line, turn punch OFF. 3. Type in low address of memory area to be punched followed by a semicolon. Type in high address and then depress ALT MODE key. At this point, the computer will halt. 4. Turn on punch, depress CONTINUE on console and the specified area in memory will be punched out in binary format. If more areas in memory are to be punched, return to step 2. 5. After punching the last area in memory onto your tape, hit the asterisk (*) key. (Be sure to depress SH IFT to get into upper case.) A check sum block will be generated, and the computer will halt. 6. Turn Teletype off Iine; punch trailer {same as leader). 7. Turn Teletype on line, turn punch off and hit CONTINUE on the console. ODT is now waiting for the next command. If any characters other than those described in the program writeup are typed, ODT wi 11 respond with a ? and ignore the diaracter. E. PATCHING ODT does not al low the programmer to insert any instructions between existing instructions in the program. To insert instructions, add a patch into an available area in memory. Usually, patches are placed near the end of the current page in memory. 7-2 To insert a patch fol lowing a given instruction, replace that instruction with a jump to an available place on the same page. The displaced instruction is the first instruction written in the patch. The desired instructions for the patch are inserted fol lowed by a jump back to the correct location in the main program. F. EXAMPLE Suppose the program for adding numbers is typed in the following manner. During assembly, no error indicators were typed out, but when the assembled program was read in, the computer ran approximately 2 seconds and stopped. The correct answer did not appear in its proper location. The symbol print from assembly is shown with a guided example for using ODT to examine, correct, and punch out the correct program. The programmer should return and make the corresponding corrections on the symbolic tape, then reassemble. Th is gives a permanent copy of the corrected program without wasted core space and execution time. /ADD UP NUMBERS *600 BEGN, HLT /LOAD 200-207 WITH NUMBERS. HIT 11 CONTINUE 11 ON CONSOLE I /THE NEXT FIVE INSTRUCTIONS INITIALIZE THE ROUTINE CLA /CLEAR THE ACCUMULATOR TAD MlO /LOAD AC WITH -10 TO INITIALIZE TALLY DCA CNTR /DEPOSIT IN COUNTER CLA /CLEAR THE ACCUMULATOR TAD 2HUN /LOAD AC WITH FIRST ADDRESS IN BUFFER DCABUFF I /THE NEXT SEVEN INSTRUCTIONS ARE THE PROGRAM ITSELF ADDR, TAD BUFF /ADD NEXT NUMBER FROM BUFFER ISZ BUFF /INDEX POINTER ISZ I CNTR /INDEX COUNTER. IS IT ZERO? JMP ADDR /NO, JUMP TO ADD NEXT NUMBER DCA ANSR /YES, DEPOSIT TOTAL IN 410 HLT /STOP. HIT 11 CONTINUE 11 TO REPEAT PROGRAM JMP BEGN+l I /THE NEXT THREE REGISTERS CONTAIN THE CONSTANTS FOR THE PROGRAM 7-3 MlO, 2HUN, ANSR, 0-10 200 410 /NEGATIVE TALLY NUMBER /FIRST ADDRESS IN BUFFER I /THE NEXT TWO REGISTERS ARE RESERVED FOR THE VARIABLES IN THE PROGRAM CNTR, 0 BUFF, 0 I $ BEGN MlO CNTR 2HUN ADDR BUFF ANSR 600 616 621 617 607 622 620 The program as shown ran for about 2 seconds and halted. The correct answer from the addition was not found in location 410. ODT was read in using the binary loader and was started in 1200. The program I isting and symbol table printout were used constantly during the debugging process. First, the initializing routine was checked to make sure the counters were initialized correctly. The breakpoint was inserted at locations 607 and ODT started the program running at location 601 • Note that whatever ODT typed is underlined on the printout (the under1ining was done by the author-not ODT). 607 11 601' 0607) 0200 The breakpoint typeout indicated that the AC contained 200. This is incorrect because the DCA command should have cleared the accumulator. Thus, location 606 was opened. 606/ 622/ 0000 3222 0000 Finding it 0000, the listing was observed. The command DCA was not properly delimited. Then the instruction 3222 (DCA BUFF) was deposited and the register closed. Register 622 (BUFF) was opened and was not initialized. The command to go is given with the first breakpoint still in. 7-4 601 1 0607) 0000 622/ 621/ 0200 7770 The registers are now correctly initialized. A new breakpoint is inserted to trap the program just before the jump to add the next number. The programmer knew that the numbers in location 200-207 were all 0001 and ex- pected the AC to contain l when the trap occurred. The results are: 612 11 0612) 0200 The programmer examined the listing and saw why the AC was 0200 instead of 0001; he should have used the instruction TAD I BUFF instead of TAD BUFF. Thus he set bit 3 of the instruction to a l using ODT. 607/ 1222 1622 Then the programmer checked to see if the counter indicated that one number had been added. It did not! Scrutiny of the Iisting indicated that he had made bit 3 to a l in this instruction. He had confused the use of indirect addressing. This is a common error frequently done by an inexperienced programmer. The instruction register was opened and modified as shown be low. 621/ 611/ 7770 2621 2221 At this point, the breakpoint was cancelled and the program restarted. The computer halted immediately instead of running for two seconds. ODT was restarted at 1200 and location 410 was opened. It sti II contained the incorrect answer. II 601 1 410/ 3570 7-5 The breakpoint was inserted again at the JMP instruction and the program restarted by ODT. The sequence of proceed commands indicated that the routine was adding the numbers correctly indicating the programmer concluded that the deposit instruction was wrong. The listing was observed and the programmer saw that DCA ANSR should have been DCA I ANSR-misuse of indirect addressing. Address ANSR was opened and, the answer was found there. The correct indirect reference and pointer were inserted and the registers closed. 612 11 601' 0612) 0001 . I 0612) 0002 0612) 0003 . I 0612) 0004 0612) 0005 613/ 3220 3620 620/ 0010 410 The breakpoint was cancelled and the proceed command given. The computer halted, it was restarted at 1200 and register 410 opened. The correct answer was contained therein. The sequence of command is shown below: II 4 l 0/ 00 l 0 0000 The answer location was cleared and the program rerun and checked, fol lowed by the command sequence to punch and the contents of the corrected program. Only the low and high address observed on the printout. 600;622F<: i -*<*?&> The binary tape was preserved, and the symbolic tape was corrected using the Symbolic Tape Editor. 7-6 G. SUMMARY OF PREPARATION AND CORRECTION OF PROGRAMS At this point, the programmer may be confused concerning the use of each of the three main programs-PAL, Symbolic Tape Editor, and ODT. The fol lowing flow diagram illustrates the relationship between the programs and the place of each in the preparation of correct programs. TYPE UP SYMBOLIC PROGRAM WITH ASR-33 OFF LINE OR WITH THE SYMBOLIC TAPE EDITOR CORRECT SYMBOLIC TAPE USING THE SYMBOLIC TAPE EDITOR. PUNCH OUT CORRECT TA PE ASSEMBLE THE SYMBOLIC TAPE WITH PAL YES FIND AND CORRECT THE ERROR IN THE BINARY PROGRAM USING THE OCTAL DEBUGGING TAPE LOAD THE BINARY OBJECT TAPE FROM ASSEMBLER INTO MEMORY PUNCH OUT THE CORRECT BINARY TAPE NO FINISHED 7-7 CHAPTER 8 INPUT-OUTPUT INSTRUCTIONS AND A. ROUTINES GENERAL An introduction to the elements of the input-output control is given in Section B, Chapter l of the PDP-8 Handbook. The programmer doesn 1 t need to know the function of each of the elements in the control for elementary programming applications. Further information on the control may be found in the PDP-8 Maintenance Manual. The PDP-8 is capable of servicing 64 different 1/0 devices, each requiring three commands. To the person watching the 64 1/0 devices, the computer is hand I ing al I 64 devices simultaneously. However, to the programmer, the computer is handling each device independently and checking the status of all the others and servicing them, if necessary. If each device only requires one command to service it, the PDP-8 can handle up to 192 separate devices. The 1/0 instructions and suggested program sequences for each device are given in Section B of the PDP-8 Handbook. In this workbook, the printer/punch, reader/keyboard, high-speed reader, and high-speed punch will be discussed. The techniques used with 1/0 devices will be directly applicable to any equipment available on the PDP-8. The specifications and commands for al I devices is described in F-85. This section will deal primarily with the general 1/0 device and its programming techniques. l. Device Flag Al I 1/0 devices have a device flag. This flag indicates the state of the device. If the flag is set (a l) the device is free; that is, it can be used if it is an output device, or has information (if it is an input device). If the flag is cleared (a O) the device is busy; that is, currently not available as a result of issuing 'it a command (if it is an output device) or not having any information (if it is an input device). 8-1 The figure below illustrates the device flag. [ D1 l Dz [ D3 PDP-8 } ... 1 J -._,. Fz } .... F3 F1 w ...... ~ • 1' INTERRUPT Note that the device flags are physically located in the control processor and that each device, whether input or output has a unique flag. All the flags, however, are wired to the interrupt system. This is described in more detail in a later chapter of th is workbook. Each flag has two basic instructions associated with it. l. Skip of the flag is set. 2. Clear the flag. A separate device instruction is furnished to complete the action 3. Operate the device. Thus if the programmer initially clears a device flag and operate the device, the flag associated with that device will be automatically set to a l when the device action is complete. Usually the skip instructions are immediately followed by jump instructions to Iisten or wait for a flag to be set. 8-2 Example: CLR A, /CLEAR A DEVICE FLAG TAD IOT SKP JMPA /EXECUTE AN OUTPUT COMMAND /SENSE DEVICE FLAG /WAIT /CONTINUE The 1/0 commands can be microprogrammed to include the clearing operation in the output IOT command. When computer power is turned on, the flags can go to either a set or cleared state. Therefore, the flags should be cleared first (a must for interrupt programs). There isn't any rule for the programmer to use to determine when to examine a flag or wait for a device; he must use his judgment. Situations may occur where computation could proceed while waiting for a device (storing or examining characters while reading paper tape), then the device waiting time can be utilized, as ii lustrated below in flow chart form: Example 1: START STOP 8-3 Example 2: a. Problem Write a program to type out the characters corresponding to the codes for 308 letters stored in consecutive locations starting at l 000 8 . The program starts at location 600. Use a flow diagram. b. Flow Diagram START INITIALIZE REGISTER AND TELEPRINTER LOAD AC WITH CODE FOR CHARACTER JUMP TO SUBROUTINE TO TYPE IT OUT PRINT CHARACTER IN AC NO RETURN TO GET NEXT CODE RETURN TO MAIN PROGRAM NO HALT 8-4 c. Program Listing /ROUTINE TO TYPE 30 CHARACTERS *600 BEGN, HLT /LOAD LOCATIONS IN TABLE WITH CODES FOR CHARACTERS. HIT 11 CONTINUE 11 I /THE FOLLOWING 10 INSTRUCTIONS INITIALIZE PROGRAM AND PRINTER MECHANISM CLA /CLEAR AC TAD CR /LOAD AC WITH CODE FOR CARRIAGE RETURN JMS TYPE /TYPE IT OUT IN SUBROUTINE TAD LF /LOAD AC WITH CODE FOR LINE FEED JMS TYPE /TYPE IT OUT CMA /LOAD AC WITH 11 TABL-l 11 FOR TAD TABL /AUTO-INDEX REGISTER DCA Z IRl /STORE IN LOCATION 11 TAD M30 /INITIALIZE CHARACTER COUNTER DCA CNTR I /MAIN PROGRAM GET, TAD I Z IRl /LOAD AC WITH CODE FOR CHARACTER JMS TYPE /TYPE IT OUT ISZ CNTR /INDEX COUNTER. IS IT ZERO? JMP GET /NO, RETURN TO GET NEXT CHARACTER HLT /YES, FINISHED. HIT 11 CONTINUE 11 TO REPEAT PROGRAM JMP BEGN+l I /TYPEOUT ROUTINE TYPE, 0 /LINKING REGISTER TO MAIN PROGRAM TLS /TYPE OUT CHARACTER IN AC TSF /IS THE PRINTER FLAG A l? JMP .-1 /NO, CHECK IT AGAIN. CHARACTER NOT YET TYPED CLA /YES, CHARACTER TYPED. CLEAR AC & RETURN TO PROGRAM JMP I TYPE I /CONSTANTS AND VARIABLES TABL, 1000 /INITIAL ADDRESS OF TABLE OF CHARACTERS M30, 0-30 /2 1 S COMPLEMENT OF 30 FOR COUNTER CR, 215 /CODE FOR CARRIAGE RETURN LF, 212 /CODE FOR LINE FEED CNTR, 0 /CHARACTER COUNTER I /USE AN AUTO-INDEX REGISTER WHEN SCANNING SEQUENTIAL LOCATIONS *11 IR l, 0 I $ 8-5 Example 3: a. Problem Write a routine which will accept characters typed on the keyboard. The code for each character is to be stored consecutively in a table whose Iimits are set on the switch register (two settings required-upper and lower). When the codes have filled the table, the computer is to type out the word "BURP:" and halt with all ones in the AC. b. Flow Diagram START INITIALIZE REGISTER SET UPPER AND LOWER LIMITS OF TABLE JUMP TO SUBROUTINE TO LISTEN FDR CHARACTER NO INFORMATION READY READ INTO AC STORE IT AWAY IN TABLE NO TYPEOUT LETTERS CLEAR AND COMPLEMENT AC HALT 8-6 c. Program Listing /TYPEIN ROUTINE *400 /THE FOLLOWING INSTRUCTIONS INITIALIZE THE ROUTINE STRT, KCC /CLEAR AC AND KEYBOARD FLAG LODl, HLT /SET INITIAL ADDRESS OF TABLE. HIT CONTINUE LAS /LOAD AC WITH SWITCH REGISTER DCA TOP /STORE INITIAL ADDRESS IN "TOP" LOD2, HLT /SET FINAL ADDRESS OF TABLE. HIT CONTINUE LAS /LOAD AC WITH SWITCH REGISTER CIA /COMPLEMENT AND INDEX FOR FUTURE USE DCA MBOT /STORE IN 11 MBOT 11 INIT, CMA /INITIALIZE AUTO-INDEX REGISTER TAD TOP /FOR STORING CODES. DCA Z IRl TAD BRPT /INITIALIZE AUTO-INDEX REGISTER FOR TYPING "BURP!" DCA Z IR2 /INITIALIZE TELEPRINTER POSITION AT "CRLF" JMS Z CRLF /MAIN PROGRAM TYPI, KSF /IS THE KEYBOARD FLAG A 1 JMP .-1 /NO, CHECK IT AGAIN KRB /YES, CODE READY. LOAD INTO AC TLS /TYPE IT OUT DCA I Z IRl /STORE IT AWAY IN TABLE Z IRl CKCK, TAD /LOAD AC WITH POINTER TAD MBOT /ADD 2'S COMPLEMENT OF BOT. OF TABLE SPA /IF ANSWER IS NEGATIVE, TABLE NOT FULL. GET NEXT CHAR. JMP TYPI I /THIS PORTION OF MAIN PROGRAM TYPES OUT INDICATION THAT TABLE IS FULL BURP, TAD I Z IR2 /TABLE FULL. LOAD AC WITH CODE FOR TYPEOUT JMS X TYPO /TYPE IT OUT TAD MEXC /ADD 2'S COMPLEMENT OF 11 ! 11 TO AC SZA C LA /IS ANSWER ZERO? JMP BURP /NO, WORD NOT TYPED YET JMS Z CRLF /YES, LAST CODE WAS 11 ! 11 • INITIALIZE TELEPRINTER C LA CMA /SET AC TO ALL ONES. HLT /STOP. RESTART BY HITTING "CONTINUE" JMP STRT I /CONSTANTS AND VARIABLES TOP, 0 MBOT, 0 /BRPT = THIS LOCATION BRPT, BRPT 302 /B 325 /U 8-7 /R /P 322 320 ;: 241 MEXC, 0-241 /2 1 S COMPLEMENT OF II : 11 I /SMALL, OFTEN-USED SUBROUTINES PLACED ON PAGE 0 *40 CRLF, 0 TAD JMS CLA TAD JMS CLA JMP TYPO, LF TYPO /TYPE OUT LINE FEED I CRLF /RETURN TO MAIN PROGRAM /LINKING REGISTER FOR SUBROUTINE 0 TSF JMP TLS JMP CR, LF, CR TYPO /LINKING REGISTER FOR SUBROUTINE /TYPE OUT CARRIAGE RETURN . -1 I TYPO 215 212 I /LOCATIONS FOR AUTO-INDEX REGISTERS *ll IRl I 0 IR2, 0 $ Example 4: Rotation and Masking in Packing and Unpacking a. Problem Write a routine to accept octal numbers typed on the keyboard as on absolute address. Follow the address by a slash (/). The routine will then type four spaces fol lowed by the contents of the specific address. Al I addresses are assumed to be right justified. If the address specified is too large or if any character other than 0-7 or/ is typed, the routine wil I type a question mark and wait for the next address. 8-8 b. Flow Diagram START INITIALIZE REGISTERS AND TELEPRINTER POSITION JUMP TO SUBROUTINE TO LISTEN FOR CHARACTER TYPE CHARACTER BACK OUT WHEN ARRIVES LOAD AC WITH CODE FOR'?' TYPE IT OUT TYPE OUT FOUR SPACES INITIALIZE COUNTER FOR UNPACKING LOAD REGISTER INDICATED BY ADDRESS REGISTER STORE AWAY IN TEMPORARY LOCATION NO LOAD TEMPORARY LOCATION ROTATE ONCE MORE BECAUSE OF LINK MASK OFF BITS 0-8 MASK OFF BITS 4-8 STORE AWAY IN TEMPORARY LOCATION LOAD PARTIALLY ASSEMBLED CODE ADD IN 260 ROTATE 3 BINARY BITS TO THE LEFT TYPE IT OUT ADD TEMPORARY LOCATION TO IT STORE IN ADDRESS REGISTER NO 8-9 c. Program Listing /OCTAL PRINT - SINGLE LOCATION *1000 /THE FOLLOWING INSTRUCTIONS INITIALIZE THE ROUTINE INIT, TLS /SET TELEPRINTER FLAG KCC /CLEAR AC AND KEYBOARD FLAG JMS Z CRLF /INITIALIZE TELEPRINTER DCA HOLD /DEPOSIT ZEROS IN LOCATION TO HOLD ADDRESS TAD M5 /INITIALIZE COUNTER TO COUNT NUMBERS IN THE ADDRESS DCA CCTR I /THE FOLLOWING ROUTINE TESTS INCOMING CHARACTERS USN, JMS Z TYPI /JUMP TO LISTEN FOR INCOMING CHARACTER PROC, DCA TEM /STORE IT AWAY FOR REFERENCE TAD TEM /LOAD IT INTO AC TAD SLSH /ADD NEGATIVE CODE FOR SLASH SNA CLA /IS THE RESULT ZERO? JMP SPCR /YES, CHARACTER WAS 11/ . 11 JUMP TO TYPE SPAC TAD TEM /NO, CHECK TO SEE IF TAD M260 /CODE IS LESS THAN 260 SPA CLA /IS SUM GREATER THAN ZERO OR EQUAL TO ZERO? 2LTL, JMP Z TYP? /NO, CODE< 260. TYPE"?" TAD TEM /YES, GET CODE AGAIN TAD M267 /CHECK TO SEE IF CODE SMA SZA CLA/IS GREATER THAN 267? 2BIT, JMP Z TYP? /YES, CODE> 267 ISZ CCTR /NO, INDEX CHARACTER CNTR. HAVE 5 COME IN? SKP /NO, SKIP NEXT INSTRUCTION 2MNY JMP z TYP? /YES TYPE II? II TAD TEM /GET CODE AGAIN AND MASK /MASK OFF BITS 9-8 DCA TEM /STORE SINGLE OCTAL DIGIT IN TEM TAD HOLD /LOAD ASSEMBLED WORD RTL /ROTA TE THREE BITS TO THE LEFT RAL TAD TEM /ADD IN LA TEST NUMBER DCA HOLD /STORE IN ADDRESS REGISTER. RETURN FOR NEXT CHARACTER JMP USN I I I /ROUTINE TO TYPE OUT FOUR SPACES SPCR, TAD M4 /LOAD AC WITH MINUS 4 DCA SCTR /STORE IT IN SPACE COUNTER TAD SPCD /LOAD AC WITH SPACE CODE JMS Z TYPE /TYPE IT OUT ISZ SCTR /INDEX SPACE COUNTER. IF NOT ZERO, TYPE ANOTHER SPACE JMP .-3 8-10 I /ROUTINE TO UNPACK AND TYPE OUT DESIRED REGISTER UNPK, TAD M4 /INITIALIZE COUNTER TO TYPE OUT DCA CCTR /4 LETTERS TAD I HOLD /ADD CONTENTS OF EFFECTIVE ADDRESS ROLO, RTL /ROTA TE 3 PLACES TO THE LEFT RAL DCA TEM /STORE RES UL TANT WORD TAD TEM /LOAD IT AGAIN RAL /ROTATE ONCE MORE BECAUSE OF LINK MSKR, AND MASK /MASK OFF ALL BUT DESIRED OCTAL DIGIT TAD NMCD /ADD IN 260 TO MAKE IT CODE FOR NUM JMS Z TYPE /TYPE IT OUT TAD TEM /ADD PARTIALLY ROTATED WORD ISZ CCTR /INDEX COUNTER HAVE WE TYPED 4 LETTERS JMP ROLO /NO, JUMP BACK AND TYPE OUT NEXT CODE JMP INIT+l /JUMP BACK TO INITIALIZE ROUTINE /CONSTANTS AND VARIABLES NMCD, 260 /CODE FOR NUMBERS HOLD, 0 /REGISTER TO HOLD ASSEMBLED ADDRESS CCTR, 0 /VARIABLE FOR CHARACTER COUNTER M5, 0-5 /CONSTANT FOR CHARACTER COUNTER MASK, 7 /MASK TO LEAVE ONLY l OCTAL CODE M267, 0-267 /NEGATIVE VALUE FOR UPPER LIMIT OF NUMBERS M260, 0-260 /NEGATIVE VALUE FOR LOWER LIMIT OF NUMBERS TEM, 0 /TEMPORARY LOCATION SLSH, 0-257 /NEGATIVE CODE FOR SLASH SCTR, 0 /VARIABLE LOCATION FOR COUNTING SPACES M4, 0-4 /TALLY NUMBER TO COUNT 4 SPACES SPCD I 240 /CODE FOR SPACE I *40 /SUBROUTINE TO TYPEOUT CHARACTER TYPE, 0 /LINKING REGISTER TO MAIN PROGRAM TSF /IS PRINTER FLAG A l? JMP .-1 /NO, CHECK IT AGAIN TLS /YES, TYPE OUT NUMBER IN AC CLA CLL /CLEAR AC AND LINK, RETURN TO MAIN PROGRAM JMP I TYPE I /SUBROUTINE TO LISTEN FOR KEYBOARD TYPI, 0 /LINKING REGISTER TO MAIN PROGRAM KSF /IS KEYBOARD FLAG A l? JMP .-1 /NO, CHECK IT AGAIN KRB /YES I READ KB IN AC TLS /TYPE IT BACK OUT. RETURN TO MAIN PROGRAM JMP I TYPI I /THIS ROUTINE TYPES A QUESTION MARK AND JUMPS TO INITIALIZE ROUTINE 8-11 QUMK TAD z TYPE /TYPE II ? 11 JMS JMP I AGIN /JUMP BACK TO INITIALIZING ROUTINE AGIN, INIT+l /POINTER TO MAIN PROGRAM QUMK, 277 /CODE FOR QUESTION MARK TYP?, I /THIS ROUTINE TYPES A CARRIAGE RETURN-LINE FEED COMBINATION CRLF, 0 /LINKING REGISTER TAD CR /LOAD AC WITH CODE FOR CARRIAGE RETURN JMS Z TYPE /TYPE IT OUT TAD LF /LOAD AC WITH CODE FOR LINE FEED JMS Z TYPE /TYPE IT OUT JMP I CRLF /RETURN TO MAIN PROGRAM CR, 215 212 LF I $ Example 5: a. Write a tape duplicator which wil I read characters from a paper tape and store them in a word storage block starting at 400 8 and ending at 7000 8 • At the same time, the punch should be punching the contents of the storage. Use the 1/0 time available while punching to read as many characters as possible; thus operating punch and reader at full speed. Devise a method of determining when the end of the tape has been reached. The solution to this example shown on the fol lowing pages does not use the program interrupt. This type of programming simply illustrates how one can do a large number of program steps while a relatively slow 1/0 device is operating. In this solution, approximately 5 characters are read from paper tape and stored in memory while one character is being punched. Likewise, the routine for determining when the end of the tape has been reached is operating while information is being obtained from the reader. The end-clock routine for determining the end of the tape is as follows. Each time the computer finds that the reader flag is a 0, it indexes a counter before returning to check the flag again. The counter is preset to overflow after looping approximately 30 mil Iiseconds in that sequence of instructions. only 3.3 milliseconds to read a line of tape. It usually takes If a feed hole doesn't appear under the reader head, the flag is not set to a 1 and the counter indexes until overflow. The computer then assumes the end of the tape has been reached. 8-12 b. Flow Diagram START INITIALIZE ALL REGISTERS CHANGED DURING P~OGRAM DUPLICATE NEXT BLOCK OF TAPE SET UP A COUNTER TO INDICATE END OF TAPE PUNCH TWO FOLDS OF BLANK TAPE (400 LINES) NO READ READER BUFE:ER AND STORE CODE IN BUFFER AT 200 CUT READER PORTION OUT OF PROGRAM PUNCH IS READY. PUNCH OUT NEXT CHARACTER END-OF-TAPE YES YES HALT 8-13 c. Program Listing /TAPE DUPLICATOR FOR HIGH SPEED READER AND PUNCH ON PDP-5 *200 BEGN, HLT /LOAD TAPE TO BE DUPLICATED INTO READER. HIT CONTINUE. I /THE FOLLOWING ROUTINE PUNCHES 400 LINES (2 FOLDS) OF LEADER LEDR, CLA /SET UP COUNTER TO PUNCH 400 (OCTAL) TAD M400 /LINES OF LEADER DCA LCTR PUNL, PLS /PUNCH OUT LEADER (AC=O) PSF /CHECK TO SEE IF PUNCH FLAG IS 1 JMP .-1 /NO, CHECK IT AGAIN ISZ /YES, INDEX LEADER COUNTER. SKIP ON OVERFLOW LCTR JMP PUNL I /INITIALIZING ROUTINE INIT, TAD BUFF /INITIALIZE AUTO-INDEX REGISTERS DCA Z IRl TAD BUFF DCA Z IR2 TAD RDIN /INITIALIZE PROGRAM TO INCLUDE READER LOOP DCA CHGl TAD RDIN DCA CHG2 I /MAIN PROGRAM READ, TAD MG DCA ECHK RFC RSF SKP JMP .+4 ECHK TCHK, ISZ JMP .-4 JMP RSTP RRB DCA I Z IRl BCHK, TAD Z IRl TAD MEND SNA CLA RSTP JMP PSF PUN, READ CHGl I JMP TAD I Z IR2 PLS CLA /SET UP COUNTER TO INDICATE END OF TAPE /FETCH FIRST CHARACTER /CHECK TO SEE IF READER FLAG IS A l /NO, CHECK IF END OF TAPE /YES, JUMP TO READ READER BUFFER /INDEX ENDCHECK. IS IT ZERO? /NO, CHECK READER FLAG AGAIN. /YES, CUT READER PORTION OUT OF PROGRAM. END OF TAPE /READ READER BUFF /STORE IN BUFFER /LOAD READER POINTER INTO AC /ADD NEGATIVE ADDRESS OF END OF BUFFER /ARR THE TWO NUMBERS EQUAL? /YES, JUMP TO STOP READER. BUFFER FULL /NO, IS THE PUNCH AVAILABLE? /NO, JUMP BACK TO READ OR PUNCH NEXT CHARACTER /YES, PUNCH READY. GET NEXT CODE /PUNCH IT OUT 8-14 TAD Z IR2 /LOAD AC WITH PUNCH POINTER TAD MEND /COMPARE WITH LAST LOC. IN BUFFER SZA CLA /ARE THE TWO NUMBERS EQUAL? JMP .+5 /NO, BUFFER NOT PUNCHED YET. TAD ECHK /YES, LOAD AC WITH END-OF-TAPE COUNTER SNA CLA /IS IT ZERO? JMP STOP /YES, END OF TAPE REACHED. JMP INIT /NO, MORE TAPE TO DUPLICATE TAD Z IR2 /LOAD AC AGAIN WITH PUNCH POINTER TAD M400 /COMPARE WITH BEGINNING OF BUFFER SNA CLA /ARE THE TWO NUMBERS EQUAL? JMP READ /YES, READ NEXT CHARACTER. ITS FIRST TIME TAD Z IR2 /LOAD AC ONCE MORE WITH PUNCH POINTER CMA IAC /COMPARE WITH READER POINTER TAD Z IRl SZA CLA /ARE THE TWO NUMBERS EQUAL? CHG2, JMP READ /NO, JUMP TO READER OR PUNCH LOOP STOP, CLA CMA /YES, DUPLICATION COMPLETE HLT /HALT WITH ALL ONES IN THE AC JMP LEDR /BY HITTING CONTINUE, YOU MAY DUPLICATE ANOTHER TAPE I /FOLLOWING ROUTINE CHANGES ALL 11 JMP READ 1 S11 TO 11 JMP PUN 1 S11 /TO ALLOW PUNCH TO CATCH UP WITH READER. THEY ARE REINITIALIZED EACH /TIME PUNCH HAS PUNCHED OUT THE BUFFER RSTP, CLA /READER STOP SEQUENCE TAD PNIN /LOAD INSTRUCTION 11 JMP PUN 11 DCA CHGl /DEPOSIT IN LOCATIONS WHICH CHANGE TAD PNIN /WHEN READER FILLS BUFFER DCA CHG2 JMP PUN /VARIABLES /COUNTER TO DETERMINE END OF TAPE ECHK, 0 /COUNTER TO DETERMINE END OF LEADER LCTR, 0 I /CONSTANTS M400, 0-400 BUFF I 377 END, 7000 MEND, 1000 PININ, JMP PUN RDIN, JMP READ MG, 0-1000 /CONSTANl TO l NITIALIZE LEADER COUNTER /CONSTANT INDICATING BEGINNING OF BUFFER /END OF BUFFER /TW0 1 S COMPLEMENT OF END OF BUFFER /INSTRUCTION TO CHANGE 11 JMP READ 11 /INSTRUCTION TO CHANGE 11 JMP PUN 11 /CONSTANT TO INITIALIZE END OF TAPE COUNTER I * 11 /DEFINITION OF AUTO-INDEX REGISTERS. IRl I 0 /READER POINTER IR2, .0 /PUNCH POINTER I $ 8-15 REVIEW QUESTIONS - CHAPTER 8 Write routines for the following problems. All routines should be in PDP-8 Assembler language and symbolic addressing should be used. l. Type out in octal the contents of memory, starting and ending at the locations of your choice. Type two columns, the left representing the address of the location and the right representing the contents of that location. 2. Write a routine which will accept octal instructions typed on the keyboard and store them in memory. The starting address for the sequence of instructions is determined by typing an A, the absolute octal address, and a carriage return. The following Iist of 4-digit instructions {each terminated by CR) will be inserted consecutively in memory unti I another A is hit to specify a new starting address. To make the program useful type an E, erasing al I numbers typed after the preceding carriage return and enabling correction of errors in typing. 3. Write a routine which will punch out on paper tape the contents of memory starting and ending as specified by the operator. Be sure to put on the tape the starting address of the block and a suitable termination word that indicates the end of tape. 4. Write a routine to read from paper tape and store in memory the information punched by the above program (#3). 8-16 CHAPTER 9 PROGRAM A. INTERRUPT FEATURE OF THE PDP-8 SYSTEM GENERAL The program interrupt feature of the PDP-8 computer al lows a logic I ine to interrupt the program that is running, to sense certain alarm conditions or event signals, or to service an 1/0 device. This feature speeds up processing of 1/0 data, because many computer instructions may be performed while waiting for an 1/0 device to become ready again. Also, the time may be effectively shared between two, three, four, five or more separate devices. When an interrupt occurs, the contents of the program counter (the current address in the main program) are automatically stored in memory location 0, and an interrupt begins by forcing the computer to execute a program beginning at location 0001. The above operations occur automaticaly in 3.2 microseconds. To avoid destruction of the auto-index registers, the instruction in 0001 should be a jump to a interrupt servicing routine. The interrupt system is turned OFF automatically when the interrupt is initiated, and therefore must be turned ON again by the program immediately before returning to the main program. After the device causing the interrupt has been examined and serviced by a subroutine, the computer should return to the main routine by the execution of a JMP I Z 0000. If another interrupt request is waiting, it will be accepted immediately. If there is a second interrupt request while the computer is servicing the first request, the second request is ignored unti I the first request hos been satisfied. However, the device flag is set and may be checked by the servicing routine before returning to the main program. It is good practice to examine the program flags for other devices before leaving the interrupt routine. This should be done prior to turning on the interrupt and executing the JMP I Z 0000. The two instruction associated with the interrupt system are: ION IOF 6001 Enable the interrupt system Disable the interrupt system 6002 9-1 B. TYPES OF INTERRUPTS There are two kinds of interrupts: data break and program interrupt. If the computer gets a request for these two at the same time, a priority circuit wil I handle the data break request before the program request. If two or more program interrupts occur at the same time, the interrupt is initiated; and with program examination of the device flags, a priority of 1/0 devices can be assigned. l• Data Break The data break feature al lows high-speed transfer of data from an 1/0 device such as a magnetic tape unit, a drum, or a microtape unit. The data break is controlled by hardware in the control unit for the specific 1/0 device. The programmer does not need to be concerned with the handling of the data, this is governed by the control unit. This control unit will steal one cycle per data transfer from the computer while it is executing the program and will deposit the data in or fetch data from memory, but wil I not disturb the arithmetic registers or the program counter. 2. Program Interrupt In general applications, the program interrupt is used more frequently than the data break. It is particularly useful in hand I ing data from the relatively slow 1/0 devices such as the high-speed reader, high-speed punch or teleprinter. It al lows the main program to run continuously, and the program wi II be interrupted only when a data transfer is ready. If data is coming into the computer, it is stored at this time, and instructions are modified to take care of the next input of data. If data is going from the machine, the instructions are modified to select the correct data for the next output. C. USE OF THE PROGRAM INTERRUPT At the beginning of a program using the interrupt, the programmer should clear al I the device flags connected to the computer. The state of the flags cannot be assumed, and spurious interrupts might occur if this precaution were not taken. 9-2 The following program will illustrate a typical use of the system routine, using the highspeed punch and reader. The 1/0 flags will be tested to see which 1/0 device should be handled. Each of the subroutines, that handle the equipment returns to the interrupt routine and continues to check flags to assure that another device further down in priority has not requested an interrupt during the 1/0 handling routine. If such a device has set a flag, it will be serviced at this time before the AC and link are restored and the interrupt system is enabled. After the interrupt system is turned on, the computer should return immediately and al I flags checked again. This is not the only interrupt routine which can be used. Some programmers may prefer to jump out of the interrupt routine without checking any other flags. Either procedure may be used. ILLUSTRATION OF INTERRUPT AND SYSTEM ROUTINE *0 0 JMP I 2 1000 *1000 INTR EXIT, REDR, DCA TEMP RAL DCA LINK RSF SKP JMS REDR PSF SKP JMS PUN TAD LINK RAR CLL TAD TEMP ION JMP I Z 0 0 CLA JMP I REDR PUN, 0 CLA JMP I PUN /STORE AWAY AC /ROTA TE LEFT /STORE AWAY LINK /CHECK READER FLAG /SERVICE READER /CHECK PUNCH FLAG /SERVICE PUNCH /RESTORE THE LINK /RESTORE AC /ENABLE INTERRUPT SYSTEM /RETURN TO MAIN PROGRAM /THIS SUBROUTINE SHOULD PROCESS /DATA FROM READER IN WHATEVER /WAY PROGRAMMER DECIDES AND /SHOULD CHANGE INSTRUCTIONS FOR /MANIPULATION OF NEXT INPUT. /THIS SUBROUTINE SHOULD GET /DA TA TO BE PUNCHED OUT, AND /SHOULD CHANGE INSTRUCTIONS /FOR NEXT OUTPUT. 9-3 D. CRITERIA FOR DETERMINING TIMING AND PRIORITY l. Timing In writing an interrupt program for a real-time application, there are two important parameters which must be determined: the frequency of data transfer to or from each device and the stabi Iity of data to or from each device. The latter consideration is seldom critical because of the buffers on each standard device. However, in some applications, (processing of radar signals) it may be important. The first general rule may be phrased as: The time of the processing subroutine for all devices must be shorter than the time between the data transfers from the higher frequency device. If this condition is not met, information may be lost from the device. To minimize subroutine time, the programmer may choose to use JMP instructions in servicing devices rather than JMS instructions and JMP back at end of the subroutine rather than JMP I. 2. Priority In the standard interrupt foci I ity of the PDP-8, the programmer has control over the sequence in which the various devices are checked. The second general rule is: Check the 1/0 devices in order of frequency. The faster devices should be checked first. Again, if the stability time of the data is important, this should be considered. 9-4 CHAPTER 10 PROGRAM A. LIBRARY: SUBROUTINES AND PROGRAMS GENERAL It is often necessary to repeat a group of instructions during the execution of a program. Do not write out the instruction each time a function is needed. Instead, the instructions needed are written once and the main program transfers to this group of instructions each time they are required. This group of instructions is cal led a subroutine. These subroutines normally perform basic functions and may be used in the solution of many problems. A great deal of the programmer's time and effort may be saved by using the subroutines which are available from the PDP-8 Library. By using these subroutines and the cal I ing sequence as required, the programmer can write a program very quickly to accomplish a rather complex sequence of operations. as well as listings of each subroutine. The symbolic tapes of the subroutines are supplied, The tapes may be appended to the main program, and any page specifications and address assignments may be es tab Iished by the programmer using the Symbolic Tape Editor. Programs are constantly being added to the library. The subroutines and programs listed on the following pages represent only a partial list of those presently available. The requests and needs of the customer are often the criterion to write a program for the I ibrary. B. USE OF THE SUBROUTINES l• Assembly Most of the subroutines in the Iibrary have an origin setting at the beginning and a $ delimiter at the end of the tape. At the time of assembly, it may be necessary for these to be removed from the final symbolic tape. l 0-1 With the Symbolic Tape Editor, the operator can easily append the subroutines onto the main program and the Editor wil I punch out the entire program. The text storage area of the Editor holds over 64 10 instructions (one half memory page) with comments. If the program is longer than one half memory page, the use of the form feed block on the symbolic tape will ease the job of editing. Considerable thought should be given to the organization of subroutines on the core pages. The writeup for each subroutine contains the number of locations required. The subroutines should be placed together to use as many registers on a core page as possible. 2. Requirements Some of the subroutines in the I ibrary require other subroutines to make them work properly. Under the category labeled Needed on the official writeup, the author I is ts the required equipment and/or subroutines to make the particular subroutine work properly. Failure to heed the requirements will result in wasted time as the program won't work. If both subroutines are to be used without modification, they should be on the same page. 3. Intercommunication Registers If the subroutine is not on the current page of the main program and not on Page 0, the programmer may put an intercommunication register on the current page for ease in referencing the subroutine. The address portion of the intercom register is the tag of the starting address of the subroutine. On assembly, the initial address of the subroutine is placed in the intercom register. An example of this technique will be shown using the Square Root subroutine. a. Example Using Intercom Register JMS I SQIN /AC CONTAINS SQUARE /SUBROUTINE CALLED /AC CONTAINS SQUARE ROOT 10-2 SQIN, SQRT /INTERCOM TO SQRT If the square root subroutine were placed on Page 0, the subroutine cal I would be: /AC CONTAINS SQUARE /SUBROUTINE CALLED /AC CONTAINS SQUARE ROOT JMS Z SQRT 4. Tags in the Subroutine The tags in the subroutine are specified by the author when writing it. If a tag in the main program is identical to a tag in a subroutine, PAL will type out BEGN DT and halt. Therefore, the listing of the pertinent subroutine be observed and all tags should be noted. The programmer must then use different tags. 5. Single- and Double-Precision Routines Both single- and double-precision routines are available from the PDP-8 Program Library. Single-precision routines deal with one computer word (i.e., 12 bits). Using one word, the machine can represent 2's complement numbers in the range of +2047 to -2048. If more range is desired, the programmer should use double-precision routines (two computer words, 24 bits). By using 24 bits, the machine can represent signed 2's complement numbers in the range of+ 8, 388,607 to - 8, 388,608. The fol lowing is an example of a double-precision addition. A double-precision operand is stored in locations 20 and 21. The second operand is stored in locations 22 and 23. The high-order portions are in locations20 and 22. Add the two numbers and store the results in locations 24 and 25 with the high-order portion in location 24. CLA CLL TAD TAD DCA RAL z z z 21 23 25 10-3 TAD TAD DCA C. z z z 20 22 24 SELECTED ROUTINES l. The PDP-8 Program Library is constantly being updated and new programs added. No attempt will be made to present all the programs that are available from the library in this workbook. Your instructor will issue the latest program abstract. Following is a selected group of library subroutines, which are used most often. Single- and double-precision routines are similar therefore, only single-precision is presented here. 2. Arithmetic Routines The rules for using a 2 1s complement, fixed-point computer for performing arithmetic operations are referred to as sealing of binary numbers. The PDP-8 subroutines are written for general-purpose, fixed-point arithmetic. This scaling or scale factor concept must be used to obtain meaningful results. A complete discussion of the rules and techniques of scaling is available from Digital's Applied Programming Department. a. 2's Complement Multiply Subroutine The multiplicand must be present in the location following the JMS MULT instruction before the subroutine is ca 11 ed. The subroutine multiplies two 11-bit signed numbers together resulting in a 22bit signed product. If the product is positive, bits 0 and l of the high-order word will be O; if negative, bits 0 and l will both be l. This provides consistency with 2's complement arithmetic. The subroutine returns with the high-order word of the product in the AC and the low-order bits in location MPl. If the main program is on another core page, MPl may be referenced by an intercom register. 10-4 b. 2 1s Complement Divide Subroutine The definitions of divisor, dividend, and quotient are: 5 (Dividend) 2 (Divisor) = 2 (quotient) with a remainder of 1. The divide subroutine is general-purpose to divide 2 1s complement, fixed-point, scaled binary numbers. The dividend is 24 bits and must be greater in magnitude than the divisor. When dividing scaled binary numbers, the scale factor of the quotient is the difference between the scale factor of the dividend and the scale factor of the divisor. Example: Divide 408 by 20 8 Dividend Divisor Quotient 0000 0040 0020 0001 Sea le Factor = B23 Scale Factor = B11 Scale Factor= B12 In this example, the scale factor of the quotient is outside the 12-bit word. To preserve accuracy of the quotient, the programmer should adjust the scale factors before entering the divide subroutine. The scale factors are adjusted by shifting operations which are performed by combinations of rotates on the PDP-8. In the above example, the scale factor of the quotient should have been Bl l. This could be obtained by resealing the dividend to 822 by shifting the dividend one place to the left. When the divisior:i is performed, a binary number scaled B22 by a binary number scaled B11 wil I be divided. The quotient wil I be scaled B11 (B22 - B11 ) • The following is a suggested program sequence to accomplish rescaling before cal I ing the subroutine. Assume that the high- and low-order portions of the signed, 23-bit dividend are located in HDIV and LDIV, respectively. CLA TAD RAL CLL LDIV 10-5 CALL, DCA TAD RAL CALL+ l HDIV JMS DIV Where such a technique is used, the largest acceptable dividend before manipulation is: 3. ±222 - l = ±4, 194, 30310 Conversion Routines a. Single-Precision, Decimal-to-Binary Input This subroutine will accept a signed string of decimal digits from the keyboard of the ASR-33. The number typed will be converted to its binary equivalent, which wil I be in the accumulator on return from the subroutine. b. Single-Precision, Binary-to-Decimal Conversion and Output (DEC-5-32-A) This subroutine will convert a signed 11-bit number to its decimal equivalent which will be typed out by the ASR-33 printer. 4. Teletype Output Programs a. Teletype Output Package This package contains several subroutines to perform different functions. The purpose of the subroutines is to provide an easy means of typing out l, 2, or a string of characters and special characters such as carriage return/line feed combinations, tabs or spaces. This package also contains a routine to interpret a BCD code and type it out as a single decimal digit. The codes for the characters used in the subroutine are referred to as trimmed codes. Instead of being composed of 8 binary bits, the codes contain only the last 6 binary bits of the ful I code. 10-6 The untrimmed codes for each character are shown in Appendix 2 of the PDP-8 Handbook. The fol lowing table shows the function, the subroutine cal I, and the contents of the AC when the subroutine is cal led. Control always returns to the main program with the AC and I ink cleared {except for the last function). Regular tab is equal to 8 spaces because location TTAB contains 7770 {- 8 decimal). Location TTAB may be changed as desired by the programmer. For example, TTAB would contain 7772 for 6 spaces. The tab subroutine is similar to the tab on a regular typewriter. For an excel lent description of the tab, refer to the program writeup. The special considerations for typing a string of characters are also contained in the writeup. The most important features are described here. The last 2 codes in a table of packed, trimmed codes must be 0001. This signals the subroutine to discontinue typing of characters. To type a carriage return or I ine feed only, the trimmed code must be preceded by two zeros. {i.e., pack the codes 0015 or 0012, respectively.) On entering the subroutine, the AC must contain the absolute initial address of the table of trimmed codes. The fol lowing table indicates the technique for writing the program in assembler language. TBll, 2324 etc. /TRIMMED CODES FOR STRING ENDL, 0001 /END SIGNAL In order to specify the typeout of this string of characters, the cal I ing sequence would be: TAD JMS TUN TSC 10-7 /LOAD AC WITH TABLE l DESIGNATOR /SUBROUTINE CALLED /RETURN WITH AC AND LINK /CLEARED TUN, D. TBll /INTERCOM REGISTER TO TABLE l Function Call Type l character JMS TYl Trimmed codes in AC bits 6-11 Type 2 characters JMS TY2 First code in AC bits 0-5 Second code in AC bits 6-11 Type a string of characters JMS TSC Initial address of stored codes Type CR/LF JMS TCR Type l space JMS TSP Type tab JMS TYT Type BCD digit JMS TDIG Bits 0-7-0, Bits 8-11 BCD Convert trimmed code to 8 bit code JMS CON Enter with code in AC, bits 6-11 Exit with code in AC, 4-11 Contents of AC FLOATING-POINT ROUTINES l. General The floating-point package is provided for users who have problems involving decimal fraction arithmetic and do not want to program fixed-point arithmetic. Fixedpoint programming involves a thorough knowledge of the limits of the values of the parameters both in the input/output stages and before and after each elementary calculation. To facilitate calculations of this type, a complete set of floating-point instructions are available through the use of the interpretive Floating-Point Arithmetic Package. In this program, the instructions operate on numbers in a floating-point format where the binary point (counterpart to the decimal point) is maintained automatical Iy by the program. l 0-8 The addition of two floating-point numbers in the computer corresponds to the addition of the two numbers with decimal points. Example: Add the numbers 50 and - 0 .635. 50.000 - 0.635 49.365 The decimal points must Iine up before the numbers can be added correctly. The same addition could have been performed with the numbers expressed as shown. x l 020 x l0 0.49365 x l o2 0.50 -0.635 Again the numbers must be arranged so that the exponent values are the same, and leading zeros must be supplied. x 10~ x l0 0 .4 9365 x 102 0.50000 0.00635 The final fraction contains more digits than either of the two numbers involved. Under certain cir::~:;-;:;: .... nces, there may be leading zeros which contain no significant information. The floating-point package will normalize the number {i.e., adjust the exponent part of the number to eliminate insignificant zeros). When writing programs using the floating-point package, the programmer will need to know a conversion procedure for decimal to floating and floating to decimal. A floating-point word in the PDP-8 occupies three registers one register for the exponent and two registers for the mantissa. The fol lowing is a brief description of the conversion process. a. Convert the number lO(lO) to floating-point. point binary. l 0-9 First convert the number to fixed- Move the binary point to the left of the most significant bit and count the places moved. This number is the exponent. Write the mantissa at the extreme left, but not in bit 0. Bit 0 is used to indicate the sign. The number will look like this in octal notation: 124001 !00041 Exponent b. Mantissa Convert the number 25(l0) to floating point. 25 (10) = 1100 l. (2) Move the binary point and count the places moved. The exponent will be 5. Write the mantissa to the left. The number will be as shown below (octal). looo5j 131001 Mantissa Exponent c. Convert -lO(lO) to floating-point. Convert to binary, working only with the absolute magnitude of the number. Move and count the binary point. Put the exponent and mantissa in as before. Take the 2 1s complement of the mantissa. The floating-point number looks I ike this: 15400] 100041 Mantissa Exponent d. Convert the number -.0625 to floating-point • • 0625(10)= .0001 Move and count the binary point to the right. Move the point to the left of the first binary one. The exponent is - 3. Expressing - 3 in 2's complement is 7775(B)" Put the mantissa at the left, but to the right of bit 0, take the 2 1s complement of the mantissa yields 16000] 10-10 !ooooJ The complete floating-point number will look like this. 17775] 16000] Exponent 2. Mantissa Interpretive Floating-Point Arithmetic Package a. .Tape Format This routine is long and assembly in each program is needless. Thus, the program is available only in binary format and may be loaded with the regular binary loader. b. Internal Format of Floating-Point Words The heart of the floating-point package is a 3-register block (44 8 -46 8 ) called the floating accumulator (FA). All data calculations and transfers are made through the floating accumulator, similar to the 12-bit accumulator (AC). Floating-point data in the FA and in storage registers is composed of two parts: Mantissa. Th is portion occupies two registers (45 and 46 of the FA) and contains the norma I ized data word. Exponent. This register (44) indicates the magnitude of the exponent. The magnitude limits are ±2047 10 . Unless the programmer is doing special manipulations, he does not need to be concerned with the details of this format. The commands and the program keep consistent control over the data. NOTE: A floating-point word occupies three registers. If a floating-point storage register is set aside, three (12-b it) registers must also be set aside. l 0-11 3. Floating-Point 1/0 Package This routine performs the same routines that the input-output conversion subroutines perform. When the input routine is cal led, it wil I accept a signed decimal number typed on the ASR-33, convert it to floating-point format, and store the number in the floating accumulator. On output it will print out in decimal format the floatingpoint number contained in the floating accumulator. This routine is only available in binary format. a. Floating-Point Input Conversion (FINK) The floating-point input conversion routine is of the form: ±ddd.dddE±dd The d's represent decimal digits. The E must be typed preceding the digits which represent the decimal exponent of the number. Either of the signs, the decimal point, or the entire exponent may be omitted. If the decimal point is omitted, it is assumed to be to the right of the last significant digit of the mantissa. Any character which is not legally a part of the above format terminates input of the number. The input will allow up to 6 digits in the data word and 2 digits in the exponent. Al I rubout codes are ignored. b. Floating-Point Output Conversion (FOUT) The floating-point output routine converts the number in the floating accumulator to decimal and types it out in the fol lowing format: ±.dddddd±dd The decimal point is always in front of the leftmost digit. The last two digits (i.e., those after the second sign) indicates the exponent of the 6-digit decimal fraction. c. If the magnitude of the exponent exceeds 99, XX will be printed. Sample Problem to Demonstrate the Use of the Floating-Point Package Four decimal numbers are typed on the ASR-33 representing the coefficients A, B, C, and D of a third-order nonlinear equation. The floating-point routine 10-12 calculates the value of the equation and prints the answer on the ASR-33. The values of X and Y are stored on the current page. The equation is: + + (D/A)Y 3 The portion of the program, which will accept the four decimal parameters from the keyboard, calculate the expression, type out the answer, and leave it in the floating accumulator, is shown below. TRMl I TRM2, TRM3, TRM4, ADUP, JMS JMS FPUT FMPY FMPY FMPY FPUT FEXT JMS JMS FMPY FMPY FMPY FPUT FEXT JMS JMS FMPY FMPY FMPY FPUT FEXT JMS JMS FDIV FMPY FMPY FMPY FSUB FADD FADD I I Z FINK /READ A INTO F.A. Z FPNT /TRANSFER CONTROL TO FLOATING POINT A /STORE IT FOR FUTURE USE x /CALCULATE FIRST TERM x x STRl /STORE F.A. IN STORAGE AREA l /EXIT FROM FLOATING POINT MODE I Z FINK /READ B INTO F.A. I Z FPNT /TRANSFER CONTROL TO FLOATING POINT x /CALCULATE SECOND TERM x x STR2 /STORE F.A. IN STORAGE AREA 2 /EXIT FROM FLOATING POINT MODE Z FINK /READ C INTO F.A. I Z FPNT /TRANSFER CONTROL TO FLOA Tl NG POINT x /CALCULATE THIRD TERM y y STR3 /STORE F.A. IN STORAGE AREA 3 /EXIT FROM FLOATING POINT MODE Z FINK /READ D INTO F.A. I Z FPNT /TRANSFER CONTROL TO FLOATING POINT A /CALCULATE FOURTH TERM y y y STR3 /ADD UP THE TERMS STR2 STR l 10-13 FEXT JMS OUTP, x, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Y, STR 1, STR2, STR3, A, /EXIT FROM FLOATING POINT MODE Z FOUT /PRINT OUT ANSWER /X PARAMETER STORED HERE /Y PARAMETER STORED HERE /STORAGE REGISTERS Example 6: Expensive Adding Machine a. Problem Write a program which will accept decimal digits from the ASR-33 preceded by an operator(+, -, X, or/) and terminated by a nondigit character (a space is suggested). The indicated operation wil I be performed in floating-point arithmetic. When an equal sign is typed, the routine wil I generate a carriage return/ Iine feed combination and print the value of the expression. If any other char- acter is typed as input, the routine will ignore it and return to listen for a meaningful character. The program that is shown as a solution does not inherently contain an error correction facility. However, if an error is made, simply type a space followed by an equal sign. The incorrect answer wil I be typed out and the operator may return to type in the correct sequence of dig its. 10-14 The value of the expression up to that point is calculated after each termination character. The ordinary rules of algebra concerning order of operations do not hold. This routine is a calculating routine not a compiling routine. NOTE: Use a 4K version of the PAL Assembler marked PAL 4K33 (EOT) to assemble a symbolic program using the floating-point commands. b. Flow Diagram START INITIALIZE TELEPRINTER POSITION PERFORM SPECIFIED OPERATION.LEAVE ANSWER IN F. A. LISTEN FOR INCOMING CHARACTER LOAD INTO~ WHEN IT ARRIVES TYPE our•-• TYPE OUT"/" ENTER FLOATING 110 IN SPECIFIED ROUTINE TO LISTEN FOR CHARACTER TYPE OUT"=" TYPE CR a LF TYPE NUMBER CONTAINED IN F.A. REMAIN IN FLOATING 1/0 TYPE OUT"~ LISTEN FOR NEXT CHARACTER 10-15 c. Program Listing /EXPENSIVE ADDING MACHINE - FLOATING POINT /SET UP THE INTER-COM REGISTERS FOR FLOATING POINT *5 FINK, 7400 FOUT, 7200 FPNT, 5600 I /TYPEOUT SUBROUTINE FOR PAGE ZERO *173 TYPE, 0 /LINKING REGISTER TO MAIN PROGRAM TSF JMP .-1 TLS JMP I TYPE I /THE STARTING ADDRESS IS 200 /I NI TIA LIZA TION ROUTINE BEG, KCC TLS TAD C215 JMS Z TYPE CLA TAD C212 JMS Z TYPE CLA DCA ACC DCA ACC+l DCA ACC+2 /CLEAR KEYBOARD FLAG AND AC /GIVE TYPEOUT COMMAND TO SET FLAG /INITIALIZE TELEPRINTER POSITION /CLEAR OUT SPACE FOR /FLOATING NUMBER I /SECTION TO LISTEN FOR INCOMING CHARACTER GOPR, KSF /GET OPERATOR JMP .-1 KRB I /DISPATCH ROUTINE TAD SNA JMP TAD SNA JMP TAD SNA JMP TAD JMP M253 ADD M2 SUB M2 DVD Ml6 EQL /ADD TO CODE MINUS 253 /WAS IT A PLUS SIGN, CODE 253? /YES I JUMP TO ADD /NO, ADD -2 TO RESULT /WAS IT A MINUS SIGN, CODE 255? /YES, JUMP TO SUBTRACT /NO, ADD -2 TO RESULT /WAS IT A SLASH, CODE 257? /YES, JUMP TO DIVIDE /WAS IT AN=, CODE 275? /YES I JUMP TO EQUATE 10-16 TAD SNA JMP JMP /ADD ROUTINE ADD, TAD JMS CLA TAD JMS JMS JMS FADD M33 MLT GOPR /ADD - 33 TO RESULT /WAS IT AN 11 X11 , CODE 330? /YES, JUMP TO MULTIPLY /ILLEGAL CHARACTER, TRY AGAIN C253 Z TYPE /TYPE A 11 + 11 SIGN C240 Z TYPE I Z FINK I Z FPNT ACC /TYPE A SPACE AFTER OPERATOR /ENTER FLOATING 1/0 TO GET NUMBER /ENTER INTERPRETIVE MODE /ADD CONTENTS OF 11 ACC 11 TO CONTENTS OF /FLOATING AC /STORE IN ACC /LEAVE INTERPRETIVE MODE FPUT ACC FEXT JMP GOPR /END OF ADDITION. GET NEXT OPERATOR I /SUBTRACT ROUTINE /THE FOLLOWING ROUTINES ARE ESSENTIALLY THE SAME AS THE / 11 ADD 11 ROUTINE SO WILL NOT BE COMMENTED SUB, TAD C255 JMS Z TYPE /TYPE MINUS SIGN CLA TAD C240 JMS Z TYPE JMS I Z FINK JMS I Z FPNT FPUT ACC+3 ACC FGET ACC+3 FSUB ACC FPUT FEXT JMP GOPR /END OF SUBTRACTION. GET NEXT OPERATOR I /DIVIDE ROUTINE DVD, TAD JMS CLA TAD JMS JMS JMS FPUT FGET FDIV C257 Z TYPE /TYPE SLASH FOR DIVIDE C240 Z TYPE I Z FINK I Z FPNT ACC+3 ACC ACC+3 10-17 /END FPUT ACC FEXT JMP GOPR OF DIVISION. GET NEXT CHARACTER I /MULTIPLY ROUTINE MLT, TAD C330 JMS Z TYPE /TYPE MULTIPLY OPERATOR, 11 X 11 CLA TAD C240 JMS Z TYPE JMS I Z FINK JMS I Z FPNT ACC FMPY ACC FPUT FEXT JMP GOPR /END OF MULTIPLICATION. GET NEXT OPERATOR I /EQUALS ROUTINE EQL, TAD C275 JMS Z TYPE /TYPE EQUALS OPERA TOR CLA TAD C215 JMS Z TYPE /TYPE CR CLA TAD C212 JMS Z TYPE /TYPE LF JMS I Z FPNT ACC FGET /GET ANSWER IN F.A. FEXT /LEAVE INTERPRETIVE MODE JMS I Z FOUT /TYPE OUT ANSWER CLA JMP BEG+2 /JUMP TO INITIALIZE PROGRAM FOR NEXT CALCULATION /CONSTANTS C215, 215 212 C212, M253, 0-253 0-2 M2, Ml6, 0-16 0-33 M33, C253, 253 C240, 240 C255, 255 C257, 257 l 0-18 C330, C275, ACC, 330 275 0 0 0 $ l 0-19 CHAPTER II INTRODUCTION TO THE PDP-8 DEC DEBUGGING TAPE (DDT-8) A. GENERAL DDT-8 is a debugging program for the PDP-8 computer which allows the programmer to correct a binary program which contains errors. location 4. DDT-8 occupies locations 5240 to 7600 and Its internal symbol table extends down to 5000 and al lows an input of 200 {decimal) symbols. Its starting address is 5400. DDT-8 is operated from the ASR-33 Key- board, and the output may be on the ASR-33 Printer-Punch or the High-Speed Punch, depending on the operator's choice and available equipment. B. DEFINITIONS l. Symbol - A string of letters or letters and numbers, the first character of which must be a letter. Up to six characters may be used. 2. Number - A string of up to four octal digits. 3. Expression - A string of symbols and numbers separated by a plus{+), minus {-), or space. 4. Open Register - When a register is opened, its contents are printed out, and the register becomes available for modification. 5. Closed Register - When a register is closed, any modifications requested are made and further access to the register is denied until it is opened again. DDT will respond to operator errors by typing a question mark (?)and will ignore the error. C. LOADING PROCEDURE l. Load binary object tape into memory using the Binary Loader. 11- l D. 2. Load DDT-8 into memory using the Binary Loader. 3. Set switch register to 5400, depress LOAD ADDRESS, depress START. 4. DDT-8 is now running and awaiting the first command. CONTROL CHARACTERS NOTE: Use of a left bracket ([) indicates depression of ALT MODE key which is echoed as a left bracket ([). The switch register is positive when the leftmost switch (bit) is down (O) and negative when it is up (1). l. Arithmetic a. Plus (+) - Separation character meaning arithmetic plus. b. Minus(-) - Separation character meaning arithmetic minus. c. Space - Separation character indicating that the fol lowing expression is to be taken as an address. 2. d. Period{.) - Has the numerical value of the current location. e. Equal (=) - Convert the last expression printed into its octal equivalent. Program Examination and Modification a. Slash V) - Open the register whose address precedes the slash. The operation causes the contents of the register to be printed out and makes it available for modification. b. Carriage Return ( ~) - Closes the register opened by the slash. Any expression typed before carriage return wi 11 become the contents of the register. c. Line Feed - Has the same effect as carriage return, however, it opens the next consecutive register. d. Up Arrow (t) - Opens the register specified in the address portion of the instruction contained in the open register. Use of this character does not follow an indirect chain. 11-2 e. [0 - Convert to octal mode. Causes contents of registers examined to be typed out in octal. f. [S - Convert to symbolic mode. Causes contents of registers examined to be typed out in symbolic. 3. Search a. N[W - Causes a word search for the expression or number N. The search will take place between the limits in locations [Land [U of DDT and the contents of the registers will be masked (logical ANDed) by the contents of [M. b. [L - Permits access to the register which contains the lower limit of the search (operates in the same way as the slash), originally 0001. c. [U - Permits access to the register which contains the upper limit of the search, initia Ily 5000. d. [M - Allows access to the register which contains the mask of the search, originally 7777. 4. Breakpoints a. Y[B - Inserts a breakpoint before location Y. when a G or C command is given. The breakpoint is inserted only When a breakpoint is encountered, control goes to DDT and the AC and I ink are saved. The location of the breakpoint is typed out fol lowed by a right parenthesis and the contents of the AC at that point. Breakpoints may be removed by typing [B alone with no address indicated. NOTE: Only one breakpoint may exist at any time. The last specified breakpoint is the one which DDT establishes when the GO or CONTINUE command is given. 11-3 b. Y[G - Go to address Y and begin execution of the user's program at that point. Control goes to the user's program and its execution begins. The computer will stay in the user's program until a breakpoint is reached at which time control will return to DDT. If no trap occurs (no breakpoint established or reached due to branching) the computer wil I stay in the user's program until a programmed halt occurs, at which time the computer will halt. DDT will have to be restarted by putting 5400 in the switch register, depressing LOAD ADDRESS, and then depressing START. c. [C - Continue from trap. This command will cause control to go from DDT to the user's program with the AC and link returned to their original condition before the breakpoint was encountered. Control will stay in the user's program until a breakpoint is reached, at which time control goes back to DDT. If the breakpoint is in a loop and it is desired to go around the loop a specific number of times, the command N[C may be typed, at which time DDT wil I al low the program to loop N times before the breakpoint is encountered. 5. d. [A - Opens the register which contains the contents of the AC at a breakpoint. e. [y - Opens the register which contains the contents of the link at a breakpoint. Symbol Definition a. [R - Read symbol table. If it is desired to define symbols to use in the symbolic mode and these symbols are on the binary tape produced from the Assembler, place this portion of the tape in the reader, type [R, and then turn on the reader. If the symbols on the tape are less than 200 (decimal), they will be read into the buffer area of DDT which is reserved for the definitions of tags used in a program. Then hit CONTINUE. If a new symbol table is being created, the contents of the switch register should be negative; however, if it is desired that the symbols coming in append the table currently in the buffer, the contents of the switch register should be positive. To define symbols not on a binary tape, use the fol lowing procedure: 11-4 1. Set switch register to positive or negative. 2. Type [R. 3. Type CARRIAGE RETURN-LINE FEED. 4. Type symbol to be defined, at least one space, the address of the symbol, CARRIAGE RETURN-LINE FEED. 5. Repeat step 4 for each symbol to be defined. 6. When all symbols have been defined, type EOT and hit CONTINUE. After the symbol tab Ie has been read in by DDT, the bottom address of the externa I symbol table wi 11 be typed out. The operator's program must not exceed this address. 6. Punch a. Y;Z[ P - Punch contents of locations Y through Z inclusive in binary format on tape. b. [T - Punch leader-trailer. c. [E - Punch checksum and trailer. d. Procedure to punch binary tape on ASR-33. 1. Turn the Teletype to on I ine; turn punch off. 2. Set switch register to negative. 3. Type [T, turn punch on, depress CONTINUE. 4. Turn punch off, type in low address of area to be punched followed by a Leader will be generated. semicolon (;), then the high address of the area to be punched, then type [ p. 5. Turn punch on, depress CONTINUE. 6. Repeat steps 4 and 5 for more blocks to be punched. 7. With Teletype on Iine and punch off, punch checksum and trailer by typing [E, turn punch on and hit CONTINUE. 11-5 8. Turn punch off after tape is punched. DDT is now awaiting the next command. To use the high-speed punch (15A), use the same procedure as with ASR-33 except the switch register should be set to positive and the punch on ASR-33 is left off. 11-6 mamanmn 5233 PRINTED IN U.S.A. . 5-3/65
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies