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

 
Output of file : DELMDDL.ASM contained in archive : CEXPRESS.ZIP
;void delete_middle(strg,position,left,right);
; unsigned char *strg,left,right;
; unsigned short position;

EXTRN _memory_model:byte
EXTRN _error_code:byte

_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _delete_middle
_delete_middle proc near
push bp ;
mov bp,sp ;set stack frame
push di ;
push si ;
push ds ;
mov _error_code,1 ;1 = error occured
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 pts to Strg
inc bp ;add 2 to bp since dword ptr
inc bp ;
jmp short L1 ;
L0: mov si,[bp+4] ;NEAR case
L1: mov cx,[bp+6] ;get starting position
inc cx ;count from 1
mov dx,cx ;make a copy
L2: cmp byte ptr[si],0 ;seek start position
je L8 ;quit if start not within string
inc si ;forward ptr
loop L2 ;loop to start point
dec si ;ptr overshoots
mov di,si ;copy ptr position
mov cx,dx ;number chars to start of string
mov ah,[bp+8] ;get left border char
mov bh,[bp+10] ;right border char
mov al,[si] ;get char at starting position
cmp al,ah ;test against border chars
je L8 ;
cmp al,bh ;
je L8 ;
L3: dec si ;pull ptr back one byte
cmp [si],ah ;is char a border char?
je L4 ;jump when found
loop L3 ;loop
L4: inc si ;don't delete border char
L5: mov al,es:[di] ;get a char
cmp al,0 ;end of string?
je L7 ;jump if so
cmp al,bh ;right border char?
je L6 ;jump if so
inc di ;else forward ptr
jmp short L5 ;loop
L6: mov al,es:[di] ;now transfer down top end of string
mov [si],al ;
cmp al,0 ;terminator?
je L7B ;quit if so
inc si ;inc the ptrs
inc di ;
jmp short L6 ;loop
L7: mov byte ptr[si],0 ;no right border case
L7B: pop ds ;
mov _error_code,0 ;no error
jmp short L9 ;
L8: pop ds ;restore DS
L9: pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_delete_middle ENDP
_TEXT ENDS
END


  3 Responses to “Category : C Source Code
Archive   : CEXPRESS.ZIP
Filename : DELMDDL.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/