Digital PDFs
Documents
Guest
Register
Log In
DIGITAL-7-95-U
January 1966
7 pages
Original
0.2MB
view
download
Document:
ExecuteSubr
Order Number:
DIGITAL-7-95-U
Revision:
Pages:
7
Original Filename:
http://bitsavers.org/pdf/dec/pdp7/DIGITAL-7-95-U_ExecuteSubr_Jan66.pdf
OCR Text
1. IDENTIFICATION 1.1 Di gita 1-7-95-U 1.2 Execute Subroutine 1.3 January 25, 1966 PDP 7 LIBRARY Digital-7-95-U Page 1 2. ABSTRACT 2.1 The Execute Subroutine is designed to allow a user to execute any sequence of instructions anywhere in the program, as if it were a subroutine. In essence, it acts as if the XCT instruction were a I lowed to execute more than just a single instruction anywhere in memory. The subroutine includes the instructions necessary for initialization, a pseudo command (XXCT) to allow entrance and exit from the requested subroutines, and enough storage space for pushdown stacks and nesting to five levels. The subroutines can be used with either a PDP-4 or PDP-7. 3. REQUIREMENTS 3. 1 Storage memories. The subroutines occupy 105 8 locations. They are not designed to work with extended 3.2 Subprograms (None) 3.3 Equipment Normal 4K or 8K PDP-4 or PDP-7 4. USAGE 4.1 Loading The user is supplied with a symbolic tape which can be assembled with the main program. The tape contains no undefined tags, no origin, and no final START address. 4.2 Ca II i ng Sequence 4.2.1 Before the Execute Subroutine is used for the first time, the user must initialize the system by issuing the command XCTSET. XCTSET is defined as a JMS to a set of instructions which will see that the stack pointers are reset and will replace any locations in memory which may have been changed by any previous use of the subroutines. The latter could occur if the program were stopped and restarted whi Ie under the control of the Execute Subroutine. The initialization, therefore, attempts to restore memory to its correct original condition before continuing. Note that if the computer should be stopped at certain locations within the subroutine itself, it might be necessary to reload the entire program to restart. 4.2.2 The format for calling the subroutine is as follows: XXCT ADDRl ADDR2 /PSEUDO COMMAND, defined as a JMS to subroutine. /FIRST LOCATION to be executed /FIRST LOCATION NOT to be executed. ADDRl should be the location of the first instruction of the loop to be executed. Fifteen bi ts are used for the address. ADDR2 is the location of the first instruction of the loop not to be executed, or, more simply, it is the location which when reached causes a return to the main program at XXCT+3. Di gita 1-7-95-U Page 2 Fifteen bits are used for the address. The user must be sure that ADDR2 is one which will definitely be reached sometime during the execution of the subroutine. The contents of the accumulator and link are not destroyed when the subroutine is entered, and will contain the correct results of the executed subroutine upon return. 4.2.3 There are no restrictions on actua I instructions being executed as a subroutine, except to remember that an exit wi II be made the first time the instruction at ADDR2 is reached and before its execution. Execute loops may be nested to a depth of 5. If nesting is desired to any other level, the statement XCTLNG=5 should be changed to indicate the desired amount. Three locations are used for each leve I of nesti ng. 4.3 Switch Settings (None) 4.4 Start Up The subroutines can usually be reinitialized by issuing the XCTSET pseudo command. There may be rare instances when the program should be reloaded in its entirety. 4.5 Errors in Usage Only one halt can occur within the subroutines: HALT Location Meaning Procedure XCTTM Execute loops have been nested to a leve I greater than 5. If legitimate, reassemble the program changing the XCTLNG=5 statement to the correct length necessary. 5. RESTRICTIONS 5.1 The subroutines will not operate correctly if the subroutines themselves or the area to be executed is in extended memories or if the computer is in extend mode when the subroutines are called. The XXCT pseudo command should never be issued by a normal PDP-7 execute (XCT) instruction. 6. DESCRIPTION 6.1 Discussion The Execute Subroutine allows the use of any set of instructions anywhere in the program, as a subroutine. It is most useful where running time and space are not an important consideration and where, for one reason or another, a set of instructions is not coded as a subroutine. It has been found very useful in the debugging stage to simply assemble the Execute Subroutine with the main program, making corrections where necessary and where possible by executing a proper set of instructions anywhere in the program. After debugging, the proper instructions can be coded as subroutines, if desired, and the Execute Subroutine can be removed if necessary to save time and space. It has also been found useful during testing to execute certain portions of a test program without necessari Iy executing those portions before or after. Digital-7-95-U Page 3 The subroutines operate rough Iy as follows: 1) Save the accumulator. 2) Check to find out whether the nesting limit has been exceeded. If it has, halt; otherwise continue. 3) Save subroutine starting location (ADDR 1) . 4) Save the address of the last location (ADDR2) on the last location pushdown stack (XCTLOC). 5) Save the contents of the last location on the contents pushdown stack (XCTCON). 6) Place a JMP instruction in the last location whi ch returns to the Execute Subroutine when the subroutine is terminated. 7) Save the address of the return to the main program on the return address pushdown stack (XCTREn. 8) Index a II stack pointers, restore the accumu lator, and jump to the subrouti ne at the first location specified. When the subroutine has been completed, it wi II return to the Execute Subroutine where the following procedure is followed: 9) Save the accumu lator. 10) Decrement the last location and contents of last location pushdown stack pointers (XCTLOC and XCTCON). 11) Restore the ori gina I contents of the last location. 12) Decrement the return address pushdown stack pointer. 13) Restore the accumulator, and return to the main program at the location saved on the return address stack (XCTRET) . The initialization procedure (XCTSET) operates basically as follows: 14) Check to see if the contents pushdown stack pointer (XCTCON) is at its base position. 15) If the stack pointer is at its base position, exit and return to the main program. 16) If the stack pointer is higher than its base position, repeat steps 10 through 12. 17) Repeat steps 14 through 16 unti I a II items have been reset. Di gita 1-7-95-U Page 4 6.2 Example The following is an example of how the Execute Subroutine might be used. The example is not to be taken as one which is either particularly applicable or efficient I but simply a use of the subroutine. In the PDP-7 Bidirectional DECtape Subroutines (Digital-7-22A-1/0) the following 35 millisecond delay loop is used before changing unit selections: MMWAIT, MMSCH9, MMRS /READ DECTAPE STATUS AND (400) /SAVE CONTROL TYPE JMP MMSCH9 /NO DELAY FOR NEW CONTROLS LAC MMCHK1+1 /PICK UP UNIT NUMBER SAD MMSEL /COMPARE TO PREVIOUS SELECTION JMP MMSCH9 /NO DELAY IF UNIT IS THE SAME DAC MMSEL /SAVE NEW UNIT NUMBER CLA /CLEAR THE ACCUMU LA TOR MMSE /SELECT UNIT 0, i.e., DESELECT LAM DECIMAL-5000+10CTAL /COUNTER DAC MMBLF /TEMPORARY STORAGE AREA ISZ I. -1 /DE LAY LOOP EQUALS 7 tJSEC JMP .-1 /DELAY 35 MSEC LAC MMCHK 1+1 /PICK UP SELECT ETC. If the user desired to deselect all DECtapes and delay 35 msec somewhere else in his program the following sequence of instructions could be used: XXCT MMSCH9-6 MMSCH9 /FIRST INSTRUCTION TO EXECUTE /INSTRUCTION TO CAUSE RETURN Note also that the following set of instructions could be used if the user simply required a 50 msec de lay: LAM DECIMAL-7143+1 OCTAL /50000 DIVIDED BY 7 !-,SEC XXCT MMSCH9-3 /FIRST INSTRUCTION TO EXECUTE MMSCH9 /INSTRUCTlON TO CAUSE RETURN The user should be aware that in these particular examples use of the subroutines themselves causes an additional delay (see Section 9); however, for purposes of illustration it is being ignored. 7. METHODS (See Section 6) 8. FORMAT (Not Applicable) 9. EXECUTION TIME The subroutines require 77 cycles or approximately 135 tJsec on a PDP-7 or 616 tJsec on a PDP-4 to enter and exit any requested subroutine. Di gital-7-95-U Page 5 10. PROGRAM 10.4 Program Listing I~XE~UTE SU8~OUTtN~ I~M~ '~25~6~, wILL I~X~~UTES A qEnU~NnE NOT WORK WITH E~TENnED ~EMnRy. OF T~STRUCTIONS NOT IN SU8~OUTyNE FORM 1138US oER SU~ROUTINE. ,~5 (OCTAL. L"CATrON~) IFO~MAT XXCT I ADDR 1 IF 1 RST I NSTRIICT I nN TO BE EXECUTED I ADDR? IFIRST INSTRIICTII")N NOT TO Sr: EXECUT~D XXCT=.JMS • t'J OAC XCTAC LAW 'l('CTR£T SAO ~CTCON ~LT LAC t XXCT-JMS DAt:'! XCT"WA r 82 'l('XCT ""Jr'1S LAC I XXCT .. Ji"1S DAC r XCTlnC f'lAC XCrWA? LAC T XCT .. I,~A2 TJAC r XCTcnr\l LAC C \.JMP XXCTRT) nAr. r XCTWA2 r S 7 XXc T " J t.1 S LAC XXCT-JMS nAC T XCTR~T rSl XCTLOC ISl ycrCOIIJ XeT" 1S'- )feTHEr XCTAC JMP r XCTwll L.AC IRETURN ,rROM SUBROUTINE XXCTRT, DAr. XCTAC LAM ADD DAC '_AM ADn -1 verloe '<crlOC -1 ,<crCON DAC )(eTCOl\1 l.AC T xCTC'iN XCT xelLoe LAM -1 ADn 'lCTRET DAC X~T2, )feTHET LAC XCTAC JMP veTHET IS AvE ACCUMULATOR IFr,R COMPARISON IC"MPARE TO CnNTENTs STACK POINTER IT"O MANY RECURSIvE LEVELS ISTARTING ADDRESS ITrMPORARy STnRAG~ AREA 1 I ~'DEX ARGUMENT Po I t\ITER IFTRST NON-EXECUTED LOCATION ISAVE ON LAST LOCATION STACK IT,MPORARy STnRAG~ AREA ICnNTENTS OF lAST LOCAT I ON ISAVE nN OONT~NTS STACK IJMP INSTRUCTION IRrPLACE OONT,NTS OF LAST LUCATION IIMDEX ARGUMENT PnINTER IPTCK uP RETURN AnDRESS ISAvE ON RETURN AnDRESs STACK IIMDEx LAST LnCATyON STACK poyNTER II~DEX CONTENTS STACK POINTER IINDEX RETURN ADDRESS STACK PoINTER IREsToR~ AC, LINK UNCHANGEO. ISTART EFPECTyVE SUBROUTINE ISAVE ACCUMULAToR IF"R StJBTRACTTON ID~CREMENT LAsT AnDREss STACK POtNT~R IR~STO~E POINTER IFr!R SllBTRACTyQN ID~CREMENT CONTENTS STACK POINTER IRl='sTORE POIf\lTER IPfCK IJP ORIGrNAL IR~STORE CONT~NTS CONTENTs UF LAST LCcATtnN OF LAST LOCATION IF"R SUSTRACTyON ID~CREMENT RETURN ADDRESS SlACK porNTER IR~STORE POINTER IREsTORE AC, LINK UNCHANGEO IJMP TO MAIN LOOP. Digital-7-95-U Page 6 IINtTTAlTZE VCT TA,RLE XCTS~T·JMS • SURROUTI~ES. WILL R~SET LOOPS TF AMY ITEMS REMAIN lIN iii LAW ~CTCON+l ~An XCTCI')N JMP r .-3 LAC (JMP XCT3) DAC )(CT2 ,J MP X XCT~ T+ 1 LAC XCT1 OAC )(CT2 JMP ~CTSET.l-JMS )(CTAr.II)(CTS£T . . JMS xCTLnc, DAC , XCTU'lC+XCTLNr,+1/ .+, XCTCON, LAw .+1 XC TcnN+)(cTLNr,+1/ XCTR~T, JMP I 'l(CT~r:.:T+)(CTLNr,+11 .+' STA~T 11 . DIA GRAMS (None) 12. RE FERENCES (Not Applicable) IW~RK AREA, XOTAC IFnR CO~1PARISn~J IIq POYNTER RESET IEXTT IR~TUR~ FROM CLEARING STACK IRpPLACE LAC TNSTRUCTION ICIEAR ONE ENTRY IN THE STACK ILAC INSTRUCTTON IR~STO~E LAC TNSTRUCTlnN IC~ECK FOR COMPLETION.
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies