Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,615 of 4,675    |
|    Frederick Virchanza Gotham to All    |
|    Re: aarch64 (64-Bit ARM) - return by val    |
|    18 Jul 23 01:35:32    |
   
   From: cauldwell.thomas@nospicedham.gmail.com   
      
   Over on comp.unix.programmer, Adam Sampson gave me inline assembler that works:   
      
    __asm(".text\n"   
    "Invoke:\n"   
    " mov x1, x8\n"   
    " adr x9, f\n"   
    " ldr x9, [x9]\n"   
    " br x9\n"   
    );   
      
   For the sake of posting to this newsgroup, I simplified my problem just a tiny   
   bit. Previously I told you that 'f' was a global variable defined as follows:   
      
    void (*f)(void);   
      
   but in actual fact it's:   
      
    thread_local void (*f)(void);   
      
   If I change it to thread_local then try to re-compile the inline assembler, I   
   get a linker error:   
      
    R_AARCH64_ADR_PREL_LO21 used with TLS symbol f   
      
   Do you know what syntax I use to access the thread_local variable from   
   assembler? Will I need to write a separate function as follows?   
      
   void (*getf(void))(void)   
   {   
    return f;   
   }   
      
   and then call that function from my assembler? I'm worried about corrupting   
   the caller-saved registers, because I perform a 'br' rather than a 'blr' (i.e.   
   I perform a jump rather than a function call). I suppose I could push all the   
   caller-saved    
   registers before invoking 'getf' and then pop afterward... which I know how to   
   do on x86_64 but I'm new to all this aarch64 stuff.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca