diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-09-25 20:36:45 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-09-25 20:36:45 -0700 |
commit | 4cba95cf8118c1db5fd180a49c2fbf5ea366a2a3 (patch) | |
tree | 52504cb0664b4177422c5f28c0a3ff03638c4185 | |
parent | 64b3a9c56b26d2adfa79f8e4e8df00e3b27edd9a (diff) | |
download | nasm-4cba95cf8118c1db5fd180a49c2fbf5ea366a2a3.tar.gz nasm-4cba95cf8118c1db5fd180a49c2fbf5ea366a2a3.tar.bz2 nasm-4cba95cf8118c1db5fd180a49c2fbf5ea366a2a3.zip |
nasmdoc: corrections on 64-bit immediates/displacements
Corrections the section on 64-bit immediates and displacements. In
particular, immediates are sign-extended the same way displacements
are (and the same way 8-bit immediates are), so there is some use for
the 7-byte mov eax,dword imm form :(
-rw-r--r-- | doc/nasmdoc.src | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index 4ea2885..148139f 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -6293,19 +6293,24 @@ In 64-bit mode, immediates and displacements are generally only 32 bits wide. NASM will therefore truncate most displacements and immediates to 32 bits. -The only instruction which takes a full 64 bit immediate is: +The only instruction which takes a full \i{64-bit immediate} is: \c MOV reg64,imm64 -NASM will produce this instruction whenever the programmer uses \c{MOV} -with an immediate into a 64-bit register. If this is not desirable, -simply specify the equivalent 32-bit register, which will be -automatically zero-extended by the processor: +NASM will produce this instruction whenever the programmer uses +\c{MOV} with an immediate into a 64-bit register. If this is not +desirable, simply specify the equivalent 32-bit register, which will +be automatically zero-extended by the processor, or specify the +immediate as \c{DWORD}: \c mov rax,foo ; 64-bit immediate +\c mov rax,qword foo ; (identical) \c mov eax,foo ; 32-bit immediate, zero-extended +\c mov rax,dword foo ; 32-bit immediate, sign-extended -The only instructions which take a full 64-bit \e{displacement} is +The length of these instructions are 10, 5 and 7 bytes, respectively. + +The only instructions which take a full \i{64-bit \e{displacement}} is loading or storing, using \c{MOV}, \c{AL}, \c{AX}, \c{EAX} or \c{RAX} (but no other registers) to an absolute 64-bit address. Since this is a relatively rarely used instruction (64-bit code generally uses @@ -6314,17 +6319,20 @@ displacement size as \c{QWORD}: \c default abs \c -\c mov eax,[foo] ; 32-bit absolute disp (-2..2 GB) -\c mov eax,[a32 foo] ; 32-bit absolute disp (0..4 GB) +\c mov eax,[foo] ; 32-bit absolute disp, sign-extended +\c mov eax,[a32 foo] ; 32-bit absolute disp, zero-extended \c mov eax,[qword foo] ; 64-bit absolute disp \c \c default rel \c \c mov eax,[foo] ; 32-bit relative disp \c mov eax,[a32 foo] ; d:o, address truncated to 32 bits(!) -\c mov eax,[qword foo] ; 32-bit relative disp(!) +\c mov eax,[qword foo] ; error \c mov eax,[abs qword foo] ; 64-bit absolute disp +A sign-extended absolute displacement can access from -2 GB to +2 GB; +a zero-extended absolute displacement can access from 0 to 4 GB. + FIXME: THIS IS NOT YET CORRECTLY IMPLEMENTED \H{unix64} Interfacing to 64-bit C Programs (Unix) |