{"id":146,"date":"2016-12-29T14:03:41","date_gmt":"2016-12-29T14:03:41","guid":{"rendered":"http:\/\/teachcomputerscience.com\/?p=146"},"modified":"2024-07-24T13:06:19","modified_gmt":"2024-07-24T13:06:19","slug":"instructions","status":"publish","type":"post","link":"https:\/\/teachcomputerscience.com\/instructions\/","title":{"rendered":"Instructions"},"content":{"rendered":"<div class=\"gb-container gb-container-1c0eb502 upsell-block\"><div class=\"gb-inside-container\">\n<div class=\"gb-grid-wrapper gb-grid-wrapper-c012f01e\">\n<div class=\"gb-grid-column gb-grid-column-203a31c5\"><div class=\"gb-container gb-container-203a31c5\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-1da3cc58 gb-headline-text\">GCSE Basic Programming Constructs (14-16 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-a5f547b8\">\n\n<a class=\"gb-button gb-button-c3a33374 gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/gcse\/programming\/basic-programming-constructs\/\">View GCSE Basic Programming Constructs Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n\n<div class=\"gb-grid-column gb-grid-column-8ed17a9b\"><div class=\"gb-container gb-container-8ed17a9b\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-b03ba572 gb-headline-text\">A-Level Introduction to programming (16-18 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-5d7ffa49\">\n\n<a class=\"gb-button gb-button-7a24842d gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/a-level\/problem-solving-and-programming\/introduction-to-programming\/\">View A-Level Introduction to programming Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n\n<p class=\"wp-block-paragraph\">Candidates should be able to:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>explain how instructions are coded as bit patterns<\/li><li>explain how the computer distinguishes between instructions and data.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">How are program instructions coded?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Machine code instructions are binary numbers and are coded as bit patterns<\/strong>, for example, a 16-bit machine code instruction could be coded as 001010101101001011.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In machine code, <strong>the instructions are usually made up of 2 parts<\/strong>, an <strong>operator<\/strong> (op code) and an <strong>operand<\/strong> (typically a memory address). The CPU decodes the operator (for example, the <strong>bit pattern<\/strong> 001 could be the code for ADD) to decide what action to take with the operand.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The number of memory bits needed for each instruction (operator plus operand) is important. If only 8 bits were used then 3 bits could be used for the operation codes leaving 5 for the location in memory where the data is stored. This would however be very limiting as there could only be 8 possible operation codes and only memory addresses from 00000 to 11111 could be accessed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>particular CPU<\/strong> will be designed to <strong>process a particular set of machine code instructions<\/strong> and will know:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>How many bits are used for each <strong>instruction<\/strong>.<\/li><li>How many of the instruction bits are used for the <strong>operator<\/strong> (OP code) and how many for the <strong>operand<\/strong>.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The table below represents 9 memory addresses. Memory address <strong>00000<\/strong> holds an <strong>operator and operand<\/strong> (using 8 bits) and address <strong>00100<\/strong> holds some <strong>data<\/strong>. The CPU would follow the <strong>instruction<\/strong> and <strong>ADD<\/strong> the value in memory location <strong>00100<\/strong> to the accumulator.<\/p>\n\n\n\n<figure class=\"wp-block-table rcp-table\"><table><tbody><tr><th>Memory address<\/th><th>Memory contents<\/th><th>Explanation<\/th><\/tr><tr><td><span class=\"style11\"><strong>00000<\/strong><\/span><\/td><td><span class=\"style6\"><strong>001<\/strong><\/span><span class=\"style8\"><strong>00100<\/strong><\/span><\/td><td>This memory address has an <strong>instruction<\/strong> stored in it, made up of<span class=\"body\">:<br>&#8211; <\/span>the <strong><span class=\"style6\">operator <\/span><\/strong>(<em>in this case the code for <\/em><strong><span class=\"style6\">ADD<\/span><\/strong><em> the contents of &nbsp;a memory address to the contents of the accumulator<\/em>)<br>&#8211; the <strong><span class=\"style8\">operand<\/span><\/strong> (<em>in this case, the <\/em><strong><span class=\"style8\">memory address<\/span><\/strong><em> of the data to be added to the accumulator<\/em>).<\/td><\/tr><tr><td>00001<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><tr><td>00011<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><tr><td><strong>00100<\/strong><\/td><td><strong>00010101<\/strong><\/td><td>This memory address has <strong>data<\/strong><span class=\"body\"> stored in it <\/span>(<em>in this case the number 21 stored i<\/em><span class=\"body\"><em>n<\/em><\/span><em> binary<\/em>)<\/td><\/tr><tr><td>00101<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><tr><td>00110<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><tr><td>00111<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><tr><td>01000<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><tr><td>01001<\/td><td>00000000<\/td><td>&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">How does the computer distinguish between instructions and data?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the <strong>Von Neumann architecture<\/strong> used by most computers <strong>memory locations are used to store both program instructions and data<\/strong>. The CPU <strong>cannot, therefore,<\/strong> distinguish between instructions and data just by reading the bit pattern stored at a memory address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The CPU program counter should therefore always contain the memory location of <strong>instruction<\/strong>. If the CPU is instead pointed to a memory address that contains data (either by mistake or because instruction has somehow been overwritten by data) then the program would fail to run correctly because the CPU would try and interpret the data as an instruction.<\/p>\n\n\n\n<h3 class=\"gb-headline gb-headline-0cf95000 gb-headline-text\">Further Readings: <\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Programmed_learning\" target=\"_blank\" rel=\"noopener\">Programmed learning<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Candidates should be able to: explain how instructions are coded as bit patterns explain how the computer distinguishes between instructions and data. How are program instructions coded? Machine code instructions are binary numbers and are coded as bit patterns, for example, a 16-bit machine code instruction could be coded as 001010101101001011. In machine code, the &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Instructions\" class=\"read-more button\" href=\"https:\/\/teachcomputerscience.com\/instructions\/\" aria-label=\"Read more about Instructions\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[27],"tags":[204,47],"class_list":["post-146","post","type-post","status-publish","format-standard","hentry","category-data-representation","tag-article","tag-hide-old-upsell","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"acf":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":1,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":605748,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/146\/revisions\/605748"}],"wp:attachment":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}