Category : Assembly Language Source Code
Archive   : STDLIB_A.ZIP
Filename : STRDEL2.ASM

 
Output of file : STRDEL2.ASM contained in archive : STDLIB_A.ZIP
stdlib segment para public 'slcode'
assume cs:stdlib
;
extrn sl_malloc:far
;
; strdel2- deletes characters from a string.
;
; inputs:
;
; ES:DI- Points at the string to delete characters from.
;
; CX- Index into source string (ES:DI) to begin deletion.
;
; AX- Number of characters to delete.
;
; outputs:
;
; ES:DI- Points at new string on stack which is the image of the
; source string minus the specified characters.
;
; Carry=1 if memory allocation error, 0 if sufficient memory for the
; new string.
;
;
public sl_strdel2
;
;
sl_strdel2 proc far
push es
push di
push si
push ds
push ax
push bx
push cx
mov bx, ax ;Save length
;
; Compute the length of the source string:
;
push es
push di
push cx
mov cx, 0ffffh
mov al, 0
repne scasb
neg cx
sub cx, bx ;Compute length of new str.
jnc DoAlloc ;Too much to delete?
pop cx ;Use insertion point as
push cx ; the length.
;
DoAlloc: call sl_malloc
jnc GoodAlloc
add sp, 6
pop cx
pop bx
pop ax
pop ds
pop si
pop di
pop es
ret
;
GoodAlloc: pop cx
pop si
pop ds
push es ;Save ptr to new string.
push di
Cpy1: lodsb
stosb
cmp al, 0
loopne Cpy1
jz DelDone
Skp1: mov cx, bx ;Get # chars to delete
Skp2: lodsb
cmp al, 0
loopne Skp2
jz DelDone
Cpy2: lodsb
stosb
cmp al, 0
jnz Cpy2
;
DelDone: mov byte ptr es:[di], 0
pop di
pop es
pop cx
pop bx
pop ax
pop ds
pop si
add sp, 4 ;Don't restore es:di
ret
sl_strdel2 endp
;
;
stdlib ends
end


  3 Responses to “Category : Assembly Language Source Code
Archive   : STDLIB_A.ZIP
Filename : STRDEL2.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/