































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































































Instruction Cycle. Memory: Reference Instructions- Input โ Output and Interrupt , Addressing Modes, DATA Transfer and Manipulation, Program Control COMPUTER ARITHMETIC : Addition and Subtraction, Multiplication Algorithms, Division Algorithms, Floating โ Point Arithmetic Operations, Decimal Arithmetic Unit, Decimal Arithmetic Operations. INSTRUCTION CYCLE: ๏ The program consists of a sequence of instructions. The program is executed in the computer by going through a cycle for each instruction. each instruction cycle in turn is subdivided in to a sequence of sub cycles or phrases. ๏ Instruction cycle consists of following phrases
๏ At time To, AR is connected to the address inputs of memory, it is necessary to transfer the address from PC to AR during the clock transition associated with timing signal T 0. ๏ The instruction read from memory is then placed in the instruction register with the clock transition associated with timing signal T 1. At the same time, it is incremented by one to prepare it for the address of the next instruction in the program. ๏ At the time T 2 , the operation code in IR is decoded, the indirect bit is transferred to flip flop I and the address part of the instructions is transferred to AR. ๏ Note that SC is incremented after each clock pulse to produce the sequence T0,T 1
D 7 I^1 T 3 = r (common to all register reference instructions) IR (i) = Bi [bit in IR (0- 1 1) that specifies the operation] The control function is distinguished by one of the bits in IR(0-11). By assigning the symbol Bi to bit i of IR, all control functions can be simply denoted by rBi. Ex: The instruction CLA has hexadecimal code 7800=0111 1000 00000 0000. The first bit is a zero which is equivalent to I^1. The next three bits constitute the operation code and are recognized from decoder output D 7. Bit 11 in IR is 1 & is recognized from B 11. The control function which initiates the micro operation for this instruction is D 7 I^1 T 3 B 11 =rB 11
๏ The decoded output Di for i=0, 1, 2, 3, 4, 5, 6 from the operation decoder that belongs to each instruction is included in the table. ๏ The effective address of the instruction is in the address register AR and was placed there during timing signal T 2 when I=0 or during timing signal T 3 when I=1. ๏ The execution of the memory reference instructions starts with timing signal T 4. AND to AC: This is an instruction that performs the AND logic operation on pairs of bits in AC and the memory word specified by the effective address. The result of the operation is transferred to AC. ADD TO AC : This instruction adds the content of the memory word specified by the effective address to the value of AC. The sum is transferred into AC and the output carry Cout is
Instructions and data stored in memory must come from some input device. Computational results must be transmitted to the user through some output device. Commercial computers include many types of input and output devices. ๏ The terminal sends and receives serial information. Each quantity of information has 8 bits of an alphanumeric code. ๏ The serial information from the keyboard is shifted into the input register INPR. The serial information for the printer is stored in the output register OUTR. These two registers communicate with a communication interface serially and with the AC in parallel.
๏ The INP instruction transfers the input information from INPR into the 8 low-order bits of AC and also clears the input flag to 0. ๏ The OUT instruction transfers the 8 LSBs of AC into the output register OUTR and clears the output flag to 0. ๏ If the flag is 1, the branch instruction is skipped and an input or output instruction is executed. ๏ The last two instructions are set and clear an interrupt enable flip flop IEN. PROGRAM INTERRUPT: ๏ When IEN is cleared to 0, the flags cannot interrupt the computer. ๏ When IEN is set to 1, the computer can be interrupted. ๏ An interrupt flip-flop R is included in the computer. When R=0, the computer goes through an instruction cycle. ๏ During the execute phase of the instruction cycle IEN is checked by the control. If it is 0, it indicates that the programmer does not want to use the interrupt, So control continues with the next instruction cycle. If IEN is 1, control checks the flag bits, If both flags are 0, it indicates that neither the input nor the output registers are ready for transfer of information.
๏ In this case, control continues with the next instruction cycle. If either flag is set to 1 while IEN=1, flip flop R is set to 1. ๏ At the end of the execute phase, control checks the value of R, and if it is equal to 1, it goes to an interrupt cycle instead of an instruction cycle. ๏ The interrupt cycle is a hardware implementation of a branch and save return address operation. The return address available in PC is stored in a specific location where it can be found later when the program return to the instruction at which it was interrupted. This location may be a processor register, a memory stack, or a specific memory location.
The interrupt cycle is initiated after the last execute phase if the interrupt flip-flop R is equal to 1. This flip-flop is set to 1 if IEN=1and either FGI or FGO are equal to 1. This can happen with any clock transition except when timing signals To, T 1 orT 2 are active. The condition for setting flip-flop R to 1can be expressed as The symbol โ+โ indicates logic OR operation between FGI and FGO. This is AND with IEN and Toโ T1โ T2โ. The interrupt cycle stores the return address (available in PC) into memory location 0, branches to memory location 1, and clears IEN, R & SC too. This can be done with the following sequence of micro operations ๏ During the first timing signal AR is cleared to 0,and the content of PC is transferred to the temporary register TR. ๏ With the second timing signal, the return address is stored in memory at location 0 and PC is closed to 0. ๏ The third timing signal increments PC to 1, clears IEN and R and control goes back to To by clearing SC to 0.
The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. Computers use addressing mode techniques for the purpose of accommodating one or both of the following precisions.
Relative addressing mode: This addressing mode is commonly used to specify the target address in the branch instructions. Example: JNZ BACK This instruction causes program execution to go to the branch target location identified by the name BACK, if the branch condition is satisfied. The branch target location can be determined by specifying it an offset from the current value of the program counter. Indexed addressing mode: The effective address of the operand is generated by adding a constant value to the contents of a register. EXAMPLE: MOVE 20 (R1), R The above instruction loads the contents of register R2 into the memory location whose location whose address is calculated by addition of the contents of register R1 and constant value 20. DATA TRANSFER AND MANIPULATION: Most computer instructions can be classified into three categories:
LOAD: The load instruction has been used mostly to designate a transfer from memory to a processor register, usually an accumulator. Store : The store instruction designates a transfer from a processor to memory. Move : The move instruction has been used in computer with multiple CPU registers to designate a transfer from one register to another. It has also been used for data transfers between CPU registers and memory or between two memory words. EXCHANGE: The exchange instruction swaps information between two registers or a registers and a memory word. INPUT-OUTPUT: The input and output instructions transfer data among processor registers and input or output terminals. PUSH-POP: The push-pop instructions transfer data between processor registers and a memory stack.
Logical and bit manipulation: ๏ There are three bit manipulation operations possible: a selected bit can be cleared to 0, or can be set to 1, or can be complemented. ๏ The AND Instruction is used to clear a bit or a selected group of bits of an operand. For any Boolean variable x, the relationships x b0 = 0 and x b1=x dictate that a binary value ANDed with a 0 produces a 0; but the variable does not change in value when ANDed with a 1. ๏ The OR instruction is used to set a bit or a selected group of bits of an operand. For any Boolean variable x, the relationships x+1=1 and x+0=x dictate that a binary variable ORed with a 1 produces a 1; but the variable does not change when ORed with a 0. ๏ The XOR instruction is used to selectively complement bits of an operand. This is because of the boolean relationships x 1=x and x 0=x.
Shift Instructions: ๏ Shifts are operations in which the bits of a word are moved to the left or right. The bit shifted in at the end of the word determines the type of shift used. Shift instructions may specify either logical shifts , arithmetic shifts , or rotate type operations. In either case the shift may be to the right or the left ๏ The logical shift inserts 0 to the end position. The end position is the left more bit for shift right and the right most bit position for the shift left. ๏ The Rotate instructions produce a circular shift. Bits shifted out at one end of the word are not lost as in a logical Shift but are circulated back into the other end. ๏ To rotate through carry instruction treats a carry bit as an extension of the register whose word is being rotated. ๏ A rotate left through carry instruction carry instruction treats the carry bit into the right most bit position of the register, transfers the left most bit position into the carry, and at the same time, shifts the entire register to the left. ๏ The arithmetic shift right instruction must preserve the sign bit in left most position. The sign bit is shifted to right together with the rest of the number, but the sign bit itself remains unchanged. ๏ The arithmetic Shift left inserts 0 to the end position and itself it is identical to the logical shift โ left.