Abstract:
A microcomputer in which a higher address must be corrected according to a carry or borrow signal generated during address computation for memory reference based on each addressing mode. The microcomputer is provided with a databank register for holding the higher address and a temporary register for storing a value obtained by incrementing or decrementing by one digit the contents of the data bank register so that the higher order address may be corrected with neither increase in the number of instruction executing cycles nor loss of the memory area continuity.

Description:
This is a continuation of application Ser. No. 07/144,455 filed Jan. 15, 1988, now abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     The present invention relates generally to data processing system and, more particularly, to a data processing system capable of correcting the higher order address when a carry or borrow signal is generated in address computation. 
     FIG. 6 shows the central processing unit (CPU) of a conventional microcomputer. It is assumed that the address width and data bus width are 24 and 16 bits, respectively. The CPU includes a program counter (PC) 1, a program bank register (PBR) 2, a data bank register (DBR) 3, address latches (L1 and L2) 5 and 6, address adders (INC1 and INC2) 7 and 8, an arithmetic and logic unit (ALU) 21, and buses for connecting these devices. The PC 1, and the PBR 2 and DBR 3 are a 16-bit register and 8-bit registers, respectively. The PBR 2 holds the most significant 8 bits (AD 16  -AD 23 ) of an address in the program area while the DBR 3 holds values in the most significant 8 bits of an address in the data area, respectively. Consequently, the program fetch is carried out from the address at which the most significant 8 bits AD 16  -AD 23  are designated by the contents of the program bank register and AD 0  -AD 15  are designated by the contents of the program counter. On the other hand, the data fetch is carried out from the address at which AD 16  -AD 23  and AD 0  -AD 15  are designated by the contents of the DBR 3 and the values determined by the operation of the CPU in execution of the instruction, respectively. 
     The CPU further includes various 16-bit registers 10-18; namely, a temporary register (TP1) 10 for temporary storing the results of computation in the ALU 21, accumulators (A and B) 11 and 12, and index registers (X and Y) 13 and 14, a stack pointer (S) 15, a direct page register (D) 16, a processor status register (PS) 17, and a temporary register (TP2) 18 for temporary storing data fetched into the CPU from the data bus, and internal bus latches 19 and 20. Symbols o and o represent gates responsive to a control signal from the control section to open when the reference clock is a logic level low &#34;L&#34; and a logic level high &#34;H&#34;, respectively. 
     The operation of the CPU will be described by way of the execution of an instruction Load Accumulator A (LDA) in an absolute X addressing mode. This instruction is composed of one byte of operation code and two bytes of operand. A first address part identified by the sum of the contents of the X register and the operand are used as a low part of an address to be combined with a second address part stored in DBR 3 to provide an entire address. This entire address is used to access data which is loaded into accumulator A. 
     The timing chart for execution of this instruction is shown in FIG. 7. In cycles 30 and 31, the operation code and the operand are fetched, and the operation code is decoded. At the same time, the previous instruction is executed in these cycles. Consequently, the LDA instruction is executed from the next cycle 32, in which the 2-byte operand (hhll) fetched in the TP2 in the previous cycle and the contents of the X register are added in the ALU 21 and the sum is stored in the TP1. In the next cycle 33, the values of this TP1 and the DBR are output at AD 0  -AD 15  and AD 16  -AD 23 , respectively, and the contents of this address is fetched in the TP2. In the cycle 34, the fetched value is transferred to the TP1 to check the flag. In the cycle 35, it is stored in the accumulator A. Thus, the execution of the LDA instruction in the absolute X addressing mode is completed in four cycles. 
     However, there is a problem when a carry signal is generated upon addition of the contents of the X register and the operand hhll in the cycle 32. The 16-bit addition in the ALU 21 generates a carry signal in the second half of the cycle 32 so that there is not sufficient time to input it to the address adder 8 of FIG. 6 to increment by one digit the value of the DBR 3 in the same cycle. 
     One solution is to ignore all carry signals. However, this results in loss of the continuity in the memory area, which is disadvantageous for programming purposes. Another solution is to provide after the cycle 32 another cycle for computing the value of the DBR 3 and a carry signal in the ALU 21. This makes the execution time one cycle longer. 
     SUMMARY OF THE INVENTION 
     Accordingly, it is an object of the invention to provide a microcomputer capable of performing address addition including a carry in the bank register without any increase in the number of cycles for the execution an instruction and any loss of continuity in the memory area. 
     According to the invention there is provided a microcomputer which includes a temporary register as well as respective program and data bank registers and a control unit for controlling these registers so that the contents of the PBR or DBR incremented or decremented by one digit may be stored in the temporary register in the cycle that the ALU performs address addition or subtraction and, in the next cycle, either of these values is output as an address depending on which signal, carry or borrow, is generated as a result of the address computation in the ALU, thus not only eliminating the cycle for correcting the higher order address but also ensuring the memory area continuity. 
     Other objects, features, and advantages of the invention will be apparent from the following description taken in conjunction with the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram of the CPU of a microcomputer according to the invention; 
     FIG. 2 is a timing chart for execution of an instruction by the CPU of FIG. 1; 
     FIG. 3 is a diagram showing signal flows in the CPU of FIG. 1; 
     FIG. 4 is a logic diagram of an address control circuit; 
     FIG. 5 is a timing chart for the address control circuit of FIG. 4; 
     FIG. 6 is a block diagram of the CPU of a conventional microcomputer; and 
     FIG. 7 is a timing chart for execution of an instruction by the CPU of FIG. 6. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     FIG. 1 shows the CPU of a microcomputer according to the invention. In this embodiment, the address and data bus widths are 24 and 16 bits, respectively. The CPU includes various registers, latches, an ALU, and internal buses for connecting these devices. That is to say, it includes a program counter (PC) 1, a program bank register (PBR) 2, a data bank register (DBR) 3, and a temporary register (TP3) 4 for temporarily storing the value incremented or decremented by one digit of the program bank register 2 or data bank register 3. The PC 1, and the PBR 2, DBR 3, and TP3 4 are 16-bit and 8-bit registers, respectively. The program bank register 2 holds the most significant 8 bits (AD 16  -AD 23 ) of an address in the program area and the data bank register 3 holds the most significant 8 bits of an address in the data area. Consequently, the program fetch is carried out from the address at which AD 16  -AD 23  and AD 0  -AD 15  are designated by the contents of the program bank register 2 and program counter 10, respectively. On the other hand, the data fetch is carried out from the address at which AD 16  -AD 23  and AD 0  -AD 15  are designated by the contents of the data bank register 3 and the value determined by the operation of the CPU during execution of the instruction, respectively. 
     The CPU further includes an arithmetic logic unit (ALU) 21, address latches (L1 and L2) 5 and 6, address adders (INC1 and INC2) 7 and 8, and a bank address (AD 16  -AD 23 ) control unit 9 into which carry signals K and C are input from the address adder 7 and the ALU 21, respectively, and various 16-bit registers 10-18; namely, a temporary register (TP1) for temporarily storing the computation results of the ALU 21, accumulators (A and B) 11 and 12, and index registers (X and Y) 13 and 14, and a stack pointer (S) 15, a direct page register (D) 16, a processor status register (PS) 17, a temporary register (TP2) 18 for temporarily storing data taken into the CPU from the data bus, and internal bus latches (L3 and L4) 19 and 20. Symbols o and o are gates responsive to a control signal from the control section to open when the reference clock of the CPU is a logic level high &#34;H&#34; and a logic level low &#34;L&#34;, respectively. 
     The operation of the microcomputer of the invention will be described. For example, how the CPU executes an instruction Load Accumulator A (LDA) in an absolute X addressing mode will be described. This instruction is composed of one byte of operation code and two bytes of operand and instructs that the contents of the address at which AD 0  -AD 15  and AD 16  -AD 23  are the sum of the 2-byte operand and the X-register contents, and the value of the data bank register, respectively, be stored in the A register. The timing chart for execution of this instruction and the signal flows within the CPU in cycles 24 and 25 are shown in FIGS. 2 and 3, respectively. 
     In FIG. 2, in cycles 22 and 23, the operation code and the operand are fetched and the operation code is decoded. At the same time, the previous instruction is executed in these cycles. Consequently, the LDA instruction is executed from the next cycle 24, in which the 2-byte operand (hhll) fetched in the temporary register (TP2) 18 and the contents of the X register are added in the ALU 21 and the sum is stored in the temporary register (TP1)10. At the same time, the contents of the data bank register 3 are incremented by one digit and stored in the temporary register (TP3) 4. 
     In the cycle 25, the contents of the temporary register 1 is output at AD 0  -AD 15  while the address of the previous cycle or value of the data bank register 3 is latched when the addition (X+hhll) in the previous cycle generates no carry signal or the value &#34;data bank register+1&#34; in the temporary register 3 is output at AD 16  -AD 23  when a carry signal is generated. The contents of the address designated with AD 0  -AD 23  is stored in the temporary register 2. In cycles 26 and 27, the fetched data is transferred to the temporary register 1 for flag checking and then stored in the accumulator A to complete execution of the instruction. 
     The operation of the bank address control unit 9 in FIG. 1 for controlling the address to be output at AD 16  -AD 23  in the cycles 24 and 25 will be described in more detail. FIGS. 4 and 5 show a logic diagram of the control unit 9 and the timing chart for operation of this unit in the cycles 24 and 25, respectively. The bank address control unit 9 consists of a carry control unit 28 and an address switching unit 29. Control signals S11 and S94 from the CPU control section and a carry signal K from the address adder 7 of FIG. 1 are input to the carry control unit 28. Normally, S11 and S94 are &#34;L&#34;, and a carry signal K from the address adder (INC1) 7 is input to the address adder (INC2) 8. 
     On the other hand, when S11=&#34;H&#34; and S94=&#34;L&#34; in the cycle 24 of FIG. 2, the input Ka to the address adder 8 is forced to be a logical &#34;1&#34;. Consequently, when the value of the data bank register 3 is input to the address adder 8 via L2, it is incremented by one digit and stored in the temporary register (TP3) 4. When S94=&#34;H&#34;, Ka is forced to be &#34;O&#34;. This is used for loading data in the program bank register 2 or data bank register 3. 
     The address switching unit 29 receives control signals S10, S22, and S23 from the control section and a carry signal C from the ALU 21 and outputs a signal S10a for controlling the address latch L2 and a signal 20a for controlling the read gate of the temporary register 4. In the cycle 25 of FIG. 2, this switching unit operates as follows. It is in the second half of the cycle 24 to determine whether a carry signal C is generated (&#34;1&#34;) or not (&#34;0&#34;) as a result of the addition (X+hhll) in the ALU 21. The control unit latches this value in Φ and holds until φ=&#34;H&#34;. 
     On the other hand, the control signals become S22 =&#34;H&#34; and S23 =&#34;L&#34; in the period between φ=&#34;L&#34; of the cycle 24 and φ=&#34;H&#34; of the cycle 25. Consequently, when a carry signal is generated (C=1), both S10a and S20a are &#34;H&#34; for φ=&#34;H&#34; of the cycle 25 so that the value of the temporary register 4 or value of the data bank register +1 is output on the address bus. Conversely, when no carry signal generated (C=0), both S10a and S20a are &#34;L&#34; so that the value of the previous cycle 24 (in the data bank register 3) is latched on the address bus. Thus, the bank address may be switched without increasing the number of instruction execution cycles. 
     If S22=&#34;L&#34; and S23=&#34;H&#34; in this control unit, the contents of the temporary register 4 are output on the address bus when C=&#34;0&#34; while the previous address is latched when C=&#34;1&#34; in contrast to the operation in the cycle 25. Thus, when a borrow signal is generated in the address subtraction in the ALU (C=0), the bank address is decremented by one digit. 
     While the carry operation in the absolute X addressing mode has been described, this principle is applicable to other addressing modes where a carry or borrow signal from the higher order address is generated in the address computation in the ALU, thus making address switching possible without providing an additional execution cycle for correction of the higher order address. That is to say, according to the invention, the higher order address may be corrected without providing an additional execution cycle while keeping the continuity in the whole memory space addressable in the address bus width. 
     While a preferred embodiment of the invention has been described using specific terms, such description is for illustrative purposes only, and it is to be understood that changes and variations may be made without departing from the spirit and scope of the appended claims.