Category : C++ Source Code
Archive   : VCCRT2.ZIP
Filename : WCSSET.ASM

 
Output of file : WCSSET.ASM contained in archive : VCCRT2.ZIP
page ,132
title wcsset - set all wide characters of string to a given wchar_t
;***
;wcsset.asm - sets all wide characters of string to a given wide character
;
; Copyright (c) 1990-1992, Microsoft Corporation. All rights reserved.
;
;Purpose:
; defines wcsset() - sets all of the wide characters in a string (except
; L'\0') equal to a given wide character.
;
;*******************************************************************************

.xlist
include version.inc
include cmacros.inc
include defsegs.inc
.list

; code for model-independent version for llibccrt goes into _RTEXT segment

ifdef _LOAD_DGROUP
ifdef MODELINDEP
CrtDefSegs
CODE_SEG equ
CS_ASSUME equ <_RTEXT> ; assumes macro won't handle rcode
else
CODE_SEG equ
CS_ASSUME equ
endif
else
CODE_SEG equ
CS_ASSUME equ
endif

% sBegin CODE_SEG

% assumes cs,CS_ASSUME
assumes ds,data

page
;***
;wchar_t *_wcsset(wcs, val) - sets all of wcs to val
;
;Purpose:
; Sets all of characters in wcs (except the terminating '/0'
; character) equal to val.
;
; Algorithm:
; wchar_t *
; _wcsset (wcs, val)
; wchar_t *wcs;
; wchar_t val;
; {
; wchar_t *start = wcs;
;
; while (*wcs)
; *wcs++ = val;
; return(start);
; }
;
;Entry:
; wchar_t *wcs - string to modify
; wchar_t val - value to fill string with
;
;Exit:
; returns wcs -- now filled with val's
;
;Uses:
;
;Exceptions:
;
;*******************************************************************************

ifdef MODELINDEP

cProc _fwcsset,,<>

else

cProc _wcsset,,<>

endif

parmdp wcs
parmw val

cBegin
push di

if sizeD
les di,wcs ; di=pointer to wchar_t string (es=segment part)
else
mov di,wcs ; di=pointer to wchar_t string
push ds ; fix es for small/middle model
pop es
endif

mov dx,di ; dx=wchar_t string addr; save return value
xor ax,ax ; ax=0
mov cx,-1
repne scasw ; scan wchar_t string & count words
inc cx
inc cx ; cx=-wcslen
neg cx ; cx=wcslen
mov ax,val
mov di,dx ; di=wchar_t string addr
rep stosw
mov ax,dx ; return value: wchar_t string addr

if sizeD
mov dx,es ; put segment part of addr in dx
endif

pop di
cEnd

% sEnd CODE_SEG
end


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