3.24.5 Non-RIP-Relative Addressing in 64-Bit

Asmc Macro Assembler

3.24.5 Non-RIP-Relative Addressing in 64-Bit

In 64-bit a RIP-relative addressing mode was introduced. This mode is used as default for direct addressing, because it allows to access all code or data labels with a 32-bit displacement. However, for constant address locations this mode is not appropriate and won't be used:

 
     mov al, gs:[1000h]
     mov al, gs:[100000000h]

If a constant address is to be accessed without segment prefixes - note that in 64-bit, only segment registers FS and GS can be used as segment prefixes - one has to use the FLAT keyword in JWasm:

 
     mov al, FLAT:[1000h]           ;invalid for Masm
     mov al, FLAT:[100000000h]      ;invalid for Masm

This syntax differs from Masm's, because Masm won't accept FLAT. In 64-bit Masm, the syntax for accessing constant addresses is instead:

 
     mov al, [1000h]               ;invalid for JWasm
     mov al, [100000000h]          ;invalid for JWasm

The code that will be generated won't show any differences:

  
0000000000000000: 65 8A 04 25 10 00 00 00              mov al,byte ptr gs:[00000010h]
0000000000000008: 65 A0 00 00 00 00 01 00 00 00        mov al,byte ptr gs:[0000000100000000h]
0000000000000012: 8A 04 25 10 00 00 00                 mov al,byte ptr ds:[00000010h]
0000000000000019: A0 00 00 00 00 01 00 00 00           mov al,byte ptr ds:[0000000100000000h]