PDP-12 User's Manual

CHAPTER 4
PDP-8 MODE PROGRAMMING

Section VI. EXTENDED MEMORY

When additional 4096-word memory banks are attached to the PDP-12, the Memory Extension Control provides access to the additional storage, both for programs and data. The registers of the Control are already built into the PDP-12; they are described in Section 3.22 in relation to LINC mode memory control. In PDP-8 mode, the functions of these registers are the same, but only a portion of each register is used. The Instruction Field (IF), Data Field (DF), and Instruction Field Buffer (IB) registers are each three bits long; the two low-order bits of the 5-bit total pertain only to LINC memory fields. The Save Field register (Interrupt Buffer) is only six bits long; in this case, the four high-order bits are unused.

REGISTERS

Instruction Field Register (IF), 3 Bits

These three bits serve as an extension of the PC for determining the 4096-word field from which executable instructions are to be taken. All direct memory references are made to registers in the Instruction Field, with one exception, all JMP and JMS instructions, whether direct or indirect, are registers within the Instruction Field. The exception is the first JMP or JMS executed after a CIF instruction is given. This causes the field to change.

Data Field Register (DF), 3 Bits

These three bits serve as an extension of the Memory Address register for determining which memory bank contains the operands to be accessed by indirect (only) memory references. The Data Field and Instruction Field may be set to the same bank.

Instruction Field Buffer (IB), 3 Bits

This serves as an input buffer for the IF. Except for a direct transfer from the console switches, all transfers into the IF must pass through the IB. When a CIF or RMF instruction is executed, information going to the IF is first placed in the IB. At the next occurrence of a JMP or IMS, the contents of the IB are transferred to the Instruction Field register, and programming continues in the new field, starting in the target register of the jump.

Save Field Register (SF), 6 Bits

Also called the Interrupt Buffer. When a program interrupt occurs, the contents of the IF and DF are stored in the Save Field register, as shown in Figure 4-10. After the interrupt has been serviced, an RMF instruction will cause the contents of the SF to be restored to the DF and IB. The SF can be examined by using the RIB instruction.

	- To Be Done -
Figure 4-10. Data Path to SF and AC

Break Field Register (BF), 3 Bits

When an external device requires extended memory for the transfer of data using the Data Break Facility, the contents of the BF specify the memory bank to be accessed. The use of the register is described in detail in Chapter 5.

INSTRUCTIONS

All Extended Memory IOT instructions require 4.3 microseconds for execution.

CDF - Change Data Field

Octal code: 62N1, 0 <= N <= 7
Operation: The quantity N is transferred to the Data Field register. All subsequent indirect memory references by AND, TAD, ISZ, and DCA are to the new field.

CIF - Change Instruction Field

Octal code: 62N2, 0 <= N <= 7
Operation: The quantity N is transferred to the instruction Field Buffer. At the occurrence of the next subsequent JMP or JMS instruction, whether direct or indirect, the contents of the IB are transferred to the IF. The effective address of the jump is placed in the PC, and the program continues from that address in the new Instruction Field.

In both CIF and CDF, the number N occupies bits 6-8 of the instruction code.

RDF - Read Data Field

Octal code: 6214
Operation: The contents of the Data Field register are placed in bits 6, 7, and 8 of the AC. The other bits of the AC are unaffected.

RIF - Read Instruction Field

Octal code: 6224
Operation: The contents of the Data Field register are placed in bits 6, 7, and 8 of the AC. The other bits of the AC are unaffected.

RIB - Read Interrupt Buffer

Octal code: 6234
Operation: The contents of the Save Field register (Interrupt Buffer) are transferred to the AC, as follows:

Bits 0-2 (IF) are placed in AC[6:8]; bits 3-5 (DF) are placed in AC[9:11].

RMF - Restore Memory Field

Octal code: 6244
Operation: The contents of the Save Field register are placed in the instruction Field Buffer and DF as follows: Bits 0-2 (original Instruction Field) are transferred to the IB; bits 3-5 (original Data Field) are restored to the Data Field register. This instruction is used to restore the Memory Field registers after a program interrupt has been serviced. Normally, the next instruction after the RMF would be JMP I 0; the address of the interrupted program, stored in register 0000 of bank 0, is placed in the PC, and the contents of the IB are placed in the Instruction Field register; the program thus returns to the main program with the Memory Fields restored to their original values.

PROGRAMMING

All instructions, effective addresses, and directly-addressed operands are taken from the field specified by the contents of the instruction Field Register. All indirectly-addressed operands are taken from (or are stored in) the field specified by the contents of the Data Field Register. The following chart shows the results of the four possible addressing combinations, when the IF and DF designate different memory fields.

