home bbs files messages ]

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

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

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

   Message 3,312 of 4,675   
   Kerr-Mudd,John to All   
   Hex 2 Bin   
   20 Mar 18 21:01:56   
   
   From: notsaying@nospicedham.invalid.org   
      
   My googlefu is awful; I can't get any decent (i.e. short fast) hex2bin asm   
   source code. Just some learners with naive code such as (top of head)   
   ------------   
   cmp al,'0'   
   jb gnc   
   cmp al,'9'   
   jb isnum   
   and al,0xDF ; scrap lowercase   
   sub al,'A'   
   jb gnc   
   add al,0x0A   
   jmp havehex   
   isnum:   
   sub al,0x30   
   havehex:   
   ------------   
      
      
   I want something with far less jmps!   
      
   Best I can manage so far is   
   ------------   
            cmp al,'0'          ;      ah/al   
            jb gnc              ;    3x  41   61   
            aam 0x40            ;  0/3x 1/1 1/21   
            aad 0x09            ;  0/3x 1/A 1/2A   
            and al,0x0F         ;    0x  0A   0A   
   havehex:   
   ------------   
   but 'aam'  and 'aad' aren't too fast.   
   Anyone do better?   
      
      
      
   --   
   Bah, and indeed, Humbug.   
      
   --- 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