þ a‹R þ w Qþ m^9     þ hý	 oP    þ nSystem-wide    NAME OsPromSubs

    PUBLIC  CompareChars, Upper, KeyRoutine

CGROUP GROUP CODE

true EQU 0ffh
false EQU 0

; "PlmMod" should be the name of the Plm module.
; This will make sure all the references get fixed up
; properly.  Now you can reference these variables
; as if they were in this module.  If the DS register
; is already set up by the time these routines are
; entered, life is much simpler.
; Sample data declarations

PlmMod_DATA SEGMENT
     EXTRN var1:WORD, var2:BYTE

PlmMod_DATA ENDS


CODE SEGMENT PUBLIC 'CODE'
    ASSUME  CS:CGROUP




    EXTRN ShortKeyRoutine:NEAR


;  KeyRoutine
;  This helps turn a short routine into a long one

KeyRoutine PROC FAR

    CALL ShortKeyRoutine

    RET
KeyRoutine ENDP




;  Upper: PROCEDURE (char) BYTE CLEAN;
;    DCL char BYTE;
;
;    This will return the upper case value of a letter.

char EQU BYTE PTR [BP+6]

Upper PROC FAR
    PUSH BP
    MOV  BP, SP

    MOV  AL, char
    CMP  AL, 'a'
    JB   UpperExit
    CMP  AL, 'z'
    JA   UpperExit
    AND  AL, 0DFH

UpperExit:
    POP  BP
    RET  2
Upper ENDP

PURGE char

$EJECT

;  CompareChars: PROCEDURE (pString1, pString2, length) BOOLEAN CLEAN;
;    DCL lenCompare WORD;
;    DCL pString1   PTR;
;    DCL pString2   PTR;
;
;    This will return TRUE if two buffers are equal.  Case is ignored.
;
;    NOTE: This routine depends on the routine
;      Upper only changing register AL.

lenCompare EQU WORD  PTR [BP+8]
pString2   EQU DWORD PTR [BP+10]
pString1   EQU DWORD PTR [BP+14]

CompareChars PROC FAR
    PUSH DS
    PUSH BP
    MOV  BP, SP

    MOV  CX, lenCompare
    JCXZ CompareEqual

    LDS  SI, pString1
    LES  DI, pString2

CompareTopOfLoop:
    MOV  AL, DS:[SI]      ; get the Upper of the
    PUSH AX
    CALL Upper            ; byte at string1 (next)
    MOV  BL, AL           ; save this Upper value

    MOV  AL, ES:[DI]      ; get the Upper of the
    PUSH AX
    CALL Upper            ; byte at string2 (next)

    CMP  AL, BL           ; if the characters
    MOV  AL, false        ; do not match, then
    JNZ  CompareExit      ; RETURN (FALSE)

    INC  SI               ; point to next str1 char
    INC  DI               ; point to next str2 char
    LOOP CompareTopOfLoop ; keep checking

CompareEqual:
    MOV  AL, true         ; RETURN (TRUE);

CompareExit:
    POP  BP
    POP  DS
    RET  10
CompareChars ENDP

PURGE lenCompare, pString2, pString1

CODE ENDS

END
