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,314 of 4,675   
   Kerr-Mudd,John to notsaying@nospicedham.invalid.org   
   Re: Hex 2 Bin   
   23 Mar 18 08:36:10   
   
   From: notsaying@nospicedham.invalid.org   
      
   On Wed, 21 Mar 2018 11:26:44 GMT, "Kerr-Mudd,John"   
    wrote:   
      
   > On Wed, 21 Mar 2018 01:10:40 GMT, "wolfgang kern"    
   > wrote:   
   >   
   >> Kerr-Mudd,John wrote:   
   >>   
   >>> My googlefu is awful; I can't get any decent (i.e. short fast)   
   >>> hex2bin asm source code.   
      
   []   
      
   >>   
   >> shorter without checks and only one branch:   
   >>   
   > need to add cr lf space skipping   
   >>  and al,0x4f   
   >>  cmp al,0x40     ;any U/Lcase or Num   
   >>  jb +2           ;skip   
   >>  sub al,0x37     ;add 9 sub 0x40   
   >>                  ;al = 00..0F   
   >   
   >> __   
   >> wolfgang   
   >>   
   >   
   > 10 bytes, with Jxx but no AAx   
   > ;; 1x becomes num            ; 0A 0D 20 30 41 61 66   
   >          or  al,0x20         ; 2A 2D 20 30 61 61 66   
   >          sub al,'a'-0x0A     ; D3 D6 C9 D9 0A 0A 0F  ; 0x57   
   >          jae havehex   
   >          add al,'a'-0x0A-'0' ;  -  -  -  0  x  x  x  ; 0x27   
   >          js  gnc             ; skip cr lf space   
   > havehex:   
   >   
   >   
   Sorry to be so slow; 8 bytes:   
      
   cmp al'0'   
   jb gnc       ; skip space, cr, lf   
   and al,0x4F  ; drop numeric '3' prefix, lcase->ucase   
   aam 0x37     ; add 9 sub 0x40 iff alpha   
      
   --   
   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