åé¡ç·¨ã¯ãã¡ãã®x86ã«ã«ãã¯ã¤ãºã§ãï¼ Q1 [ä¹ç®ã®åæ¸] lea eax, [eax + eax*8] lea eax, [eax + eax*4] 45 = 9 * 5 = (8 + 1) * (4 + 1)ãå©ç¨ããï¼ä¹ç®å½ä»¤ãéããªã£ãã¨ã¯ããï¼ã¾ã add/sub/shift/leaã®çµã¿åããã使ã£ãæ¹ãéããã¨ãå¤ãï¼ Q2 [æ¡ä»¶åå²ã®åæ¸] cdq xor eax, edx sub eax, edx æ¡ä»¶åå²ã¯å¯è½ãªéã使ããªãï¼æ¬¡ã®äºã¤ã®æçå¼ -x = x ^ (-1) - (-1) x = x ^ 0 - 0 㨠unsigned int m = (x < 0) ? -1 : 0 ãçµã¿åããããã¨ã§çµ¶å¯¾å¤ã unsigned int m = x >> 31; return x ^ m - m; ã¨å®ç¾ããï¼ããã§mãåå¾ããé¨å㯠mov edx, eax sa
{{#tags}}- {{label}}
{{/tags}}