home *** CD-ROM | disk | FTP | other *** search
- ;void over_write(strg,sub_strg,position);
- ; char *strg,*sub_strg;
- ; unsigned short position;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _over_write
- _over_write proc near
- mov _error_code,0 ;assume no error
- push bp ;
- mov bp,sp ;set up stack frame
- push di ;
- push si ;
- push ds ;DS is changed
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: sub cx,cx ;
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- les di,dword ptr [bp+4] ;ES:DI pts to Strg
- lds si,dword ptr [bp+8] ;DS:SI pts to substring
- mov cx,[bp+12] ;position
- jmp short L1 ;
- L0: mov di,[bp+4] ;NEAR case
- mov si,[bp+6] ;
- mov cx,[bp+8] ;
- mov ax,ds ;ES = DS
- mov es,ax ;
- L1: add di,cx ;forward ptr to position
- cld ;
- L2: lodsb ;get a char
- cmp al,0 ;end of string?
- je L3 ;quit if so
- stosb ;
- jmp short L2 ;loop
- L3: pop ds ;restore DS
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _over_write ENDP
- _TEXT ENDS
- END