home bbs files messages ]

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

   comp.arch      Apparently more than just beeps & boops      131,241 messages   

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

   Message 129,868 of 131,241   
   John Savard to Anton Ertl   
   Re: sign/zero/garbage extension (was: Ti   
   09 Oct 25 13:51:52   
   
   From: quadibloc@invalid.invalid   
      
   On Sat, 04 Oct 2025 10:17:41 +0000, Anton Ertl wrote:   
      
   > If the calling convention guarantees that ints are zero-extended (sounds   
   > perverse, but RV64 has the guarantee that unsigned is passed in   
   > sign-extended form, which is equally perverse), then the compiler must   
   > use instructions that produce a zero-extended result (e.g., AMD64's   
   > addl).  If the calling convention only requires and guarantees the   
   > low-order 32 bits (I call this garbage-extended), then the compiler can   
   > use instructions that perform 64-bit adds; this is what we are seeing   
   > above.   
   >   
   > The other side of the medal is what is needed at the caller: If the   
   > caller needs to cconvert a sign-extended int into a long, it does not   
   > have to do anything.   
      
   I find this just a bit confusing.   
      
   Obviously, regular signed integer values should be sign extended.   
      
   But, equally, _unsigned_ integer values should be zero extended for   
   precisely the same reason, so that the longer value, as an unsigned   
   integer, has the same value without doing anything.   
      
   John Savard   
      
   --- 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