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

 
Output of file : STRLWR.ASM contained in archive : VCCRT2.ZIP
page ,132
title strlwr - map string to lower-case
;***
;strlwr.asm - routine to map lower-case characters in a string to upper-case
;
; Copyright (c) 1985-1992, Microsoft Corporation. All Rights Reserved.
;
;Purpose:
; STRLWR converts upper-case characters in a null-terminated string
; to their lower-case equivalents. Conversion is done in place and
; characters other than upper-case letters are not modified.
;
; This function modifies only 7-bit ASCII characters
; in the range 0x41 through 0x5A ('A' through 'Z').
;
;*******************************************************************************

.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
;***
;char *_strlwr(string) - map upper-case characters in a string to lower-case
;
;Purpose:
; Converts all the upper case characters in a string to lower case,
; in place.
;
; Algorithm:
; char * _strlwr (char * string)
; {
; char * cp = string;
;
; while( *cp )
; {
; if ('A' <= *cp && *cp <= 'Z')
; *cp += 'a' - 'A';
; ++cp;
; }
; return(string);
; }
;
;Entry:
; char *string - string to change to lower case
;
;Exit:
; The input string address is returned in AX or DX:AX
;
;Uses:
; BX, CX, DX
;
;Exceptions:
;
;*******************************************************************************

ifdef MODELINDEP

cProc _fstrlwr,,<>

else

cProc _strlwr,,<>

endif

parmDP string

cBegin
if sizeD
mov cx,ds ; preserve DS
lds bx,string
else
mov bx,string
endif
mov dx,bx ; save return value
jmp short first_char; jump into loop

even
check_char:
sub al,'A' ; 'A' <= al <= 'Z' ?
cmp al,'Z'-'A'+1
jnb next_char
add al,'a' ; map to lower case
mov [bx],al ; and store new value
next_char:
inc bx ; bump string pointer
first_char:
mov al,[bx] ; get next character
or al,al
jnz check_char

done:
xchg ax,dx ; AX = return value ("string")

if sizeD
mov dx,ds ; DX:AX = return value ("string")
mov ds,cx ; restore DS
endif
pop bp
ret
cEnd

% sEnd CODE_SEG
end


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