title: why we can't move a 64-bit immediate value to memory?
body: <p>First I am a little bit confused with the differences between <code>movq</code> and <code>movabsq</code>, my text book says:</p>
  <p><em><strong>The regular <code>movq</code> instruction can only have immediate source operands that can be represented as 32-bit two’s-complement numbers. This value is then sign extended to produce the 64-bit value for the destination. The <code>movabsq</code> instruction can have an arbitrary 64-bit immediate value as its source operand and can only have a register as a destination.</strong></em></p>
  <p>I have two questions to this.</p>
  <h1>Question 1</h1>
  <p>The <code>movq</code> instruction can only have immediate source operands that can be represented as 32-bit two’s-complement numbers.</p>
  <p>so it means that we can't do</p>
  <pre><code>movq    $0x123456789abcdef, %rbp
  </code></pre>
  <p>and we have to do:</p>
  <pre><code>movabsq $0x123456789abcdef, %rbp
  </code></pre>
  <p>but why <code>movq</code> is designed to not work for 64 bits immediate value, which is really against the purpose of <code>q</code> (quard word), and we need to have another <code>movabsq</code> just for this purpose, isn't that hassle?</p>
  <h1>Question 2</h1>
  <p>Since the destination of <code>movabsq</code> has to be a register, not memory, so we can't move a 64-bit immediate value to memory as:</p>
  <pre><code>movabsq $0x123456789abcdef, (%rax)
  </code></pre>
  <p>but there is a workaround:</p>
  <pre><code>movabsq $0x123456789abcdef, %rbx
  movq    %rbx, (%rax)   // the source operand is a register, not immediate constant, and the destination of movq can be memory
  </code></pre>
  <p>so why the rule is designed to make things harder?</p>