Listing 3 The filter function

       .386
       ifndef ??version
?debug  macro
       endm
       endif
       ?debug  S "filtfunc.cpp"
       ?debug  T "filtfunc.cpp"
_TEXT   segment dword public use32 'CODE'
_TEXT   ends
_DATA   segment dword public use32 'DATA'
_DATA   ends
_BSS    segment dword public use32 'BSS'
_BSS    ends
       .model FLAT
       assume cs: FLAT, ds: FLAT, ss: FLAT, es: FLAT

       newline_char   EQU     10  ;'\n'
       return_char    EQU     13  ;'\r'

_TEXT   segment dword public use32 'CODE'
c@      label  byte
@filter_function$qpctli proc  near
   ;
   ;    filter_function( char *indata, char *outdata, int insize )
   ;
@6@35:
       PUSH    EBP
       MOV     EBP,ESP
       PUSHFD
       PUSH    ESI
       PUSH    EDI
       PUSH    ECX
       PUSH    EDX
       XOR     EAX,EAX
       MOV     ESI,[ EBP +  8 ]        ;in buffer pointer
       MOV     EDI,[ EBP + 12 ]        ;out buffer pointer
       MOV     ECX,[ EBP + 16 ]        ;in buffer chars
       MOV     EDX,EDI
       JECXZ   return_zero
       CLD                             ;increment pointers on movsb
       MOV    AL,return_char           ;for stosb insertions of '\r'

check4newline:

       CMP    BYTE PTR [ ESI ],newline_char
                            ;if newline, put '\r'
       JE     put_return_char

copy_char:

       MOVSB
       LOOP   check4newline
       JMP    SHORT return_result

put_return_char:

       STOSB
       JMP    SHORT copy_char

return_result:

       MOV    EAX,EDI
       SUB    EAX,EDX  ;EAX returns number of bytes
                    ;inserted in output buffer

return_zero:

       POP    EDX
       POP    ECX
       POP    EDI
       POP    ESI
       POPFD
       POP    EBP
       RET    12
@8@0:
@filter_function$qpct1i endp
_TEXT   ends
       ?debug  D "E:\BCOS2\INCLUDE\process.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\string.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\stdlib.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\_nfile.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\_defs.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\stdio.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmstddlg.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmerr.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmwp.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmdev.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmgpi.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmshl.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pmwin.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\pm.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\bseerr.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\bsesub.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\bsememf.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\bsetib.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\bsedos.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\bse.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\os2def.h" 6740 2048
       ?debug  D "E:\BCOS2\INCLUDE\os2.h" 6740 2048
       ?debug  D "E:\BCOS2\INC\ffilter.hpp" 6911 25049
       ?debug  D "E:\BCOS2\INC\FILTFUNC.HPP" 6911 27048
       ?debug  D "filtfunc.cpp" 6911 27042
_s@     equ     s@
_abs    equ     abs
_atoi   equ     atoi
       public  @filter_function$qpct1i
_DATA   segment dword public use32 'DATA'
d@      label   byte
d@w     label   word
d@d     label   dword
s@      label   byte
_DATA   ends
_BSS    segment dword public use32 'BSS'
b@      label   byte
b@w     label   word
b@d     label   dword
_BSS    ends
       end

; End of File