On Sep 15, 2014, at 8:57 AM, Deric Cole <deric_c...@phoenix.com> wrote:
> You can use AsciiValueToString from PrintLib.
>
I think that is the opposite endian to the example. 0x43313031 would print out
101C. So you would also need to add a SwapBytes32().
I’d probably not ship code with the static local hex, but this would work.
char *
test (unsigned int src)
{
static char hex[5];
char *ptr = (char *)&src;
hex[0] = ptr[3];
hex[1] = ptr[2];
hex[2] = ptr[1];
hex[3] = ptr[0];
hex[4] = '\0';
return hex;
}
The size of int, and long are not standard. Actually the size of long
(Microsoft LLP64 vs. others LP64) is different between the various compilers
that are supported by the edk2. This is why the UEFI spec defines types of a
know size.
Thanks,
Andrew Fish
> Deric Cole
> Sr. Customer Engineer
> Phoenix Technologies Ltd.
>
> From: sushma s [mailto:sushma.bharadw...@gmail.com]
> Sent: Sunday, September 14, 2014 11:45 PM
> To: edk2-devel@lists.sourceforge.net
> Subject: [edk2] converting UNIT32 value to ASCII format
>
> Hello,
>
> I am trying to convert a UINT32 value into ASCII format in my UEFI driver.
> I used the below method. We use EBC compiler for compiling my driver sources.
>
> char hex[5];
> int i;
> unsigned int src= 0x43313031;
>
> for(i = 0; i<4;i++)
> {
> hex[i] = src>>(64-(i+1)*8);
> }
> hex[i] = '\0';
>
> The same code when compiled in gcc compiler gives output, C101.
> The same code when used in my driver, gives blank output.
>
> Please let us know if there is any UEFI library function to achieve this
> conversion.
>
>
> Regards,
> Sushma.S
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel