2474
|
1 **********************************
|
|
2
|
|
3 * BASIC09 String Length: find length of a BASIC09 string
|
|
4 * which can be terminated by a $ff
|
|
5 * =or= allocated storage size
|
|
6
|
|
7 * ENTRY: X=start of string
|
|
8 * D=max allocated
|
|
9
|
|
10 * EXIT: D=actual length
|
|
11 * all other regs (except cc) preserved
|
|
12
|
|
13 nam Find Basic09 String Length
|
|
14 ttl Assembler Library Module
|
|
15
|
|
16
|
|
17 psect B09STRLEN,0,0,0,0,0
|
|
18
|
|
19 B09STRLEN:
|
|
20 pshs d,x,y
|
|
21 tfr d,y max. possible size to Y
|
|
22
|
|
23 loop
|
|
24 lda ,x+ get char from string
|
|
25 inca this effects a cmpa #$ff
|
|
26 beq exit reached terminator
|
|
27 leay -1,y if string max leng, no terminator
|
|
28 bne loop no yet, check more
|
|
29
|
|
30 exit
|
|
31 puls d get max possible size
|
|
32 pshs y unused size in memory
|
|
33 subd ,s++ find actual length
|
|
34 puls x,y,pc
|
|
35
|
|
36 endsect
|
|
37
|