{"id":396,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:00","modified_gmt":"2020-08-22T20:26:00","slug":"this-is-the-page-title-toplevel-229","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=396","title":{"rendered":"CPU Basics"},"content":{"rendered":"\n<title>CPU Basics<\/title>\n<p>\nThe <glossary>CPU<\/glossary>, or rather microprocessor, is the heart of any computer system.\nThe microprocessor  calculates, performs logical operations and\nmanages data flows by reading instructions from memory and then executing\nthem.\nIn the early days of computing the functional components of the\nmicroprocessor were separate (and physically large) units.\nThis is when the term <em>Central Processing Unit<\/em> was coined.\nThe modern microprocessor combines these components onto an\nintegrated circuit etched onto a very small piece of silicon.\nThe terms <em><glossary>CPU<\/glossary><\/em>, <em>microprocessor<\/em> and\n<em>processor<\/em> are all used interchangeably.\n<p>\nMicroprocessors operate on binary data; that is data composed of\nones and zeros.\nThese ones and zeros correspond to electrical switches being either\non or off.\nJust as 42 is a decimal number meaning &#8220;4 10s and 2 units&#8221;, a binary\nnumber is a series of binary digits each one representing a power\nof 2. In this context, a power means the number of times that\na number is multiplied by itself. 10 to the power 1 (\n10<sup>1<\/sup> ) is 10, 10 to\nthe power 2 ( 10<sup>2<\/sup> ) is 10&#215;10, 10<sup>3<\/sup> is 10x10x10 and so on.\nBinary 0001 is decimal 1, binary 0010 is decimal 2, binary 0011 is\n3, binary 0100 is 4 and so on.\nSo, 42 decimal is 101010 binary or\n(2 + 8 + 32 or 2<sup>1<\/sup> + 2<sup>3<\/sup> + 2<sup>5<\/sup> ).\nRather than using binary to represent numbers in computer programs,\nanother base, hexadecimal is usually used.\n<p>\nIn this base, each digital represents a power of 16.\nAs decimal numbers only go from 0 to 9, the numbers 10 to 15 are\nrepresented as a single digit by the letters A, B, C, D, E and F.\nFor example, hexadecimal E is decimal 14 and hexadecimal 2A is\ndecimal 42 (two 16s + 10).\nUsing the C programming language notation (as I do throughout this\nbook) hexadecimal numbers are prefaced by &#8220;<em>0x<\/em>&#8220;; hexadecimal\n2A is written as <em>0x2A<\/em> .\n<p>\nMicroprocessors can perform arithmetic operations such as add, multiply and\ndivide and logical operations such as &#8220;is X greater than Y?&#8221;.\n<p>\nThe processor&#8217;s execution is governed by an external clock.\nThis clock, the system clock, generates regular clock pulses to the\nprocessor and, at each clock pulse, the processor does some work.\nFor example, a processor could execute an instruction every clock\npulse.\nA processor&#8217;s speed is described in terms of the rate of the system\nclock ticks.\nA 100Mhz processor will receive 100,000,000 clock ticks every second.\nIt is misleading to describe the power of a <glossary>CPU<\/glossary> by its\nclock rate as different processors perform different amounts of work per\nclock tick. However, all things being equal, a faster clock speed means a more\npowerful processor.\nThe instructions executed by the processor are very simple; for example &#8220;read the\ncontents of memory at location X into <glossary>register<\/glossary> Y&#8221;.\nRegisters are the microprocessor&#8217;s internal storage, used for storing\ndata and performing operations on it.\nThe operations performed may cause the processor to stop what it is\ndoing and jump to another instruction somewhere else in memory.\nThese tiny building blocks give the modern microprocessor almost\nlimitless power as it can execute millions or even billions\nof instructions a second.\n<p>\nThe instructions have to be fetched from memory as they are executed.\nInstructions may themselves reference data within memory and that data must\nbe fetched from memory and saved there when appropriate.\n<p>\nThe size, number and type of <glossary>registers<\/glossary> within a microprocessor\nis entirely dependent on its type.\nAn Intel 4086 processor has a different <glossary>register<\/glossary> set to an\nAlpha AXP processor; for a start, the Intel&#8217;s are 32 bits wide and the\nAlpha AXP&#8217;s are 64 bits wide.\nIn general, though, any given processor will have a number of general purpose\n<glossary>register<\/glossary>s and a smaller number of dedicated registers.\nMost processors have the following special purpose, dedicated, registers:\n<dl compact>\n<p>\n\t<dt><b>Program Counter (PC)<\/b><\/dt><dd> This <glossary>register<\/glossary> contains the address of\n\tthe next instruction to be executed.  The contents of the PC are\n\tautomatically incremented each time an instruction is fetched.\n<p>\n\t<dt><b>Stack Pointer (SP)<\/b><\/dt><dd> Processors have to have access to large\n\tamounts of external read\/write random access memory (<glossary>RAM<\/glossary>) which facilitates\n\ttemporary storage of data.  The stack is a way of easily saving and\n\trestoring temporary values in external memory.  Usually, processors\n\thave special instructions which allow you to push values onto the\n\tstack and to pop them off again later.  The stack\n\tworks on a last in first out (LIFO) basis.\n\tIn other words, if you push two values, x and y, onto a stack and then pop\n\ta value off of the stack then you will get back the value of y.\n<p>\n\tSome processor&#8217;s stacks grow upwards towards the top of memory whilst others\n\tgrow downwards towards the bottom, or base, of memory.  Some processors\n\tsupport both types of stacks, for example ARM.\n<p>\n\t<dt><b>Processor Status (PS)<\/b><\/dt><dd> Instructions may yield results; for\n\texample &#8220;is the content of <glossary>register<\/glossary> X greater than the content of\n\t<glossary>register<\/glossary> Y?&#8221; will yield true or false as a result.  The PS <glossary>register<\/glossary>\n\tholds this and other information about the current state of the\n\tprocessor.   For example, most processors have at least two modes of operation,\n\tkernel (or supervisor) and user.  The PS <glossary>register<\/glossary> would hold information\n\tidentifying the current mode.\n<\/dl>\n<p>\nDetails on Intel-based CPUs can be found <site id=\"119\">here<\/site>.<br \/>\nDetails on Alpha AXP-based CPUs can be found <site id=\"122\">here<\/site>.<br \/>\nDetails on ARM-based CPUs can be found <site id=\"248\">here<\/site>.<br \/>\n","protected":false},"excerpt":{"rendered":"<p>CPU Basics The CPU, or rather microprocessor, is the heart of any computer system. The microprocessor calculates, performs logical operations and manages data flows by reading instructions from memory and then executing them. In the early days of computing the &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=396\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-396","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=396"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/396\/revisions"}],"predecessor-version":[{"id":532,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/396\/revisions\/532"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}