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,315 of 4,675   
   wolfgang kern to All   
   Re: Hex 2 Bin   
   23 Mar 18 10:52:37   
   
   From: nowhere@never.at   
      
   Kerr-Mudd,John posted "at the very same time":   
   []   
   >>> 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   
      
   >> 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   
      
   mmh, I always avoid AA.. but it may become handy sometimes :)   
   __   
   wolfgang   
      
   --- 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