XPost: comp.os.msdos.programmer, alt.lang.asm   
   From: admin@nospicedham.127.0.0.1   
      
   On Mon, 2 Jan 2023 11:53:55 +0100   
   wolfgang kern wrote:   
      
   > On 31/12/2022 21:52, Kerr-Mudd, John wrote:   
   >   
   > >>>> example text to unrot:   
   > >>>>   
   > >>>> Onebarff Znetnerg Gungpure!   
   >   
   > >>> Now allows >1 space between the strings! (but no error checking)   
   > >> Now 90 bytes, assumes that at start ax=0,bh=0 and that cx > lth of   
   > >> parameters.   
   > >> I think that's as small as I can manage.   
      
   [I've found a problem and a few small gains; now 87]   
      
   >   
   > >> Wolfgang, would you like it in asm? here it is -   
   >   
   > :) Happy New Year!   
   >   
   And to you!   
      
   > I actually had no idea what this is supposed to do...   
   > if it is something like ROT13 I dunno the required algo. but   
      
   Sorry I dropped that part; it's an implementation of unix's   
   'tr' utility that unix users use to do rot13.   
      
   rot13:   
      
   tr '[A-Za-z]' '[N-ZA-Mn-za-m]'   
   or   
   tr 'A-Za-z' 'N-ZA-Mn-za-m'   
      
   (luckily both work as the square brackets are translated to themselves!)   
      
   > code parts look suspicious as if compiled by good old BASIC.   
      
   Er, I'm that good? - the 'clever' bits are:   
   1) using 'dl' as a toggle to alterately get a 'from' char and then a 'to'   
   char.   
      
   2) dealing with the range by keeping 'si' at the 'dash'   
      
   once the table is setup it's just a matter of fileio and using 'xlat' on   
   each input byte.   
      
   >   
   > >> -> u 100 l5A   
   > >> 1637:0100 99 cwd   
   > >> 1637:0101 BF 5A 01 mov di,015A ; Xlat Table after code   
   > >> 1637:0104 AA stosb   
   > >> 1637:0105 FE C0 inc al ; full range 0-255   
   > >> 1637:0107 75 FB jnz 0104   
      
   > >> 1637:0109 B3 83 mov bl,83 ; pt to PSP parms, after 1st   
   string's initial quote   
   > >> 1637:010B B0 20 mov al,20   
   > >> 1637:010D 89 DF mov di,bx   
   > >> 1637:010F F2 AE repnz scasb ; find gap   
   > >> 1637:0111 F3 AE repz scasb ;;; skip intermediate spaces   
   > >> 1637:0113 89 FE mov si,di ; after 1st quote of 2nd   
   string   
   > >> 1637:0115 80 F2 01 xor dl,01   
   > >> 1637:0118 74 04 jz 011E   
   > >   
   > > 1637:011A 88 85 5A 01 mov [di+015A],al   
      
   this is the 'problem'; on 1st run it hits a table entry; I hadn't noticed   
   unitl now as it's a non-ASCII 8x posn. It can be lived with, but I find it   
   unsatisfactory; I want the smallest, but fully functional code!   
      
   > > 1637:011E 97 xchg ax,di   
   > >   
   > >> 1637:011F 87 DE xchg bx,si   
   > >> 1637:0121 80 3C 2D cmp byte [si],2D ; processing a range?   
   > >> 1637:0124 75 08 jnz 012E   
   > >> 1637:0126 40 inc ax   
   > >> 1637:0127 3A 44 01 cmp al,[si+01]   
   > >> 1637:012A 76 E9 jbe 0115   
   > >> 1637:012C 46 inc si   
   > >> 1637:012D 46 inc si   
   > >> 1637:012E AC lodsb   
   > >> 1637:012F 3C 27 cmp al,27 ; end of string   
   > >> 1637:0131 75 E2 jnz 0115   
      
   > >> 1637:0133 BA 5A 02 mov dx,025A ; IO area   
   > >> 1637:0136 31 DB xor bx,bx   
   > >> 1637:0138 89 D6 mov si,dx   
   > >> 1637:013A 89 F7 mov di,si   
   > >> 1637:013C B9 A5 FD mov cx,FDA5 ; remainder of seg as IO   
   area   
   > >> 1637:013F B4 3F mov ah,3F ; read from STDIN   
   > >> 1637:0141 CD 21 int 21   
   > >> 1637:0143 91 xchg ax,cx   
   > >> 1637:0144 E3 13 jcxzw 0159 ; no more input   
   > >> 1637:0146 BB 5A 01 mov bx,015A   
   > >> 1637:0149 51 push cx   
   > >> 1637:014A AC lodsb   
   > >> 1637:014B D7 xlat [bx]   
   > >> 1637:014C AA stosb   
   > >> 1637:014D E2 FB loopw 014A   
   > >> 1637:014F 59 pop cx   
   > >> 1637:0150 BB 01 00 mov bx,0001   
   > >> 1637:0153 B4 40 mov ah,40 ; write to STDOUT   
   > >> 1637:0155 CD 21 int 21   
   > >> 1637:0157 EB DD jmp 0136   
   > >> 1637:0159 C3 ret   
      
      
      
   --   
   Bah, and indeed Humbug.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|