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 2,843 of 4,675   
   Terje Mathisen to wolfgang kern   
   Re: Look back to "just for the H@ck"   
   18 Jul 17 15:55:23   
   
   From: terje.mathisen@nospicedham.tmsw.no   
      
   wolfgang kern wrote:   
   > Terje Mathisen wrote:   
   > ...   
   >>>> So you decide the rules and tell and show us (if you want).   
   >>>   
   >>> Thanks, I thought real needs caused this restrictions.   
   >>> So my rules for such an Base64 decoder would allow ASCII 33..127 and   
   >>> nothing less than 386 code.   
   >   
   >> That's rather stupid IMHO:   
   >   
   >> If you have 95 available characters you should get at least 6.5   
   >> bits/char, i.e. with such a large alphabet you need to use something   
   >> more efficient than Base64.   
   >   
   > Yes, I just wanted to take on the challenge for "shortest Base64" decoder.   
   >   
   > My idea was 7 bit and two prefix chars to sub constants for 128..255   
   > and 00..32, but didn't check as this may be no the shortest solution.   
   >   
   >> My first ascii executable used both POP BX and Base91. :-)   
   >   
   > was it much shorter then ?   
      
   It didn't need the Base64 decoder, but handling 16-bytes to 13 isn't   
   free either. This was more than 20 years ago so I don't remember the   
   details, like what I did if the input wasn't a multiple of 13 bytes long?   
      
   I believe I just encoded enough pairs (of 13 bits each) so that I   
   covered the input, then the decoder could just grab whatever garbage   
   happened to reside past the end.   
      
   Something like this?   
      
      bits =-8; buffer = 0;   
      do {   
        pair = (*src++ - 33) + (*src++ - 33) * 91; // 0 to 4095   
        buffer = (buffer << 13) + pair;   
        bits += 13;   
        do {   
          *dst++ = buffer & 255;   
          buffer >>= 8;   
          bits -= 8;   
        } while (bits >= 0);   
      } while (src < src_end);   
      
   with lots of opportunities for nice asm trickery to shorten it. :-)   
      
   Terje   
      
   --   
   -    
   "almost all programming can be viewed as an exercise in caching"   
      
   --- 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