; This file is a specialized form of filter to change any lone 0a, 0d or ; 0a0d codes in a file into 0D0A codes for use on DOS or Windows. ; 0d = CR, 0a = LF; => 0d0d0d is unlikely but 0a0a0a is possible ;options (x can be any character, including 0a or 0d): ;0ax -> 0d0ax if a, check for d next ;0a0dx -> 0d0ax (if so skip) ;0dx -> 0d0ax if d, check for a next ;0d0ax -> 0d0ax (if so skip) ;e.g. 0a0a0a0d0a0d0d0a -> 0d0a 0d0a 0d0a 0d0a 0d0a ; Logic: ; with either a or d, send out 0d0a ; 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 odoa call inpc cmp al, 0dh je inpchar ;skip it -- 0a(0d) already written as 0d0a cmp al, 0ah je gota ;next lot jmps norep ;other character gotd call odoa call inpc cmp al, 0ah je inpchar ;skip it -- 0d(0a) already writen as 0d0a 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 odoa proc near mov al, 0dh call outc mov al, 0ah call outc ;writes AL -- 0d0a in total 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'