Share to: share facebook share twitter share wa share telegram print page

Program counter

Front panel of an IBM 701 computer introduced in 1952. Lights in the middle display the contents of various registers. The instruction counter is at the lower left.

The program counter (PC),[1] commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR),[2][1] the instruction counter,[3] or just part of the instruction sequencer,[4] is a processor register that indicates where a computer is in its program sequence.[5][nb 1]

Usually, the PC is incremented after fetching an instruction, and holds the memory address of ("points to") the next instruction that would be executed.[6][nb 2]

Processors usually fetch instructions sequentially from memory, but control transfer instructions change the sequence by placing a new value in the PC. These include branches (sometimes called jumps), subroutine calls, and returns. A transfer that is conditional on the truth of some assertion lets the computer follow a different sequence under different conditions.

A branch provides that the next instruction is fetched from elsewhere in memory. A subroutine call not only branches but saves the preceding contents of the PC somewhere. A return retrieves the saved contents of the PC and places it back in the PC, resuming sequential execution with the instruction following the subroutine call.

Hardware implementation

In a simple central processing unit (CPU), the PC is a digital counter (which is the origin of the term "program counter") that may be one of several hardware registers. The instruction cycle[8] begins with a fetch, in which the CPU places the value of the PC on the address bus to send it to the memory. The memory responds by sending the contents of that memory location on the data bus. (This is the stored-program computer model, in which a single memory space contains both executable instructions and ordinary data.[9]) Following the fetch, the CPU proceeds to execution, taking some action based on the memory contents that it obtained. At some point in this cycle, the PC will be modified so that the next instruction executed is a different one (typically, incremented so that the next instruction is the one starting at the memory address immediately following the last memory location of the current instruction).

Like other processor registers, the PC may be a bank of binary latches, each one representing one bit of the value of the PC.[10] The number of bits (the width of the PC) relates to the processor architecture. For instance, a “32-bit” CPU may use 32 bits to be able to address 232 units of memory. On some processors, the width of the program counter instead depends on the addressable memory; for example, some AVR microcontrollers have a PC which wraps around after 12 bits.[11]

If the PC is a binary counter, it may increment when a pulse is applied to its COUNT UP input, or the CPU may compute some other value and load it into the PC by a pulse to its LOAD input.[12]

To identify the current instruction, the PC may be combined with other registers that identify a segment or page. This approach permits a PC with fewer bits by assuming that most memory units of interest are within the current vicinity.

Consequences in machine architecture

Use of a PC that normally increments assumes that what a computer does is execute a usually linear sequence of instructions. Such a PC is central to the von Neumann architecture. Thus programmers write a sequential control flow even for algorithms that do not have to be sequential. The resulting “von Neumann bottleneck” led to research into parallel computing,[13] including non-von Neumann or dataflow models that did not use a PC; for example, rather than specifying sequential steps, the high-level programmer might specify desired function and the low-level programmer might specify this using combinatory logic.

This research also led to ways to making conventional, PC-based, CPUs run faster, including:

  • Pipelining, in which different hardware in the CPU executes different phases of multiple instructions simultaneously.
  • The very long instruction word (VLIW) architecture, where a single instruction can achieve multiple effects.
  • Techniques to predict out-of-order execution and prepare subsequent instructions for execution outside the regular sequence.

Consequences in high-level programming

Modern high-level programming languages still follow the sequential-execution model and, indeed, a common way of identifying programming errors is with a “procedure execution” in which the programmer's finger identifies the point of execution as a PC would. The high-level language is essentially the machine language of a virtual machine,[14] too complex to be built as hardware but instead emulated or interpreted by software.

However, new programming models transcend sequential-execution programming:

  • When writing a multi-threaded program, the programmer may write each thread as a sequence of instructions without specifying the timing of any instruction relative to instructions in other threads.
  • In event-driven programming, the programmer may write sequences of instructions to respond to events without specifying an overall sequence for the program.
  • In dataflow programming, the programmer may write each section of a computing pipeline without specifying the timing relative to other sections.

See also

Notes

  1. ^ For modern processors, the concept of "where it is in its sequence" is too simplistic, as instruction-level parallelism and out-of-order execution may occur.
  2. ^ In a processor where the incrementation precedes the fetch, the PC points to the current instruction being executed. In some processors, the PC points some distance beyond the current instruction; for instance, in the ARM7, the value of PC visible to the programmer points beyond the current instruction and beyond the delay slot.[7]

