{"id":240,"date":"2006-04-04T18:07:08","date_gmt":"2006-04-05T01:07:08","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=240"},"modified":"2006-04-04T18:09:19","modified_gmt":"2006-04-05T01:09:19","slug":"4-additions-are-faster-than-1","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/4-additions-are-faster-than-1\/","title":{"rendered":"4 Additions Are Faster Than 1?"},"content":{"rendered":"<p>Today&#8217;s wacky ASM construct shows us four sequential additions to the same register:<\/p>\n<pre>\r\n  add ecx, 00000004\r\n  add ecx, 00000004\r\n  add ecx, 00000004\r\n  add ecx, 00000004\r\n<\/pre>\n<p>Does this have some great advantage over, say:<\/p>\n<pre>\r\n  add ecx, 00000010\r\n<\/pre>\n<p>Who knows? But I dare you to claim that this is some compiler optimization technique. You can&#8217;t claim that it&#8217;s minimizing branch prediction error this time since there are no branches to be seen for miles (kilometers, if you must) on either side. In fact, here is a little ASM context on either side of the block:<\/p>\n<pre>\r\n  xor ebx, ebx\r\n  mov bl, byte[esp+26]\r\n  add ecx, 00000004\r\n  add ecx, 00000004\r\n  add ecx, 00000004\r\n  add ecx, 00000004\r\n  mov ebx, dword[esi+4*ebx]\r\n<\/pre>\n<p>Hmm, now that I look at it after an indignant rant, I realize that maybe the compiler decided to delay after a byte is loaded from memory before accessing memory again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>More ASM nuttiness&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-reverse-engineering"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":0,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}