Computer Science
Program Counter
The program counter is a register in a computer processor that stores the memory address of the next instruction to be executed. It keeps track of the current position in the program's sequence of instructions, allowing the processor to fetch the next instruction from memory and execute it. The program counter is a crucial component in the control flow of a computer program.
Written by Perlego with AI-assistance
Related key terms
1 of 5
4 Key excerpts on "Program Counter"
- eBook - PDF
Microprocessors
Principles and Applications
- Michael J. Debenham(Author)
- 2013(Publication Date)
- Pergamon(Publisher)
The bits stored in any memory byte may represent an instruction or data. Program Counter The Program Counter is usually a 16 bit register which is a c c e s s i b l e to the programmer and whose contents indicate the address of the next instruction to be obeyed. A program will be stored in memory a s a sequence of bytes which represent the instructions of the program. Just before each instruction is e x e c u t e d , the Program Counter is advanced to the address of the next sequential instruction. However, upon examining a memory byte there is no way of deciding whether the byte contains an instruction or d a t a . In order to avoid errors, the programmer must be sure that a data byte does not follow an instruction when another instruction was expected. 32 M i c r o p r o c e s s o r s , P r i n c i p l e s and A p p l i c a t i o n s Addressing The addressing of data and program segments in store is an area that presents enormous variations from computer to computer. The problem is to allow references to be made to any arbitrary word in the addressing s p a c e , yet eliminate the need for a full set of address bits in each and every instruction. If the full address is required in each instruction, program sizes tend to grow. Nearly all microprocessors take advantage of the fact that most data and program references are local in scope; that i s , references are most often c l o s e to the address of the current instruction being executed or c l o s e to the last piece of data referenced in main storage. 'Direct' addresses are the most common kind, and are represented by instructions that contain a storage address wide enough to refer to any point in main storage. 'A'bbreviated' addresses are similar to direct addresses but only part of the address is carried in the instruction. The rest of the bits of the address are contained in a register that is usually part of the CPU; this register may be loaded by a special instruction. - Dale R. Patrick, Stephen W. Fardo(Authors)
- 2021(Publication Date)
- River Publishers(Publisher)
Address Registers Address registers are used in microprocessors to temporarily store the address of a memory location that is to be accessed for data. In some units, this register may be programmable. This means that it permits instructions to alter its contents. The program can also be used to build an address in the register prior to executing a memory reference instruction. Program Counter The Program Counter of a microprocessor is a memory device that holds the address of the next instruction to be executed in a program. As a general rule, this unit counts the instructions of a program in sequential order. When the MPU has fetched instructions addressed by the Program Counter, the count advances to the next location. At any given point during the sequence, the counter indicates the location in memory from which the next piece of information will be derived. The numbering sequence of the Program Counter may be modified so that the next count may not follow a numerical order. Through this procedure, the counter may be programmed to jump from one point to another in a routine. This permits the MPU to have branching capabilities should the need arise. Instruction Decoders Each specific operation that the MPU can perform is identified by an exclusive binary number known as an instruction code. Eight-bit words are commonly used for this code. Exactly 2 8 or 256 10 separate or alternative operations can be represented by this code. After a typical instruction code is pulled from memory and placed in the data register, it must be decoded. The instruction decoder examines the coded word and decides which op-eration is to be performed by the ALU. Sequence Controllers The sequence controller performs a number of vital functions in the operation of the microprocessor. Using clock inputs, this circuitry main-tains the proper sequence of events required to perform a processing task.- eBook - ePub
- Ian Sinclair(Author)
- 2011(Publication Date)
- Newnes(Publisher)
The exception is in the case of a jump, caused by an interrupt (see later) or by a software instruction. A jump in this sense means that a new address will be placed into the Program Counter register, and the microprocessor will then read a new instruction starting at this address and incrementing the address number at the end of each instruction. For the moment, however, the important point is that the normal action is one of incrementing the memory address each time a program action has been executed, and the sequence of actions is all important. Note Many microprocessors are designed so that they will automatically read a byte from some fixed address when they start operating. This byte is always a jump instruction, followed by data, that will cause another address range to be used. This allows the programmer to specify where the main program will be located. Note The Program Counter (PC) or instruction pointer (IP) register is the main addressing register, and is connected by gates to the address pins of the microprocessor. The number in this register will be initialized by a voltage applied to a RESET pin, and it is automatically incremented each time an instruction has been executed, or when an instruction calls for another byte. Imagine, for example, that the whole of the RAM memory from address 0000 is filled with an NOP instruction byte. NOP means no operation, and its action is simply to do nothing, just go on to the next instruction. If the PC is reset to contain the address 0000, then the NOP byte (which might be 00) at this address will be read, decoded, and acted on - eBook - PDF
Computer Organisation and Architecture
An Introduction
- B.S. Chalk, Antony Carter, Robert Hind(Authors)
- 2017(Publication Date)
- Red Globe Press(Publisher)
C H A P T E R 42 Central processor unit operation At the heart of a microcomputer system lies the Central Processor Unit (CPU) or processor . The processor runs a program by repeatedly fetching and executing instructions from main memory. By using a step-by-step approach, this chapter outlines the way in which this is done using a highly simplified processor. This will provide a foundation for understanding the operation of a real processor in Chapter 5. This chapter and Chapter 5 deal with the principles of machine code and assembly language programming . Machine code is the native code of the processor while assembly language is a more programmer friendly language that is translated into machine code by a program called an assembler . The full treatment of machine code and assembly language programming are found in other texts, some of which are listed in the references at the end of the book. The purpose of this chapter and the next is to explain and demonstrate how the components of a processor work together to carry out tasks. 4.1 CPU details In Chapter 1 we identified the role of the data, address and control buses for transferring data between the processor and other system components, selecting a memory or I/O device and for synchronising the operation of system components respectively. In Figure 4.1 we see how the system buses relate to internal processor elements. In this simplified CPU architecture only memory read and write control signals are shown. IP is the Instruction Pointer . This is the name used by Intel in their processors, although Program Counter is a name commonly used for this register. A register is a memory location within the processor. A is the name we have given to a general purpose register within the processor. Such registers are sometimes referred to as accumulators . The Memory Address Register (MAR) holds data going on to the address bus. The Memory Buffer Register (MBR) holds data going to/from the data bus.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.