References

  1. ^ a b Hayes, John P. (1978). Computer Architecture and Organization. McGraw-Hill. p. 245. ISBN 0-07-027363-4.
  2. ^ Mead, Carver; Conway, Lynn (1980). Introduction to VLSI Systems. Reading, USA: Addison-Wesley. ISBN 0-201-04358-0.
  3. ^ Principles of Operation, Type 701 and Associated Equipment (PDF). IBM. 1953.
  4. ^ Harry Katzan (1971), Computer Organization and the System/370, Van Nostrand Reinhold Company, New York, USA, LCCCN 72-153191
  5. ^ Bates, Martin (2011). "Microcontroller Operation". PIC Microcontrollers. Elsevier. p. 27–44. doi:10.1016/b978-0-08-096911-4.10002-3. ISBN 978-0-08-096911-4. Program Counter (PC) is a register that keeps track of the program sequence, by storing the address of the instruction currently being executed. It is automatically loaded with zero when the chip is powered up or reset. As each instruction is executed, PC is incremented (increased by one) to point to the next instruction.
  6. ^ Silberschatz, Abraham; Gagne, Greg; Galvin, Peter B. (April 2018). Operating System Concepts. United States: Wiley. pp. 27, G-29. ISBN 978-1-119-32091-3.
  7. ^ "ARM Developer Suite, Assembler Guide. Version 1.2". ARM Limited. 2001. Retrieved 2019-10-18.
  8. ^ John L. Hennessy and David A. Patterson (1990), Computer Architecture: a quantitative approach, Morgan Kaufmann Publishers, Palo Alto, USA, ISBN 1-55860-069-8
  9. ^ B. Randall (1982), The Origins of Digital Computers, Springer-Verlag, Berlin, D
  10. ^ C. Gordon Bell and Allen Newell (1971), Computer Structures: Readings and Examples, McGraw-Hill Book Company, New York, USA
  11. ^ Arnold, Alfred (2020) [1996, 1989]. "E. Predefined Symbols". Macro Assembler AS – User's Manual. V1.42. Translated by Arnold, Alfred; Hilse, Stefan; Kanthak, Stephan; Sellke, Oliver; De Tomasi, Vittorio. p. Table E.3: Predefined Symbols – Part 3. Archived from the original on 2020-02-28. Retrieved 2020-02-28. 3.2.12. WRAPMODE […] AS will assume that the processor's program counter does not have the full length of 16 bits given by the architecture, but instead a length that is exactly sufficient to address the internal ROM. For example, in case of the AT90S8515, this means 12 bits, corresponding to 4 Kwords or 8 Kbytes. This assumption allows relative branches from the ROM's beginning to the end and vice versa which would result in an out-of-branch error when using strict arithmetics. Here, they work because the carry bits resulting from the target address computation are discarded. […] In case of the abovementioned AT90S8515, this option is even necessary because it is the only way to perform a direct jump through the complete address space […]
  12. ^ Walker, B. S. (1967). Introduction to Computer Engineering. London, UK: University of London Press. ISBN 0-340-06831-0.
  13. ^ F. B. Chambers, D. A. Duce and G. P. Jones (1984), Distributed Computing, Academic Press, Orlando, USA, ISBN 0-12-167350-2
  14. ^ Douglas Hofstadter (1980), Gödel, Escher, Bach: an eternal golden braid, Penguin Books, Harmondsworth, UK, ISBN 0-14-005579-7

Read other articles:

Steyr AUG, salah satu senapan bullpup yang paling sukses. Bullpup adalah konfigurasi senjata api, di mana mekanisme dan magazennya terletak di belakang pelatuk. Konfigurasi seperti ini meningkatkan perbandingan panjang laras terhadap panjang total senapan, yang memungkinkan membuat senapan yang larasnya sama dengan laras senapan biasa, tetapi total panjang senapan lebih pendek. Keuntungannya selain lebih pendek, juga relatif lebih ringan. Konsep konfigurasi seperti ini sudah muncul sejak sebelum…

Artikel ini perlu diwikifikasi agar memenuhi standar kualitas Wikipedia. Anda dapat memberikan bantuan berupa penambahan pranala dalam, atau dengan merapikan tata letak dari artikel ini. Untuk keterangan lebih lanjut, klik [tampil] di bagian kanan. Mengganti markah HTML dengan markah wiki bila dimungkinkan. Tambahkan pranala wiki. Bila dirasa perlu, buatlah pautan ke artikel wiki lainnya dengan cara menambahkan [[ dan ]] pada kata yang bersangkutan (lihat WP:LINK untuk keterangan lebih lanjut). …

