home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.os.development      Operating system development chatter      4,255 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,094 of 4,255   
   wolfgang kern to Paul Edwards   
   Re: x64 address indexed by 32-bit addres   
   30 Jan 24 10:14:48   
   
   From: nowhere@never.at   
      
   On 19/01/2024 14:42, Paul Edwards wrote:   
   > Hi.   
   >   
   > I am using a slightly modified GCC 3.2.3   
   > to generate x64 code, and using PDPCLIB   
   > and running under Linux x64.   
   ...   
   > Now I have this code:   
   ...   
   > printf("as negative is %x\n", p[-1]);   
      
   > which is generating (for that last line):   
   >   
   > LM1873:   
   >          movl    $4294967295, %eax   
   >          addq    -64(%rbp), %rax   
   >          movsbl  (%rax),%esi   
   >          movl    $LC445, %edi   
   >          movb    $0, %al   
   >          call    _printf   
      
   > That first instruction - the movl - has   
   > negative 1 as an unsigned value.   
      
   of course because it's just the lower part of RAX   
   where the upper part become zeroed by a move to EAX.   
      
   > I tried manually changing the generated assembler   
   > to $-1 but the result appears to be the   
   > same (I may have stuffed up the test).   
      
   you have to make RAX -1   
   XOR RAX,RAX   
   DEC RAX   
   but what's wrong with: DEC instead of ADD -1   
   __   
   wolfgang   
      
   --- 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