; This file is a specialized form of filter to change any lone 0a, 0a0d ; or 0d0a codes in a file into 0D codes for use on a Macintosh. ; 0d = CR, 0a = LF; => 0d0d0d is unlikely but 0a0a0a is possible ;options (x can be any character, including 0a or 0d): ;0ax -> 0dx if a, check for d next ;0a0dx -> 0dx (if so skip) ;0dx -> 0dx if d, check for a next ;0d0ax -> 0dx (if so skip) ;e.g. 0a0a0a0d0a0d0d0a -> 0d 0d 0d 0d 0d ; Logic: ; with either a or d, send out 0d ; if next is same (repeated), send out same again ; if next is other one (pair), skip it inpchar call inpc cmp al, 0ah je gota cmp al, 0dh je gotd jmps norep ;no need to replace gota call od call inpc cmp al, 0dh je inpchar ;skip it -- 0a(0d) already written as 0d cmp al, 0ah je gota ;next lot jmps norep ;other character gotd call od call inpc cmp al, 0ah je inpchar ;skip it -- 0d(0a) already writen as 0d cmp al, 0dh je gotd ;next lot jmps norep ;other character norep call outc ;writes AL jmps inpchar eof mov ah, 4ch int 21h inpc proc near mov bx, 0 ;stdin mov cx, 1 ;read 1 byte mov ah, 3fh ;read file/device function mov dx, offset inbuff int 21h or ax, ax ;zero means no characters read jz eof ;SHOULD DO RET FIRST?! mov al, inbuff ;get character read ret endp od proc near mov al, 0dh call outc ret endp outc proc near mov outbuff, al mov bx, 1 ;stdout mov cx, 1 ;write one byte mov dx, offset outbuff mov ah, 40h ;write file/device function int 21h ret endp inbuff db '1' outbuff db '2'