Category : C Source Code
Archive   : C-AIDS-8.ZIP
Filename : JZCHRPOS.ASM
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³jzchrpos ³
³Return the index of a character in a string or -1 if error ³
³ ³
³Synopsis: ³
³ *wstr = "hello there"; ³
³ index = jzchrpos(wstr,' '); ³
³ ³
³ ( returns 5 ) ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
_
;=============================================================================
; Data
;=============================================================================
DGROUP group _DATA
_DATA segment word public 'DATA'
assume ds:DGROUP
; Your Data goes here . . .
_DATA ends
;=============================================================================
; Code
;=============================================================================
assume cs:_text
_text segment public byte 'code'
PUBLIC _jzchrpos
_jzchrpos proc near
push bp ; save base of stack
mov bp,sp ; establish stack frame
push di ; save MS-C's Register vars
mov di,[bp].4 ; address of string
xor ax,ax ; search for zero byte
mov cx,0FFFFh ; 64k max string
repnz scasb ; find end of string
inc cx
neg cx
mov dx,cx ; save string length
mov di,[bp].4 ; get address of string again
mov ax,[bp].6 ; char to search for
xor bl,bl ; make a zero
repnz scasb ; scan for character
mov ax,0FFFFh ; return -1 if not found
jcxz Notfound
mov ax,dx ; get string length
dec ax ; convert to index
sub ax,cx ; subtract pos from length
notfound:
pop di ; Restore MS-C's Register vars
mov sp,bp ; restore stack pointer
pop bp ; and base of stack
ret ; return to caller
_jzchrpos endp
_text ends
end
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/