Koordinat: 59°20′5″N 18°6′5″E / 59.33472°N 18.10139°E / 59.33472; 18.10139 Sveriges RadioSR logoNama sebelumnyaRadiotjänst (1925-1957)JenisPenyiaran masyarakatNegaraSwediaKetersediaanNasionalTanggal peluncuran1 Januari 1925; 99 tahun lalu (1925-01-01) (radio)4 September 1956; 67 tahun lalu (1956-09-04) (television)Situs webwww.sverigesradio.se Gedung Sveriges Radio di Stockholm Sveriges Radio AB (pengucapan bahasa Swedia: [ˈsværˈjɛs ˈ…

Wakil Menteri Luar Negeri IndonesiaPetahanaPahala Mansurysejak 17 Juli 2023Dibentuk2 September 1945Pejabat pertamaMr. Achmad Soebardjo Berikut adalah daftar orang yang pernah menjabat sebagai Wakil Menteri Luar Negeri (Wamenlu) atau Menteri Muda Luar Negeri Indonesia. No Foto Nama Kabinet Menteri Luar Negeri Dari Sampai Keterangan 1 H. Agus Salim Sjahrir II Sutan Syahrir 12 Maret 1946 2 Oktober 1946 [note 1] Syahrir III 2 Oktober 1946 26 Juni 1947 2 Mr. Tamzil St. Narajau Amir Sjari…

Part of a series onBritish law Acts of Parliament of the United Kingdom Year      1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879…

TyranationAlbum studio karya DeadsquadDirilis30 Oktober 2016DirekamDesember 2015Studio Noiselab Studio Maleeh Soundlab Slingshot Studio Genre Death metal teknikal Durasi41:14Label M8 Records Demajors[1] Produser Deadsquad Jeff Adriano Kronologi Deadsquad Profanatik(2013) Tyranation(2016) Catharsis(2022) Tyranation adalah album studio ketiga karya Deadsquad yang dirilis pada 30 Oktober 2016, yang merupakan bagian dari upaya untuk membuktikan bahwa karya musik umumnya tidak mengenal ba…

Bagian dari seri tentangBuddhisme SejarahPenyebaran Sejarah Garis waktu Sidang Buddhis Jalur Sutra Benua Asia Tenggara Asia Timur Asia Tengah Timur Tengah Dunia Barat Australia Oseania Amerika Eropa Afrika Populasi signifikan Tiongkok Thailand Jepang Myanmar Sri Lanka Vietnam Kamboja Korea Taiwan India Malaysia Laos Indonesia Amerika Serikat Singapura AliranTradisi Buddhisme prasektarian Aliran Buddhis awal Mahāsāṃghika Sthaviravāda Aliran kontemporer Theravāda Mahāyāna Vajrayāna Konsen…

كأس بلغاريا 1946 تفاصيل الموسم كأس بلغاريا  النسخة 6  البلد بلغاريا  المنظم اتحاد بلغاريا لكرة القدم  البطل ليفسكي صوفيا  كأس بلغاريا 1942  كأس بلغاريا 1947  تعديل مصدري - تعديل   كأس بلغاريا 1946 هو موسم من كأس بلغاريا. أشرف على تنظيمه اتحاد بلغاريا لكرة القدم، وفا…

1924 film The Back TrailDirected byGeorge MarshallClifford SmithWritten byIsadore BernsteinWalter J. CoburnGeorge HoagProduced byCarl LaemmleStarringJack HoxieEugenia GilbertAl HoxieCinematographyHarry NeumannProductioncompanyUniversal PicturesDistributed byUniversal PicturesRelease dateJune 16, 1924Running time50 minutesCountryUnited StatesLanguagesSilentEnglish intertitles The Back Trail is a 1924 American silent Western film directed by George Marshall and Clifford Smith and starring Jack Hox…

Questa voce sull'argomento stagioni delle società calcistiche italiane è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Segui i suggerimenti del progetto di riferimento. Voce principale: Associazione Calcio Cuneo 1905. Cuneo SportivaStagione 1989-1990 Sport calcio Squadra Cuneo Allenatore Lorenzo Barlassina Presidente Mario Sanino Serie C28º nel girone A Maggiori presenzeCampionato: Benzi (33) Miglior marcatoreCampionato: Rocca (7) 1988-1989 1990-19…

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article needs to be updated. Please help update this article to reflect recent events or newly available information. (March 2013) This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help improve this article by introducing more precise cit…

National Historical Park of the United States United States historic placeMorristown National Historical ParkU.S. National Register of Historic PlacesU.S. National Historical ParkNew Jersey Register of Historic Places Ford Mansion, Washington's headquarters in Morristown, New JerseyShow map of Morris County, New JerseyShow map of New JerseyShow map of the United StatesLocationIn and around Morristown, New JerseyCoordinates40°47′47″N 74°28′0″W / 40.79639°N 74.46667°W&#…

Groove MusicasoftwareLogoGroove Musica su Windows 10Groove Musica su Windows 10 GenereLettore multimediale SviluppatoreMicrosoft Data prima versione2006 Ultima versione11.2202.45.0 Sistema operativoWindows 8Windows 8.1 (non in lista)Windows 10 Licenza(licenza non libera) Sito webmusic.microsoft.com Modifica dati su Wikidata · Manuale Groove Musica (precedentemente Xbox Music) è un lettore multimediale integrato in Windows 8, Windows 8.1 e Windows 10. Indice 1…

Luciano LamaLuciano Lama nell'ottobre 1986 Sindaco di AmeliaDurata mandato17 luglio 1988 –31 maggio 1996 SuccessoreFabrizio Bellini Segretario generale della CGILDurata mandato24 marzo 1970 –28 febbraio 1986 PredecessoreAgostino Novella SuccessoreAntonio Pizzinato Segretario generale della FIOMDurata mandato1º gennaio 1957 –1º gennaio 1961 PredecessoreAgostino Novella SuccessorePiero BoniBruno Trentin Vicepresidente del Senato della RepubblicaDur…

Railway station in West Yorkshire, England Not to be confused with Ford and Crossgates railway station in Shropshire. Cross GatesView of Cross Gates railway station taken from the road bridge November 2023General informationLocationCross Gates, City of LeedsEnglandCoordinates53°48′18″N 1°27′00″W / 53.805°N 1.450°W / 53.805; -1.450Grid referenceSE363344Managed byNorthernTransit authorityWest Yorkshire (Metro)Platforms2Other informationStation codeCRGFare zone2C…

هذه المقالة عن المجموعة العرقية الأتراك وليس عن من يحملون جنسية الجمهورية التركية أتراكTürkler (بالتركية) التعداد الكليالتعداد 70~83 مليون نسمةمناطق الوجود المميزةالبلد  القائمة ... تركياألمانياسورياالعراقبلغارياالولايات المتحدةفرنساالمملكة المتحدةهولنداالنمساأسترالياب…

ID; Peace BSingel oleh BoAdari album LISTEN TO MY HEARTDirilis30 Mei 2001FormatCDDirekam?GenrePopLabelAvex TraxProduser? ID; Peace B adalah singel debut penyanyi Korea Selatan, BoA. Lagu ID; Peace B Dreams come true ID; Peace B (Instrumental) Dreams come true (Instrumental) ID; Peace B (English Version) lbsBoAKoreaAlbum Studio ID; Peace B • No.1 • Atlantis Princess • My Name • Girls on Top  • Hurricane Venus  &#…

Chinese politician in the 19th century Not to be confused with Wu Dechang. Wu Dacheng Wu Dacheng (1835–1902)[1] was a Chinese politician, governor, author, artist, and collector during the Qing dynasty.[2] Life Wu grew up in a scholarly home.[2] While living in Suzhou, he succeeded the imperial examination. In the next two decades, he had many jobs and positions.[3] One of the positions included being a Qing officer.[4] Governor of Hunan Dacheng was …

Mineralogical term for the visible shape of a mineral This article is about the descriptive term used in mineralogy. For the addictive drug, see crystal methamphetamine. Smoky quartz with spessartine on top of feldspar matrix, featuring different crystal habits (shapes) In mineralogy, crystal habit is the characteristic external shape of an individual crystal or aggregate of crystals. The habit of a crystal is dependent on its crystallographic form and growth conditions, which generally creates …

此条目序言章节没有充分总结全文内容要点。 (2019年3月21日)请考虑扩充序言,清晰概述条目所有重點。请在条目的讨论页讨论此问题。 哈萨克斯坦總統哈薩克總統旗現任Қасым-Жомарт Кемелұлы Тоқаев卡瑟姆若马尔特·托卡耶夫自2019年3月20日在任任期7年首任努尔苏丹·纳扎尔巴耶夫设立1990年4月24日(哈薩克蘇維埃社會主義共和國總統) 哈萨克斯坦 哈萨克斯坦政府與…

Kembali kehalaman sebelumnya