Category : C Source Code
Archive   : CEXPRESS.ZIP
Filename : FLTEROUT.ASM

 
Output of file : FLTEROUT.ASM contained in archive : CEXPRESS.ZIP
;char filter_out(ascii_string,extended_string);
; char *ascii_string,*extended_string;

EXTRN _memory_model:byte
EXTRN _error_code:byte
EXTRN _beep_on:byte

_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _filter_out
_filter_out proc near
push bp ;
mov bp,sp ;set up stack frame
push di ;
cmp _memory_model,0 ;near or far?
jle A1 ;jump if near
inc bp ;else add 2 to BP
inc bp ;
A1: mov _error_code,0 ;0 = ASCII code
mov ax,ds ;make ES = DS for NEAR case
mov es,ax ;
cmp _memory_model,2 ;data near or far?
jb L0 ;
les di,dword ptr[bp+4] ;ES:DI pts to ASCIIString
jmp short L00 ;
L0: mov di,[bp+4] ;near case
L00: sub ah,ah ;function to read key
int 16h ;wait for a keystroke
or al,al ;extended code?
jnz B1 ;jump ahead if not
inc _error_code ;1 = extended code
mov al,ah ;move 2nd byte to AL
cmp _memory_model,2 ;again, near or far?
jb L000 ;
les di,dword ptr[bp+8] ;ES:DI pts to ExtendedString
jmp short B1 ;
L000: mov di,[bp+6] ;
B1: mov ch,es:[di] ;string length to CH
inc ch ;adjust for loop entry
mov dl,al ;place char in DL
cmp dl,8 ;is it the backspace key?
jne C1 ;jump ahead if not
cmp ah,14 ;Scan code for backspace
je F1 ;jump ahead if single key
mov dl,208 ;208 signals Ctrl-H
C1: cmp dl,9 ;is it the tab key?
jne D1 ;jump ahead if not
cmp ah,15 ;Scan code for tab key
je F1 ;jump ahead if single key
mov dl,209 ;209 signals Ctrl-I
D1: cmp dl,13 ;is it the return key?
jne E1 ;jump ahead if not
cmp ah,28 ;Scan code for Return key
je F1 ;jump ahead if single key
mov dl,213 ;213 signals Ctrl-M
E1: cmp dl,27 ;is it the escape key?
jne F1 ;jump ahead if not
cmp ah,1 ;Scan code for Esc key
je F1 ;jump ahead if single key
mov dl,227 ;227 signals Ctrl-[
F1: mov al,es:[di] ;get the character
inc di ;forward string pointer
cmp al,0 ;test for end of string
je K1 ;
cmp al,0FFH ;test if all chars excluded
je G1 ;loop if so
cmp al,es:[di] ;is next char the same?
je I1 ;jump to range routine
cmp al,dl ;does char match?
jne F1 ;if not, go try the next
G1: mov ah,2 ;char found, beep and reject it
mov dl,7 ;beep character
cmp _beep_on,0 ;test if beep enabled
je H1 ;jump if not
int 21h ;beep! wrong key
H1: jmp A1 ;go try next keystroke
I1: inc di ;start char range check
sub ch,2 ;adjust strg len counter
mov bl,es:[di] ;get character
inc di ;forward string pointer
cmp al,bl ;compare 2 chars in range
jb J1 ;jump if AL lower
xchg al,bl ;else exchg the 2 values
J1: cmp dl,al ;cmp input to low char
jb F1 ;out of range if below
cmp dl,bl ;cmp input to high char
ja F1 ;out of range if above
jmp short G1 ;go beep and try again
K1: mov al,dl ;set char for return
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_filter_out ENDP
_TEXT ENDS
END


  3 Responses to “Category : C Source Code
Archive   : CEXPRESS.ZIP
Filename : FLTEROUT.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/