[coreboot] libpayload: Convert HEX2BIN/BIN2HEX to functions, add abs() et al

Jordan Crouse jordan.crouse at amd.com
Tue Apr 8 04:45:57 CEST 2008


On 08/04/08 03:11 +0200, Peter Stuge wrote:
> On Tue, Apr 08, 2008 at 02:41:23AM +0200, Uwe Hermann wrote:
> > +u8 bin2hex(u8 b)
> > +{
> > +	return "0123456789abcdef"[b & 15];
> > +}
> 
> Neat. :)

Hmm - now that you mention it - thats 16 bytes of const data.
This might be more efficient (but not as cute):

return (b < 10) ? '0' + b : 'a' + (b - 10);

Jordan

-- 
Jordan Crouse
Systems Software Development Engineer 
Advanced Micro Devices, Inc.





More information about the coreboot mailing list