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

 
Output of file : COPYPART.ASM contained in archive : CEXPRESS.ZIP
;void copy_part(strg,return_string,start,num_chars);
; char *strg,*return_string;
; unsigned short start,number_chars;

EXTRN _memory_model:byte
EXTRN _error_code:byte

_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _copy_part
_copy_part proc near
push bp ;
mov bp,sp ;set up stack frame
push di ;
push si ;
push ds ;
mov dl,1 ;error code
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 source strg
les di,dword ptr[bp+8] ;ES:DI pts to return strg
add bp,4 ;forward pointer
jmp short L1 ;
L0: mov si,[bp+4] ;NEAR case
mov di,[bp+6] ;
mov ax,ds ;ES = DS
mov es,ax ;
L1: mov cx,[bp+8] ;start position
mov byte ptr es:[di],0 ;return null string if error
inc cx ;count from 1
L2: cmp byte ptr [si],0 ;
je L5 ;quit if strlen < start
inc si ;forward pointer
loop L2 ;loop to start point
mov cx,[bp+10] ;get number chars to copy
or cx,cx ;zero?
jz L5 ;quit if zero
dec si ;pull back pointer
cld ;direction forward
L3: lodsb ;get a char from Strg
or al,al ;end of string?
jz L4 ;jump if so
stosb ;write it
loop L3 ;do next char
mov dl,0 ;code for no error
L4: mov byte ptr es:[di],0 ;place terminating null
L5: pop ds ;restore registers
mov _error_code,dl ;set error code
pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_copy_part ENDP
_TEXT ENDS
END


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