Category : C Source Code
Archive   : CEXPRESS.ZIP
Filename : CMPRSTXT.ASM
; unsigned char *strg,*return_strg,del_ch,flag_ch;
EXTRN _memory_model:byte
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _compress_text
_compress_text proc near
push bp ;
mov bp,sp ;set stack frame
push di ;
push si ;
push ds ;save DS
cmp _memory_model,0 ;near or far?
jle begin ;jump if near
inc bp ;else add 2 to BP
inc bp ;
begin: cmp _memory_model,2 ;data near or far?
jb L0 ;jump if near
lds si,dword ptr[bp+4] ;DS:SI points to source string
les di,dword ptr[bp+8] ;ES:DI points to return string
add bp,4 ;adjust stack pointer
jmp short L00 ;jump ahead
L0: mov ax,ds ;near case
mov es,ax ;
mov si,[bp+4] ;
mov di,[bp+6] ;
L00: mov ah,[bp+8] ;deletion character to AH
mov al,ah ;copy in AL
mov dh,[bp+10] ;flag character to DH
mov byte ptr es:[di],0 ;0 return length if error
cmp byte ptr[si],0 ;test for null string
je L7 ;quit if null
L1: mov dl,[si] ;get char from Strg
or dl,dl ;end of string yet?
jz L6 ;quit if so
cmp dl,ah ;a deletion char?
jne L4 ;jump ahead if not
cmp [si+1],ax ;next two chars del char?
jne L4 ;no deletion if not
mov es:[di],dh ;set flag character
mov dl,1 ;DL counts del chars
L2: inc si ;forward Strg ptr
cmp [si],al ;a delete char?
jne L3 ;jump ahead if not
inc dl ;count it
jnz L2 ;go check next
L3: dec si ;char not found, ptr back
inc di ;forward ret strg ptr
add dl,128 ;add 128 to counter
mov es:[di],dl ;place char counter
jmp short L5 ;reenter main loop
L4: mov es:[di],dl ;place char in ret strg
inc ch ;inc ret strg counter
dec cl ;dec Strg length counter
L5: inc si ;forward Strg ptr
inc di ;forward return ptr
jmp short L1 ;go get next char
L6: inc di ;forward return string ptr
mov byte ptr es:[di],0 ;set return strg length
L7: pop ds ;
pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_compress_text ENDP
_TEXT ENDS
END
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/