Instruction Bits      Fields                 Effecfive Address

Indirect  Page       IF     DF

   0       0         m      n          The operand is in Page 0 of Field m 
                                       at the address specified by instruction
                                       bits 5-11.

   0       1         m      n          The operand is in the current page of
                                       Field m.

   1       0         m      n          The effective address of the operand is
                                       in Page 0 of Field m at the
                                       location specified by instruction bits
                                       5-11. The operand is in Field n,
                                       in the location specified by the
                                       effective address.

   1       1         m      n          The effective address is taken from
                                       the current page of Field m, at
                                       the location specified by instruction
                                       bits 5-11. The operand is in Field n.
Autoindexing

When any memory bank is used as an Instruction Field, registers 10-17 of that bank have autoindexing properties, just as the corresponding locations in field 0 do. This is necessary so that a program can operate correctly regardless of the actual memory bank assigned by the IF. When an autoindex register is indirectly addressed, the resulting effective address is used to obtain the operand from the Data Field specified by the DF.

Example:

          C(IF)= 2.    C(DF)= 4.   C(AC)= O.

          In field 4:    C(4326)= 1107
          In field 2:    C(0012)= 4325
The instruction, TAD I 12, is executed in field 2.
          C(0012)+ 1 -> C(0012). Resulting effective address is 4326.
          C(4326) in field 4 are added to the AC
          C(AC)= 1107 when the instruction is completed.

Calling A Subroutine Across Fields

The problem is to let the subroutine know which field contains the calling program, so that it can return to the proper point when it's finished. This is most easily done by setting the DF to the same field as the IF, then setting the IF to the field containing the subroutine, and executing a JMS to read the subroutine. The subroutine uses the DF to indirectly obtain data from the calling field, then transfers the C(DF) back to the IF Buffer to return to the calling program. The following example shows a general procedure for doing this.

/CALLING PROGRAM IN FIELD 2, SUBROUTINE IN FIELD 4
/CURRENT DATA FIELD IS 1
/CALLING SEQUENCE SAVES CURRENT DF, PUTS IF IN DF, CALLS
/SUBROUTINE. ON RETURN, ORIGINAL DF IS RESTORED

          ...                                        
          CLA
          TAD RESDF      /CDF INSTRUCTION TO AC
          RDF            /C(DF) TO AC 6-8 FORMS CDF 10(6211)
          DCA RESDF      /STORE IN SEQUENCE TO RESTORE DF
          TAD SETDF      /CDF TO AC
          RIF            /C(IF) TO AC 6-8 FORMS CDF 20(6221)
          DCA SETDF      /STORE IN SEQUENCE TO SET DF
SETDF     CDF            /SETS DF TO CURRENT IF
          CIF 40         /SET IF BUFFER TO SUBROUTINE FIELD 4
          JMS I SUBADR   /JUMP TO SUBROUTINE IN FIELD 4
RESDF     CDF 10         /RESTORES ORIGINAL DF (FIELD 1)
          ...
SUBADR    SUBRTN         /ABSOLUTE ADDRESS OF SUBROUTINE

/IN FIELD 4, THE SUBROUTINE HAS THE FOLLOWING GENERAL FORM

SUBRTN    0              /C(PC) FROM CALLING PROGRAM
          TAD RESIF      /CIF INSTRUCTION TO AC
          RDF            /C(DF) TO AC6-8 FORMS CIF 20 (6222)
          DCA RESIF      /STORE IN SEQUENCE TO RESTORE CALLING FIELD
          ...
          ...
RESIF     CIF 20         /SETS IF BUFFER TO RESTORE CALLING FIELD
          JMP I SUBRTN   /JUMP BACK TO CALLING PROGRAM
The original contents of the IF, placed in the DF by the calling program, are used to form a CIF instruction which is placed in the subroutine program sequence just before the exit, to restore the original calling field.

Program Interrupt

If, when the interrupt facility is enabled, an interrupt request occurs, the contents of the IF and DF are saved in the Interrupt Buffer. The contents of the PC are stored in register 0000 of Field 0, and the next instruction is taken from register 0001 of Field 0. Regardless of the states of the Memory Field registers, a program interrupt always transfers control to Memory Field 0. When the interrupt has been serviced, the RMF instruction is used to restore the Memory Field registers to their original states. The last three instructions of a general interrupt service routine should be as follows:

          RMF         /RESTORES DF, PUTS ORIGINAL IF IN IF BUFFER
          ION         /ENABLE INTERRUPT
          JMP I 0     /SETS IF FROM IF BUFFER, AND RETURNS TO
                      /MAIN PROGRAM.