diff options
author | H. Peter Anvin <hpa@zytor.com> | 2017-02-20 02:39:56 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2017-02-20 02:39:56 -0800 |
commit | 164d24677a590c2b24d75aa085cbb13b6bccab61 (patch) | |
tree | e1eefad2a4cf65b71141d31fdf54d969e2cae260 /test/pcrel.asm | |
parent | 9b4b92b0143987b7e8989b01d96f92af27c1bbbe (diff) | |
download | nasm-164d24677a590c2b24d75aa085cbb13b6bccab61.tar.gz |
Support self-relative expressions in offsets and immediates
Handle, hopefully correctly, self-relative expressions (that is,
expressions of the form X - Y where Y is a symbol in the current
segment, possibly $ or $$) used as offsets or immediates, as opposed
to arguments to Dx statements (which have already been supported for a
while.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'test/pcrel.asm')
-rw-r--r-- | test/pcrel.asm | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/pcrel.asm b/test/pcrel.asm new file mode 100644 index 00000000..239e8cb8 --- /dev/null +++ b/test/pcrel.asm @@ -0,0 +1,50 @@ + bits 32 +foo: ; Backwards reference + mov eax,[foo - $] + mov ebx,[ebx + foo - $] + mov ecx,foo - $ + mov edx,foo - bar + + mov eax,[bar - $] + mov ebx,[ebx + bar - $] + mov ecx,bar - $ + mov edx,bar - foo + + mov eax,[baz - $] + mov ebx,[ebx + baz - $] + mov esi,[baz - bar] + mov ecx,baz - $ + mov edx,baz - bar + + bits 64 + default rel + + mov eax,[foo] + mov eax,[foo - $] + mov eax,[abs foo - $] + mov ebx,[ebx + foo - $] + mov ecx,foo - $ + mov edx,foo - bar + + mov eax,[bar] + mov eax,[bar - $] + mov eax,[abs bar - $] + mov ebx,[ebx + bar - $] + mov ecx,bar - $ + mov edx,bar - foo + + mov eax,[baz] + mov eax,[baz - $] + mov eax,[abs baz - $] + mov ebx,[ebx + baz - $] + mov esi,[baz - bar] + mov esi,[abs baz - bar] + mov ecx,baz - $ + mov edx,baz - bar + +bar: ; Forwards reference + hlt + + section ".data" +baz: ; Other-segment reference + dd 0 |