{"id":1404,"date":"2021-01-18T23:42:17","date_gmt":"2021-01-18T23:42:17","guid":{"rendered":"http:\/\/learnlearn.uk\/alevelcs\/?page_id=1404"},"modified":"2021-03-08T06:13:52","modified_gmt":"2021-03-08T06:13:52","slug":"bitwise-operations","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/","title":{"rendered":"Bit Manipulation &#038; Bitwise Operations"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Bitwise Operations<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Bitwise Operations Tutorial<\/h3>\n<div class=\"nv-iframe-embed\">\n<div class=\"container-lazyload preview-lazyload container-youtube js-lazyload--not-loaded\"><a href=\"https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs\" class=\"lazy-load-youtube preview-lazyload preview-youtube\" data-video-title=\"Bitwise Operations &amp; Bit Masking\" title=\"Play video &quot;Bitwise Operations &amp; Bit Masking&quot;\">https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs<\/a><noscript>Video can&#8217;t be loaded because JavaScript is disabled: <a href=\"https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs\" title=\"Bitwise Operations &amp; Bit Masking\">Bitwise Operations &amp; Bit Masking (https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs)<\/a><\/noscript><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Instruction Table<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Bit Manipulation Instruction Table<\/h3>\n<p>Here is the table given by the exam board in the syllabus.<\/p>\n<p>&nbsp;<\/p>\n<table dir=\"ltr\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"100\" \/>\n<col width=\"100\" \/>\n<col width=\"511\" \/><\/colgroup>\n<tbody>\n<tr>\n<td colspan=\"1\" rowspan=\"2\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Label&quot;}\">\n<div>Label<\/div>\n<\/td>\n<td colspan=\"2\" rowspan=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Instruction&quot;}\">Instruction<\/td>\n<td colspan=\"1\" rowspan=\"2\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Explanation&quot;}\">\n<div>Explanation<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Opcode&quot;}\">Opcode<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Operand&quot;}\">Operand<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;AND&quot;}\">AND<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;#n&quot;}\">#n<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bitwise AND operation of the contents of ACC with the operand&quot;}\">Bitwise AND operation of the contents of ACC with the operand<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;AND&quot;}\">AND<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;address&gt;&quot;}\">&lt;address&gt;<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bitwise AND operation of the contents of ACC with the contents of &lt;address&gt;&quot;}\">Bitwise AND operation of the contents of ACC with the contents of &lt;address&gt;<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;XOR&quot;}\">XOR<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;#n&quot;}\">#n<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bitwise XOR operation of the contents of ACC with the operand&quot;}\">Bitwise XOR operation of the contents of ACC with the operand<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;XOR&quot;}\">XOR<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;address&gt;&quot;}\">&lt;address&gt;<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bitwise XOR operation of the contents of ACC with the contents of &lt;address&gt;&quot;}\">Bitwise XOR operation of the contents of ACC with the contents of &lt;address&gt;<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;OR&quot;}\">OR<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;#n&quot;}\">#n<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bitwise OR operation of the contents of ACC with the operand&quot;}\">Bitwise OR operation of the contents of ACC with the operand<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;OR&quot;}\">OR<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;address&gt;&quot;}\">&lt;address&gt;<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bitwise OR operation of the contents of ACC with the contents of &lt;address&gt; (can be an absolute address or a symbolic address)&quot;}\">Bitwise OR operation of the contents of ACC with the contents of &lt;address&gt; (can be an absolute address or a symbolic address)<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;LSL&quot;}\">LSL<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;#n&quot;}\">#n<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bits in ACC are shifted logically n places to the left. Zeros are introduced on the right hand end&quot;}\">Bits in ACC are shifted logically n places to the left. Zeros are introduced on the right hand end<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;LSR&quot;}\">LSR<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;#n&quot;}\">#n<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bits in ACC are shifted logically n places to the right. Zeros are introduced on the left hand end&quot;}\">Bits in ACC are shifted logically n places to the right. Zeros are introduced on the left hand end<\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;label&gt;:&quot;}\">&lt;label&gt;:<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;opcode&gt;&quot;}\">&lt;opcode&gt;<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;operand&gt;&quot;}\">&lt;operand&gt;<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Labels an instruction&quot;}\">Labels an instruction<\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;label&gt;:&quot;}\">&lt;label&gt;:<\/td>\n<td><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&lt;data&gt;&quot;}\">&lt;data&gt;<\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Gives a symbolic address to the memory location with contents &lt;data&gt;&quot;}\">Gives a symbolic address to the memory location with contents &lt;data&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<\/div><h2 class=\"tabtitle\">Bitwise Operations \/ Bit Masking<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Bit Masking Operations<\/h3>\n<p>When computers were first invented processing power was very limited so any tricks that could be used to speed up processing were incredibly useful and as such bit masking was introduced.<\/p>\n<p>Bit Masking allows the checking, setting and resetting individual bits within a binary without having to loop through or involve complicate logic. It could all be achieved at the logic circuit level which meant that the operations were incredibly efficient.<\/p>\n<p>Computers are far more powerful today, however the amount of data our programs process has also increased exponentially, and so in certain circumstances these &#8216;binary tricks&#8217; can still come in credibly handy. They are also useful in low level control applications where simple systems use individual bits as flags. These systems are often battery\/solar power systems so it is also useful to reduce processing as much as possible. Bit masking is also still widely used in networking when using subnet masks.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Resources<\/h2>\n<div class=\"tabcontent\">\n\n<p><a href=\"https:\/\/docs.google.com\/presentation\/d\/1yEtMYxB0TdYDAQIikAtKq0H29V3Ycs3XAd5BVeuiGTQ\/edit?usp=sharing\">Teacher Presentation<\/a><\/p>\n<p><a href=\"https:\/\/www.geeksforgeeks.org\/bitmasking-and-dynamic-programming-set-1-count-ways-to-assign-unique-cap-to-every-person\/\">Bitmasking efficiency example<\/a><\/p>\n<p>Exam Question Practice<\/p>\n<p><a href=\"https:\/\/www.cambridgeinternational.org\/Images\/503434-2021-specimen-paper-1.pdf\">2021 Specimen Paper 1 &#8211; Qn 4d<\/a><\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bitwise Operations Tutorial https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAsVideo can&#8217;t be loaded because JavaScript is disabled: Bitwise Operations &amp; Bit Masking (https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs) &nbsp; Bit Manipulation Instruction Table Here is the table given by the exam board in the syllabus. &nbsp; Label Instruction Explanation Opcode Operand AND #n Bitwise AND operation of the contents of ACC with the operand AND &lt;address&gt;&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Bit Manipulation &#038; Bitwise Operations<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":70,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bit Manipulation &amp; Bitwise Operations - A Level Computer Science<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bit Manipulation &amp; Bitwise Operations - A Level Computer Science\" \/>\n<meta property=\"og:description\" content=\"Bitwise Operations Tutorial https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAsVideo can&#8217;t be loaded because JavaScript is disabled: Bitwise Operations &amp; Bit Masking (https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs) &nbsp; Bit Manipulation Instruction Table Here is the table given by the exam board in the syllabus. &nbsp; Label Instruction Explanation Opcode Operand AND #n Bitwise AND operation of the contents of ACC with the operand AND &lt;address&gt;&hellip;&nbsp;Read More &raquo;Bit Manipulation &#038; Bitwise Operations\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/\" \/>\n<meta property=\"og:site_name\" content=\"A Level Computer Science\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-08T06:13:52+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/\",\"name\":\"Bit Manipulation & Bitwise Operations - A Level Computer Science\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#website\"},\"datePublished\":\"2021-01-18T23:42:17+00:00\",\"dateModified\":\"2021-03-08T06:13:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"A Level Computer Science Home\",\"item\":\"https:\/\/learnlearn.uk\/alevelcs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bit Manipulation &#038; Bitwise Operations\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#website\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/\",\"name\":\"A Level Computer Science\",\"description\":\"CIE Specification\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/alevelcs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#organization\",\"name\":\"A Level Computer Science\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png\",\"width\":710,\"height\":98,\"caption\":\"A Level Computer Science\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bit Manipulation & Bitwise Operations - A Level Computer Science","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/","og_locale":"en_GB","og_type":"article","og_title":"Bit Manipulation & Bitwise Operations - A Level Computer Science","og_description":"Bitwise Operations Tutorial https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAsVideo can&#8217;t be loaded because JavaScript is disabled: Bitwise Operations &amp; Bit Masking (https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs) &nbsp; Bit Manipulation Instruction Table Here is the table given by the exam board in the syllabus. &nbsp; Label Instruction Explanation Opcode Operand AND #n Bitwise AND operation of the contents of ACC with the operand AND &lt;address&gt;&hellip;&nbsp;Read More &raquo;Bit Manipulation &#038; Bitwise Operations","og_url":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/","og_site_name":"A Level Computer Science","article_modified_time":"2021-03-08T06:13:52+00:00","twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/","url":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/","name":"Bit Manipulation & Bitwise Operations - A Level Computer Science","isPartOf":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/#website"},"datePublished":"2021-01-18T23:42:17+00:00","dateModified":"2021-03-08T06:13:52+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/alevelcs\/bitwise-operations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"A Level Computer Science Home","item":"https:\/\/learnlearn.uk\/alevelcs\/"},{"@type":"ListItem","position":2,"name":"Bit Manipulation &#038; Bitwise Operations"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/alevelcs\/#website","url":"https:\/\/learnlearn.uk\/alevelcs\/","name":"A Level Computer Science","description":"CIE Specification","publisher":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/alevelcs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/alevelcs\/#organization","name":"A Level Computer Science","url":"https:\/\/learnlearn.uk\/alevelcs\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png","contentUrl":"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png","width":710,"height":98,"caption":"A Level Computer Science"},"image":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/alevelcs\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"Bitwise Operations Tutorial https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAsVideo can&#8217;t be loaded because JavaScript is disabled: Bitwise Operations &amp; Bit Masking (https:\/\/www.youtube.com\/watch?v=ffPOA7UUDAs) &nbsp; Bit Manipulation Instruction Table Here is the table given by the exam board in the syllabus. &nbsp; Label Instruction Explanation Opcode Operand AND #n Bitwise AND operation of the contents of ACC with the operand AND &lt;address&gt;&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages\/1404"}],"collection":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/comments?post=1404"}],"version-history":[{"count":10,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages\/1404\/revisions"}],"predecessor-version":[{"id":1441,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages\/1404\/revisions\/1441"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/media?parent=1404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}