⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dstr005.asm

📁 嵌入式RMON,RMON为Remote monitor的缩写,基于SNMP为网络提供主动监控及错误告警,智能交换路由必备协议
💻 ASM
字号:
;************************************************************************
;* MODULE INFORMATION*
;**********************
;*     FILE     NAME:       dstr005.asm
;*     SYSTEM   NAME:       devlib
;*     ORIGINAL AUTHOR(S):  Paul Lemmers
;*     VERSION  NUMBER:     
;*     CREATION DATE:       1990/8/14
;*
;* DESCRIPTION: Contains dev_strncpy
;*              
;************************************************************************
;* CHANGES INFORMATION **
;************************
;* REVISION:    $Revision:   1.1  $
;* WORKFILE:    $Workfile:   dstr005.asm  $
;* LOGINFO:     $Log:   D:/CPROG/MYDEV/DEVLIB/VCS/DSTR005.ASV  $
;*              
;*                 Rev 1.1   17 Dec 1990 14:35:52   PAUL
;*              Function headers added
;*              
;*                 Rev 1.0   14 Aug 1990 14:42:14   PAUL
;*              Initial revision.
;************************************************************************/
;
	INCLUDE	cdev.inc


_TEXT	SEGMENT
;************************************************************************
;* NAME:        dev_strncpy
;* SYNOPSIS:    char far *dev_strncpy(char far *dest, char far *src,
;*                                    unsigned count);
;* DESCRIPTION: See C-runtime strncpy
;* UNMODIFIED REGISTERS:
;*              ds bp si di
;* RETURNS:     See C-runtime strncpy
;* TIMING:
;*         For the copy part we have:
;*         this implementation (scasb ; movsw/b ) is  O( 10*N ),
;*         an implementation with a load, compare and store instructions
;*         is O( 17*N ). Where N is the string length.
;*         Padding with blanks can only be solved in one way.
;************************************************************************
	PUBLIC	_dev_strncpy
	dest  = 4
	src   = 8
	count = 0Ch
_dev_strncpy PROC NEAR
	push	bp
	mov	bp,sp
	push	ds
	push	di
	push	si

	les	di,[bp+src]	; get ptr to dest string
	mov	dx,es		; prepare part of return value
	mov	cx,0FFFFh	; max search len
	xor	ax,ax		; search for '\0'
	repne scasb
	not	cx		; cx := # nonzero+1
	mov	bx,[bp+count]
	sub	bx,cx		; calculate # of NUL's to pad
	ja	$L000
	mov	cx,[bp+count]	; whoops, get max count
	xor	bx,bx		; No padding
$L000:	lds	si,[bp+src]
	les	di,[bp+dest]
	shr	cx,1		; calculate # of words
	rep movsw
	jnc	$L001		; jump if no last byte
	movsb
$L001:	mov	cx,bx		; get pad count to cx
	shr	cx,1		; calculate # of words
	rep stosw		; ax=0 for padding
	jnc	$L002
	stosb			; last byte

$L002:	mov	ax,[bp+dest]	; get last part of return value
	pop	si
	pop	di
	pop	ds
	pop	bp
	ret
_dev_strncpy ENDP
_TEXT	ENDS

	END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -