Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/20/04 16:01
Read: times


 
#65199 - RE: Apply a little thought
Responding to: ???'s previous message
You can convert a character to its equivalent binary value by doing character comparisions to find the range of character (i.e. '0'-'9' or 'A'-'F' or 'a'-'f') and then doing a subtraction to compete the conversion.

Alternatively, you use assembly language like this:

#pragma ASM

    $REGUSE _fast_ascii_hexadecimal_to_binary( A, R7 )

#pragma ENDASM

char fast_ascii_hexadecimal_to_binary( char character )
{
    character = character;                  // Supress UNUSED warning.

    #pragma ASM

        MOV     A,R7                        ;
                                            ;
fast_ascii_hexadecimal_to_binary:           ;
                                            ;
        MOV     C,Acc.6                     ;C set for 'A'-'F' or 'a'-'f'
        ANL     A,#0x0F                     ;
        JNC     ?fahtb_skip                 ;
        ADD     A,#0x09                     ;
                                            ;
?fahtb_skip:                                ;
                                            ;
        MOV     R7,A                        ;
                                            ;
    #pragma ENDASM

    return( character );
}


List of 17 messages in thread
TopicAuthorDate
ASCII TO HEX QUESTION            01/01/70 00:00      
   RE: ASCII TO HEX QUESTION            01/01/70 00:00      
   RE: ASCII TO HEX QUESTION            01/01/70 00:00      
      RE: ASCII TO HEX QUESTION            01/01/70 00:00      
         RE: ASCII TO HEX QUESTION            01/01/70 00:00      
         RE: ASCII TO HEX QUESTION            01/01/70 00:00      
         RE: ASCII TO HEX QUESTION            01/01/70 00:00      
         You already have it!!!!            01/01/70 00:00      
            RE: You already have it!!!!            01/01/70 00:00      
               RE: why guess            01/01/70 00:00      
                  RE: why guess            01/01/70 00:00      
                     RE: why guess            01/01/70 00:00      
                        RE: why guess            01/01/70 00:00      
                     Speculation            01/01/70 00:00      
         RE: ASCII TO HEX QUESTION            01/01/70 00:00      
   Apply a little thought            01/01/70 00:00      
      RE: Apply a little thought            01/01/70 00:00      

Back to Subject List