1 | ;
|
---|
2 | ; UTILS.ASM -- Utility functions
|
---|
3 | ;
|
---|
4 | ; Copyright (c) 1991-1996 by Eberhard Mattes
|
---|
5 | ;
|
---|
6 | ; This file is part of emx.
|
---|
7 | ;
|
---|
8 | ; emx is free software; you can redistribute it and/or modify it
|
---|
9 | ; under the terms of the GNU General Public License as published by
|
---|
10 | ; the Free Software Foundation; either version 2, or (at your option)
|
---|
11 | ; any later version.
|
---|
12 | ;
|
---|
13 | ; emx is distributed in the hope that it will be useful,
|
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ;
|
---|
18 | ; You should have received a copy of the GNU General Public License
|
---|
19 | ; along with emx; see the file COPYING. If not, write to
|
---|
20 | ; the Free Software Foundation, 59 Temple Place - Suite 330,
|
---|
21 | ; Boston, MA 02111-1307, USA.
|
---|
22 | ;
|
---|
23 | ; See emx.asm for a special exception.
|
---|
24 | ;
|
---|
25 |
|
---|
26 | INCLUDE EMX.INC
|
---|
27 |
|
---|
28 | PUBLIC NSTRCPY, UPPER
|
---|
29 |
|
---|
30 | SV_CODE SEGMENT
|
---|
31 |
|
---|
32 | ASSUME CS:SV_CODE, DS:NOTHING
|
---|
33 |
|
---|
34 | ;
|
---|
35 | ; Copy a null-terminated string
|
---|
36 | ;
|
---|
37 | ; In: DS:SI Pointer to source string
|
---|
38 | ; DS:DI Pointer to destination array
|
---|
39 | ;
|
---|
40 | ; Out: AX Points to terminating null byte of the destination string
|
---|
41 | ;
|
---|
42 | NSTRCPY PROC NEAR
|
---|
43 | PUSH SI
|
---|
44 | PUSH DI
|
---|
45 | TALIGN 4
|
---|
46 | NSC_LOOP: LODS BYTE PTR DS:[SI]
|
---|
47 | MOV [DI], AL
|
---|
48 | INC DI
|
---|
49 | TEST AL, AL
|
---|
50 | JNZ SHORT NSC_LOOP
|
---|
51 | LEA AX, [DI-1]
|
---|
52 | POP DI
|
---|
53 | POP SI
|
---|
54 | RET
|
---|
55 | NSTRCPY ENDP
|
---|
56 |
|
---|
57 | ;
|
---|
58 | ; Convert a letter (a..z) to upper case
|
---|
59 | ;
|
---|
60 | ; In: AL Character
|
---|
61 | ;
|
---|
62 | ; Out: AL Character
|
---|
63 | ;
|
---|
64 | TALIGN 4
|
---|
65 | UPPER PROC NEAR
|
---|
66 | CMP AL, "a"
|
---|
67 | JB SHORT UPPER_RET
|
---|
68 | CMP AL, "z"
|
---|
69 | JA SHORT UPPER_RET
|
---|
70 | SUB AL, "a" - "A"
|
---|
71 | UPPER_RET: RET
|
---|
72 | UPPER ENDP
|
---|
73 |
|
---|
74 | SV_CODE ENDS
|
---|
75 |
|
---|
76 | END
|
---|