{"id":96795,"date":"2017-08-10T07:00:00","date_gmt":"2017-08-10T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=96795"},"modified":"2019-03-13T01:15:06","modified_gmt":"2019-03-13T08:15:06","slug":"20170810-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20170810-00\/?p=96795","title":{"rendered":"The Alpha AXP, part 4: Bit 15. Ugh. Bit 15."},"content":{"rendered":"<p>Let&#8217;s load each of the powers of two up to 2&sup3;&sup1;, in canonical form. <\/p>\n<pre>\n    LDA  Ra, 0x0001(zero)   ;   Ra = 0x00000000`00000001 ; bit  0\n    LDA  Ra, 0x0002(zero)   ;   Ra = 0x00000000`00000002 ; bit  1\n    LDA  Ra, 0x0004(zero)   ;   Ra = 0x00000000`00000004 ; bit  2\n    LDA  Ra, 0x0008(zero)   ;   Ra = 0x00000000`00000008 ; bit  3\n    LDA  Ra, 0x0010(zero)   ;   Ra = 0x00000000`00000010 ; bit  4\n    LDA  Ra, 0x0020(zero)   ;   Ra = 0x00000000`00000020 ; bit  5\n    LDA  Ra, 0x0040(zero)   ;   Ra = 0x00000000`00000040 ; bit  6\n    LDA  Ra, 0x0080(zero)   ;   Ra = 0x00000000`00000080 ; bit  7\n    LDA  Ra, 0x0100(zero)   ;   Ra = 0x00000000`00000100 ; bit  8\n    LDA  Ra, 0x0200(zero)   ;   Ra = 0x00000000`00000200 ; bit  9\n    LDA  Ra, 0x0400(zero)   ;   Ra = 0x00000000`00000400 ; bit 10\n    LDA  Ra, 0x0800(zero)   ;   Ra = 0x00000000`00000800 ; bit 11\n    LDA  Ra, 0x1000(zero)   ;   Ra = 0x00000000`00001000 ; bit 12\n    LDA  Ra, 0x2000(zero)   ;   Ra = 0x00000000`00002000 ; bit 13\n    LDA  Ra, 0x4000(zero)   ;   Ra = 0x00000000`00004000 ; bit 14\n    LDAH Ra, 0x0001(zero)   ; \\\n    LDA  Ra, 0x8000(Ra)     ; \/ Ra = 0x00000000`00008000 ; bit 15\n    LDAH Ra, 0x0001(zero)   ;   Ra = 0x00000000`00010000 ; bit 16\n    LDAH Ra, 0x0002(zero)   ;   Ra = 0x00000000`00020000 ; bit 17\n    LDAH Ra, 0x0004(zero)   ;   Ra = 0x00000000`00040000 ; bit 18\n    LDAH Ra, 0x0008(zero)   ;   Ra = 0x00000000`00080000 ; bit 19\n    LDAH Ra, 0x0010(zero)   ;   Ra = 0x00000000`00100000 ; bit 20\n    LDAH Ra, 0x0020(zero)   ;   Ra = 0x00000000`00200000 ; bit 21\n    LDAH Ra, 0x0040(zero)   ;   Ra = 0x00000000`00400000 ; bit 22\n    LDAH Ra, 0x0080(zero)   ;   Ra = 0x00000000`00800000 ; bit 23\n    LDAH Ra, 0x0100(zero)   ;   Ra = 0x00000000`01000000 ; bit 24\n    LDAH Ra, 0x0200(zero)   ;   Ra = 0x00000000`02000000 ; bit 25\n    LDAH Ra, 0x0400(zero)   ;   Ra = 0x00000000`04000000 ; bit 26\n    LDAH Ra, 0x0800(zero)   ;   Ra = 0x00000000`08000000 ; bit 27\n    LDAH Ra, 0x1000(zero)   ;   Ra = 0x00000000`10000000 ; bit 28\n    LDAH Ra, 0x2000(zero)   ;   Ra = 0x00000000`20000000 ; bit 29\n    LDAH Ra, 0x4000(zero)   ;   Ra = 0x00000000`40000000 ; bit 30\n    LDAH Ra, 0x8000(zero)   ;   Ra = 0xFFFFFFFF`80000000 ; bit 31\n<\/pre>\n<p>Bit 15. Ugh. Bit 15. <\/p>\n<p>It&#8217;s the only one that requires two instructions to calculate the 32-bit mask in canonical form. <\/p>\n<p>This means that if you have a bitfield, bit 15 is slightly more expensive than the others. <\/p>\n<p><b>Bonus chatter<\/b>: In an internal discussion of byte manipulation on the Alpha AXP, I happened to have written &#8220;Bit 15. Ugh. Bit 15.&#8221; Gov Maharaj (co-host of <a HREF=\"https:\/\/channel9.msdn.com\/Shows\/The-Defrag-Show\">The Defrag Show<\/a> and <a HREF=\"https:\/\/channel9.msdn.com\/Shows\/Checking-In-with-Erik-Meijer\/Checking-In-Gov-Maharaj-Shimming-the-World-Dreaming-in-Assembly\">application compatibility master extraordinaire<\/a>) told me, &#8220;That needs to be the title of a blog post.&#8221; So here it is. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s make some bits.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-96795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Let&#8217;s make some bits.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/96795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=96795"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/96795\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=96795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=96795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=96795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}