Thread overview
ASM: Loading address of label truncates to 32 bits on x64
Nov 10
claptrap
Nov 10
claptrap
Nov 10
claptrap
November 10
asm
{
        mov EAX,idx;
        shl EAX,4;
        lea RCX,LOOKUP;
        jmp [RCX+RAX];
LOOKUP:
        lea R9,CASE0;
        jmp ENDLOOKUP;
        align 16;
        lea R9,CASE1;
        jmp ENDLOOKUP;
        align 16;
ENDLOOKUP:

}

00007FF760D244A7  mov         eax,dword ptr [rbp-48h]
00007FF760D244AA  shl         eax,4
00007FF760D244AD  lea         rcx,[60D244B8h]
00007FF760D244B5  jmp         qword ptr [rcx+rax]
00007FF760D244B8  lea         r9,[60D24572h]
00007FF760D244C0  jmp         00007FF760D244E0
00007FF760D244C2  nop         word ptr cs:[rax+rax]
00007FF760D244D0  lea         r9,[60D2455Bh]
00007FF760D244D8  jmp         00007FF760D244E0

All the "lea REG,label" instructions are missing the top 32 bits of the actual address.

Looks like a bug to me as it works OK on DMD. At least I compiled a small test and DMD prints out a 64 bit address

November 10

On Sunday, 10 November 2024 at 00:47:07 UTC, claptrap wrote:

>

Looks like a bug to me as it works OK on DMD. At least I compiled a small test and DMD prints out a 64 bit address

Am I understanding correctly that LDC parse D symtax and converts it to LDC/GDC syntax, and this is done with

asm-x86.h

So could be the problem is the lea is not converted to the correct symtax?

November 10

On Sunday, 10 November 2024 at 12:37:27 UTC, claptrap wrote:

>

On Sunday, 10 November 2024 at 00:47:07 UTC, claptrap wrote:

>

Looks like a bug to me as it works OK on DMD. At least I compiled a small test and DMD prints out a 64 bit address

Am I understanding correctly that LDC parse D symtax and converts it to LDC/GDC syntax, and this is done with

asm-x86.h

So could be the problem is the lea is not converted to the correct symtax?

Ok apparently...

lea RCX,[RIP+LABEL]

works.