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,280 of 4,675   
   Kerr-Mudd,John to All   
   Re: Hex to bin   
   17 Feb 18 19:24:10   
   
   From: notsaying@nospicedham.invalid.org   
      
   On Sat, 17 Feb 2018 15:00:18 GMT, "wolfgang kern"    
   wrote:   
      
   > Kerr-Mudd,John wrote:   
   >   
   >>>> For education and amusement I hereby present clax with a 5:4   
   >>>> (base85) decoder for DOS! Same caveat; the 1st 2 lines (well up to   
   >>>> and including the eeeee string) must be "as is", reflowing (cr,lf   
   >>>> spaces) should be OK afterwards.   
   >   
   >> actually removing the crlf is OK, but not inserting newlines. I'd   
   >> forgotten that whilst my ret slide of "dec bp" is usually OK it could   
   >> be an issue here; but I reset bp to 0 in the secondary stage anyway.   
   >> []   
   >>> I'll check on it, but give me some more time ...   
   >   
   >> Sure; it is a bit complicated (at least to me!). I use bp::dx as a   
   >> qword accumulator for the 5:4 decoding.   
   >   
   > I couldn't fully figure all details so far. What I got is your decoder   
   > at 03d..07e and it seem to work (I had to stop on the first INT21   
   > call). a few questions:   
   >   
   > * DEC BP  JNO   you want a branch always?   
      
   If you mean the INC BP, JO at the top of the secondary, then yes. I   
   branch back to here and forward again to avoid a fixup; effectively it   
   replaces an inline ADC BP,0.   
      
   > OV is only set on transitions from 8000 to 7FFF (opposite for INC) but   
   > not from 0 to FFFF and reverse, I dont think that my debugger is   
   > wrong.   
      
   perhaps a JNZ would look better?   
      
      
   >   
   > * XOR BH,[si] JNZ 06A ;if this isn't a 'branch never' it may act   
   > endless.   
      
   It's a branch once! BH is 0 at start; it re-executes the previous code.   
      
   >   
   > * EXCH AL,AH  ;Big Endian encoded ?   
   no, it's to correct for STOSW's Little-Ending storage!   
   >   
   > perhaps you can save on one branch in the prologue: JB 0171 JA 0171   
   > with a single JNE 0171.   
      
   Ah no, that 2nd JA address gets changed on the fly at the end the search,   
   to JA to a MOVSB. the JB continues to reject cr/lf etc. after DH is XOR'd   
   >   
   > Your encoder must be tricky to avoid some characters so your 5:4   
   > format can use 0x21..0x7D except quote marks (90 characters ?)   
      
   Ah; no I haven't done any of that (yet?). So it won't be much use In Real   
   Life.   
   It makes the decoder too big to fit in early memory too; either a lookup   
   table (+code) or lots of "if x, add 7, if y sub 34" code; c. 30 bytes   
      
      
   > the use of 0x66 overrides may make the whole story easier ie:   
   > ...   
   > XOR eax,eax       ;or if bp=0 : push bp bp pop eax   
   > LODSB             ;check/skip/end   
   > ...   
   > IMUL ebx,eax,0x55   
   > ADD [di],ebx   
   > ...               ;inner loop for powers 4,3,2,1   
   > fifth:   
   > ADD [di],eax   
   > INC di   dup 4   
   > ...               ;loop until end mark   
      
   Thanks for the tips; as I suspected, it's easier with 32bits!   
      
   > __   
   > wolfgang   
   >   
   >   
      
      
      
   --   
   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