Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
Is this question really as stupid as it sounds or am I having a mental
relapse?
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
Sent: Tuesday, April 15, 2003 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] Binary/Hex to ASCII conversion in driver
Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
My apologies, there are no stupid questions; only inquisitive idiots.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
Sent: Tuesday, April 15, 2003 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] Binary/Hex to ASCII conversion in driver
Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
I am not certain you have supplied enough information answer the
question. What are you trying to do? ASCII can be represented by an 8bit
binary/hex value… So I don’t understand what you are trying to convert
from/to.
-Justin
At 01:36 PM 4/15/2003, you wrote:
Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Does it matter
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 5:00 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
I am not certain you have supplied enough information answer the
question. What are you trying to do? ASCII can be represented by an
8bit
binary/hex value… So I don’t understand what you are trying to
convert
from/to.
-Justin
At 01:36 PM 4/15/2003, you wrote:
Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Enough sarcasm; I guess…
I think he may be looking for ACII character representation of a number
like 100 -> “100” for a printable string or something.
You can do it the hard way or you can use various sprintf like functions
to do the formatting for you.
In some of our drivers, we have code like this:
swprintf(SzGuidToPrint, L"%08lx", Guid.Data1);
where SzGuidToPrint is a string representation of the value.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jamey Kirby
Sent: Tuesday, April 15, 2003 5:21 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
Does it matter
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 5:00 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
I am not certain you have supplied enough information answer the
question. What are you trying to do? ASCII can be represented by an
8bit
binary/hex value… So I don’t understand what you are trying to
convert
from/to.
-Justin
At 01:36 PM 4/15/2003, you wrote:
Hi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Are there any of us here that have not asked a dumb question at some point
in life??.. Were you born with computer knowledge or did you have to
learn like the rest of us?
-Justin
At 01:58 PM 4/15/2003, you wrote:
My apologies, there are no stupid questions; only inquisitive idiots.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
Sent: Tuesday, April 15, 2003 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] Binary/Hex to ASCII conversion in driverHi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
I want to write an encrypting file system driver. I have written
several hello world programs in VB before. What do I need to know to do
this?
Thanks,
Rob
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 8:06 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driver
Are there any of us here that have not asked a dumb question at some
point
in life??.. Were you born with computer knowledge or did you have to
learn like the rest of us?
-Justin
At 01:58 PM 4/15/2003, you wrote:
My apologies, there are no stupid questions; only inquisitive idiots.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
Sent: Tuesday, April 15, 2003 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] Binary/Hex to ASCII conversion in driverHi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Well, I guess most of us had at least basic C knowledge before writing their
very first NT driver
Best regards,
Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]
From: zeppelin@io.com[SMTP:zeppelin@io.com]
Reply To: xxxxx@lists.osr.com
Sent: Wednesday, April 16, 2003 2:05 AM
To: xxxxx@lists.osr.com
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driverAre there any of us here that have not asked a dumb question at some point
in life??.. Were you born with computer knowledge or did you have to
learn like the rest of us?-Justin
At 01:58 PM 4/15/2003, you wrote:
>My apologies, there are no stupid questions; only inquisitive idiots.
>
>Jamey
>
>
>-----Original Message-----
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
>Sent: Tuesday, April 15, 2003 4:36 PM
>To: NT Developers Interest List
>Subject: [ntdev] Binary/Hex to ASCII conversion in driver
>
>Hi All,
>
>How should I convert my 8 bit binary/Hex value to
>corresponding ASCII in my device driver.
>
>
>__________________________________________________
>Do you Yahoo!?
>The New Yahoo! Search - Faster. Easier. Bingo
>http://search.yahoo.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>—
>You are currently subscribed to ntdev as: zeppelin@io.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: michal.vodicka@st.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
joke?
-----Original Message-----
From: Rob Green [mailto:xxxxx@cdp.com]
Sent: Tuesday, April 15, 2003 6:35 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driver
I want to write an encrypting file system driver. I have written
several hello world programs in VB before. What do I need to know to do
this?
Thanks,
Rob
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 8:06 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driver
Are there any of us here that have not asked a dumb question at some
point
in life??.. Were you born with computer knowledge or did you have to
learn like the rest of us?
-Justin
At 01:58 PM 4/15/2003, you wrote:
My apologies, there are no stupid questions; only inquisitive idiots.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
Sent: Tuesday, April 15, 2003 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] Binary/Hex to ASCII conversion in driverHi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@websense.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
On Tue, 2003-04-15 at 18:58, Jamey Kirby wrote:
Is this question really as stupid as it sounds or am I having a mental
relapse?
a RElapse?
Jamey
Very funny… first though… if you want to write a really good
driver you need to use LOGO as your programming language. VB is way too
low level.
-J
At 03:34 PM 4/15/2003, you wrote:
I want to write an encrypting file system driver. I have written
several hello world programs in VB before. What do I need to know to do
this?Thanks,
Rob
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 8:06 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driverAre there any of us here that have not asked a dumb question at some
point
in life??.. Were you born with computer knowledge or did you have tolearn like the rest of us?
-Justin
At 01:58 PM 4/15/2003, you wrote:
>My apologies, there are no stupid questions; only inquisitive idiots.
>
>Jamey
>
>
>-----Original Message-----
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
>Sent: Tuesday, April 15, 2003 4:36 PM
>To: NT Developers Interest List
>Subject: [ntdev] Binary/Hex to ASCII conversion in driver
>
>Hi All,
>
>How should I convert my 8 bit binary/Hex value to
>corresponding ASCII in my device driver.
>
>
>__________________________________________________
>Do you Yahoo!?
>The New Yahoo! Search - Faster. Easier. Bingo
>http://search.yahoo.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>—
>You are currently subscribed to ntdev as: zeppelin@io.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Just trying to give the guy the benefit of doubt instead of calling him
names…
-J
At 03:39 PM 4/15/2003, you wrote:
Well, I guess most of us had at least basic C knowledge before writing their
very first NT driverBest regards,
Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]> ----------
> From: zeppelin@io.com[SMTP:zeppelin@io.com]
> Reply To: xxxxx@lists.osr.com
> Sent: Wednesday, April 16, 2003 2:05 AM
> To: xxxxx@lists.osr.com
> Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driver
>
> Are there any of us here that have not asked a dumb question at some point
>
> in life??.. Were you born with computer knowledge or did you have to
> learn like the rest of us?
>
> -Justin
>
> At 01:58 PM 4/15/2003, you wrote:
> >My apologies, there are no stupid questions; only inquisitive idiots.
> >
> >Jamey
> >
> >
> >-----Original Message-----
> >From: xxxxx@lists.osr.com
> >[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
> >Sent: Tuesday, April 15, 2003 4:36 PM
> >To: NT Developers Interest List
> >Subject: [ntdev] Binary/Hex to ASCII conversion in driver
> >
> >Hi All,
> >
> >How should I convert my 8 bit binary/Hex value to
> >corresponding ASCII in my device driver.
> >
> >
> >__________________________________________________
> >Do you Yahoo!?
> >The New Yahoo! Search - Faster. Easier. Bingo
> >http://search.yahoo.com
> >
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >—
> >You are currently subscribed to ntdev as: zeppelin@io.com
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: michal.vodicka@st.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
OK, don’t flame me. My favorite binary-to-ASCII conversion on the x86
platform is to put the 4-bit binary value I want to convert to ASCII in the
AX register and then do:
add al,40h
daa
adc al,90h
daa
The result is an ASCII hex digit in the AX register. It’s not portable, but
it is a nifty piece of code.
I think credit for this goes to Tim Paterson at Seattle Computer Products
(circa 1980). At least that’s the first reference I saw to this particular
method.
-Dan
----- Original Message -----
Subject: Binary/Hex to ASCII conversion in driver
From: Tom Pr
> Date: Tue, 15 Apr 2003 16:36:02 -0700 (PDT)
>
> Hi All,
>
> How should I convert my 8 bit binary/Hex value to
> corresponding ASCII in my device driver.
Ahem. Allow me to kick myself in the pants. Please accept this correction:
add al,90h
daa
adc al,40h
daa
-Dan
----- Original Message -----
From: “Daniel E. Germann”
To: “NT Developers Interest List”
Sent: Wednesday, April 16, 2003 8:06 AM
Subject: Re: Binary/Hex to ASCII conversion in driver
> OK, don’t flame me. My favorite binary-to-ASCII conversion on the x86
> platform is to put the 4-bit binary value I want to convert to ASCII in
the
> AX register and then do:
>
> add al,40h
> daa
> adc al,90h
> daa
>
> The result is an ASCII hex digit in the AX register. It’s not portable,
but
> it is a nifty piece of code.
>
> I think credit for this goes to Tim Paterson at Seattle Computer Products
> (circa 1980). At least that’s the first reference I saw to this
particular
> method.
>
> -Dan
>
> ----- Original Message -----
> > Subject: Binary/Hex to ASCII conversion in driver
> > From: Tom Pr
> > Date: Tue, 15 Apr 2003 16:36:02 -0700 (PDT)
> >
> > Hi All,
> >
> > How should I convert my 8 bit binary/Hex value to
> > corresponding ASCII in my device driver.
I am just having some fun.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 5:06 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driver
Are there any of us here that have not asked a dumb question at some
point
in life??.. Were you born with computer knowledge or did you have to
learn like the rest of us?
-Justin
At 01:58 PM 4/15/2003, you wrote:
My apologies, there are no stupid questions; only inquisitive idiots.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
Sent: Tuesday, April 15, 2003 4:36 PM
To: NT Developers Interest List
Subject: [ntdev] Binary/Hex to ASCII conversion in driverHi All,
How should I convert my 8 bit binary/Hex value to
corresponding ASCII in my device driver.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Yes! The turtle!
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 9:50 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driver
Very funny… first though… if you want to write a really good
driver you need to use LOGO as your programming language. VB is way
too
low level.
-J
At 03:34 PM 4/15/2003, you wrote:
I want to write an encrypting file system driver. I have written
several hello world programs in VB before. What do I need to know to
do
this?Thanks,
Rob
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Justin Frodsham
Sent: Tuesday, April 15, 2003 8:06 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Binary/Hex to ASCII conversion in driverAre there any of us here that have not asked a dumb question at some
point
in life??.. Were you born with computer knowledge or did you have
tolearn like the rest of us?
-Justin
At 01:58 PM 4/15/2003, you wrote:
>My apologies, there are no stupid questions; only inquisitive idiots.
>
>Jamey
>
>
>-----Original Message-----
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of Tom Pr
>Sent: Tuesday, April 15, 2003 4:36 PM
>To: NT Developers Interest List
>Subject: [ntdev] Binary/Hex to ASCII conversion in driver
>
>Hi All,
>
>How should I convert my 8 bit binary/Hex value to
>corresponding ASCII in my device driver.
>
>
>__________________________________________________
>Do you Yahoo!?
>The New Yahoo! Search - Faster. Easier. Bingo
>http://search.yahoo.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>—
>You are currently subscribed to ntdev as: zeppelin@io.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: zeppelin@io.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Here, a very simple function - three lines of code - and a naive C++ tester
to go with it. The “issue” call puts the characters out, one by one. You
guys can convert it to assembler if you will, but I don’t think it’s
necessary.
Hope this helps !
Alberto.
//==============================================================
void convert(int n)
{
char *k = “0123456789ABCDEF”;
if (n > 15) convert(n>>4);
issue (k[n&0xf]);
}
//==============================================================
//==============================================================
#include
using namespace std;
#define BUFFERSIZE 16
static char c[BUFFERSIZE];
static int p=0;
void convert(int n)
{
char *k = “0123456789ABCDEF”;
if (n > 15) convert(n>>4);
issue (k[n&0xf]);
}
void prime()
{
p = 0;
for (int i=0; i}
void issue(int digit)
{
c[p++] = digit;
c[p] = 0;
}
main()
{
prime(); convert(0); cout << c << endl;
prime(); convert(0x1); cout << c << endl;
prime(); convert(0x12); cout << c << endl;
prime(); convert(0x123); cout << c << endl;
return 0;
}
//==============================================================
----Original Message-----
From: Daniel E. Germann [mailto:xxxxx@nospam.visi.com]
Sent: Wednesday, April 16, 2003 9:10 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
Ahem. Allow me to kick myself in the pants. Please accept this correction:
add al,90h
daa
adc al,40h
daa
-Dan
----- Original Message -----
From: “Daniel E. Germann”
To: “NT Developers Interest List”
Sent: Wednesday, April 16, 2003 8:06 AM
Subject: Re: Binary/Hex to ASCII conversion in driver
> OK, don’t flame me. My favorite binary-to-ASCII conversion on the x86
> platform is to put the 4-bit binary value I want to convert to ASCII in
the
> AX register and then do:
>
> add al,40h
> daa
> adc al,90h
> daa
>
> The result is an ASCII hex digit in the AX register. It’s not portable,
but
> it is a nifty piece of code.
>
> I think credit for this goes to Tim Paterson at Seattle Computer Products
> (circa 1980). At least that’s the first reference I saw to this
particular
> method.
>
> -Dan
>
> ----- Original Message -----
> > Subject: Binary/Hex to ASCII conversion in driver
> > From: Tom Pr
> > Date: Tue, 15 Apr 2003 16:36:02 -0700 (PDT)
> >
> > Hi All,
> >
> > How should I convert my 8 bit binary/Hex value to
> > corresponding ASCII in my device driver.
—
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.
Ho, here we go …
I hope that the ( two ) question poster guy(s) didn’t commit suicide after all previous comments … :)))
Christiaan
/*---------------------------------------------------------------------------------------------*/
UCHAR aValToCharConverter[16] = { ‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘A’,‘B’,‘C’,‘D’,‘E’,‘F’ } ;
VOID ConvertSequence ( IN ULONG nBinarySequenceSize ,
IN PVOID pBinarySequence ,
typedef UCHAR UCHARARRAY ;
typedef UCHARARRAY *pUCHARARRAY ;
CCHAR _cSequenceBuffer[128]; // OUTPUT
UCHAR _bytevalue ;
UCHAR _lnibble ;
UCHAR _hnibble ;
ULONG _binindex ;
/* convert the binary strings into character strings */
for ( _binindex = 0 ; _binindex < nBinarySequenceSize ; _binindex++ )
{
/* next code seems to generate the smallest amount of ASM instructions */
_bytevalue = (*(pUCHARARRAY)pBinarySequence)[_binindex] ;
_lnibble = aValToCharConverter[_bytevalue & 0x0F] ;
_hnibble = aValToCharConverter[_bytevalue >> 4] ;
_cSequenceBuffer[(_binindex << 1)] = _hnibble ;
_cSequenceBuffer[(_binindex << 1) + 1] = _lnibble ;
}
_cSequenceBuffer[nBinarySequenceSize << 1] = 0 ; /* string closing zero */
…
}
----- Original Message -----
From: “Moreira, Alberto”
To: “NT Developers Interest List”
Sent: Wednesday, April 16, 2003 6:40 PM
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
> Here, a very simple function - three lines of code - and a naive C++ tester
> to go with it. The “issue” call puts the characters out, one by one. You
> guys can convert it to assembler if you will, but I don’t think it’s
> necessary.
>
> Hope this helps !
>
> Alberto.
>
> //==============================================================
> void convert(int n)
> {
> char *k = “0123456789ABCDEF”;
> if (n > 15) convert(n>>4);
> issue (k[n&0xf]);
> }
> //==============================================================
>
> //==============================================================
> #include
> using namespace std;
>
> #define BUFFERSIZE 16
>
> static char c[BUFFERSIZE];
> static int p=0;
>
> void convert(int n)
> {
> char *k = “0123456789ABCDEF”;
> if (n > 15) convert(n>>4);
> issue (k[n&0xf]);
> }
>
> void prime()
> {
> p = 0;
> for (int i=0; i> }
>
> void issue(int digit)
> {
> c[p++] = digit;
> c[p] = 0;
> }
>
>
> main()
> {
> prime(); convert(0); cout << c << endl;
> prime(); convert(0x1); cout << c << endl;
> prime(); convert(0x12); cout << c << endl;
> prime(); convert(0x123); cout << c << endl;
>
> return 0;
> }
> //==============================================================
>
> ----Original Message-----
> From: Daniel E. Germann [mailto:xxxxx@nospam.visi.com]
> Sent: Wednesday, April 16, 2003 9:10 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
>
>
> Ahem. Allow me to kick myself in the pants. Please accept this correction:
> add al,90h
> daa
> adc al,40h
> daa
>
> -Dan
>
> ----- Original Message -----
> From: “Daniel E. Germann”
> To: “NT Developers Interest List”
> Sent: Wednesday, April 16, 2003 8:06 AM
> Subject: Re: Binary/Hex to ASCII conversion in driver
>
>
> > OK, don’t flame me. My favorite binary-to-ASCII conversion on the x86
> > platform is to put the 4-bit binary value I want to convert to ASCII in
> the
> > AX register and then do:
> >
> > add al,40h
> > daa
> > adc al,90h
> > daa
> >
> > The result is an ASCII hex digit in the AX register. It’s not portable,
> but
> > it is a nifty piece of code.
> >
> > I think credit for this goes to Tim Paterson at Seattle Computer Products
> > (circa 1980). At least that’s the first reference I saw to this
> particular
> > method.
> >
> > -Dan
> >
> > ----- Original Message -----
> > > Subject: Binary/Hex to ASCII conversion in driver
> > > From: Tom Pr
> > > Date: Tue, 15 Apr 2003 16:36:02 -0700 (PDT)
> > >
> > > Hi All,
> > >
> > > How should I convert my 8 bit binary/Hex value to
> > > corresponding ASCII in my device driver.
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compuware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it.
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
What’s the point in writing that kind of code when you could simply #include
<stdio.h> and call sprintf()?
OF COURSE, that will run faster if you define a function which will do just
the minimum you need. But is it really worth the time and risk of bug?
Unless that function is in a tight loop, I would rather use sprintf()…
Any objections?
Mat
-----Original Message-----
From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Wednesday, April 16, 2003 2:12 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
Ho, here we go …
I hope that the ( two ) question poster guy(s) didn’t commit suicide after
all previous comments … :)))
Christiaan
/--------------------------------------------------------------------------
-------------------/
UCHAR aValToCharConverter[16] = {
‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘A’,‘B’,‘C’,‘D’,‘E’,‘F’ } ;
VOID ConvertSequence ( IN ULONG nBinarySequenceSize ,
IN PVOID
pBinarySequence ,
# pragma pack ( 1 )
typedef UCHAR UCHARARRAY ;
typedef UCHARARRAY pUCHARARRAY ;
# pragma pack ( )
CCHAR _cSequenceBuffer[128]; // OUTPUT
UCHAR _bytevalue ;
UCHAR _lnibble ;
UCHAR _hnibble ;
ULONG _binindex ;
/ convert the binary strings into character strings /
for ( _binindex = 0 ; _binindex < nBinarySequenceSize ; _binindex++ )
{
/ next code seems to generate the smallest amount of ASM instructions
/
_bytevalue = ((pUCHARARRAY)pBinarySequence)[_binindex] ;
_lnibble = aValToCharConverter[_bytevalue & 0x0F] ;
_hnibble = aValToCharConverter[_bytevalue >> 4] ;
_cSequenceBuffer[(_binindex << 1)] = _hnibble ;
_cSequenceBuffer[(_binindex << 1) + 1] = _lnibble ;
}
_cSequenceBuffer[nBinarySequenceSize << 1] = 0 ; /* string closing zero
*/
…
}
----- Original Message -----
From: “Moreira, Alberto”
To: “NT Developers Interest List”
Sent: Wednesday, April 16, 2003 6:40 PM
Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
> Here, a very simple function - three lines of code - and a naive C++
tester
> to go with it. The “issue” call puts the characters out, one by one. You
> guys can convert it to assembler if you will, but I don’t think it’s
> necessary.
>
> Hope this helps !
>
> Alberto.
>
> //==============================================================
> void convert(int n)
> {
> char *k = “0123456789ABCDEF”;
> if (n > 15) convert(n>>4);
> issue (k[n&0xf]);
> }
> //==============================================================
>
> //==============================================================
> #include
> using namespace std;
>
> #define BUFFERSIZE 16
>
> static char c[BUFFERSIZE];
> static int p=0;
>
> void convert(int n)
> {
> char *k = “0123456789ABCDEF”;
> if (n > 15) convert(n>>4);
> issue (k[n&0xf]);
> }
>
> void prime()
> {
> p = 0;
> for (int i=0; i> }
>
> void issue(int digit)
> {
> c[p++] = digit;
> c[p] = 0;
> }
>
>
> main()
> {
> prime(); convert(0); cout << c << endl;
> prime(); convert(0x1); cout << c << endl;
> prime(); convert(0x12); cout << c << endl;
> prime(); convert(0x123); cout << c << endl;
>
> return 0;
> }
> //==============================================================
>
> ----Original Message-----
> From: Daniel E. Germann [mailto:xxxxx@nospam.visi.com]
> Sent: Wednesday, April 16, 2003 9:10 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: Binary/Hex to ASCII conversion in driver
>
>
> Ahem. Allow me to kick myself in the pants. Please accept this
correction:
> add al,90h
> daa
> adc al,40h
> daa
>
> -Dan
>
> ----- Original Message -----
> From: “Daniel E. Germann”
> To: “NT Developers Interest List”
> Sent: Wednesday, April 16, 2003 8:06 AM
> Subject: Re: Binary/Hex to ASCII conversion in driver
>
>
> > OK, don’t flame me. My favorite binary-to-ASCII conversion on the x86
> > platform is to put the 4-bit binary value I want to convert to ASCII in
> the
> > AX register and then do:
> >
> > add al,40h
> > daa
> > adc al,90h
> > daa
> >
> > The result is an ASCII hex digit in the AX register. It’s not portable,
> but
> > it is a nifty piece of code.
> >
> > I think credit for this goes to Tim Paterson at Seattle Computer
Products
> > (circa 1980). At least that’s the first reference I saw to this
> particular
> > method.
> >
> > -Dan
> >
> > ----- Original Message -----
> > > Subject: Binary/Hex to ASCII conversion in driver
> > > From: Tom Pr
> > > Date: Tue, 15 Apr 2003 16:36:02 -0700 (PDT)
> > >
> > > Hi All,
> > >
> > > How should I convert my 8 bit binary/Hex value to
> > > corresponding ASCII in my device driver.
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compuware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or
disclose
> it to anyone else. If you received it in error please notify us
immediately
> and then destroy it.
>
>
>
> —
> You are currently subscribed to ntdev as:
xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
—
You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</stdio.h>