2018-12-19 18:01:53 +00:00
|
|
|
#pragma zilog_syntax
|
|
|
|
|
|
|
|
byte strzlen(pointer str) {
|
|
|
|
pointer end
|
|
|
|
end = str
|
2019-08-15 22:46:11 +00:00
|
|
|
while end[0] != nullchar {
|
2018-12-19 18:01:53 +00:00
|
|
|
end += 1
|
|
|
|
}
|
|
|
|
return lo(end - str)
|
|
|
|
}
|
|
|
|
|
|
|
|
sbyte strzcmp(pointer str1, pointer str2) {
|
|
|
|
while true {
|
2019-08-15 22:46:11 +00:00
|
|
|
if str1[0] == nullchar {
|
|
|
|
if str2[0] == nullchar {
|
2018-12-19 18:01:53 +00:00
|
|
|
return 0
|
|
|
|
} else {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
} else if str1[0] != str2[0] {
|
|
|
|
if str1[0] < str2[0] { return -1 }
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
str1 += 1
|
|
|
|
str2 += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-24 23:16:15 +00:00
|
|
|
#if CPUFEATURE_Z80 || CPUFEATURE_8080
|
|
|
|
void strzcopy(pointer dest, pointer src) {
|
|
|
|
asm {
|
|
|
|
? LD HL,(src)
|
|
|
|
? LD DE,(dest)
|
|
|
|
___strzcopy_loop:
|
|
|
|
LD A,(HL)
|
|
|
|
LD (DE),A
|
2020-04-06 09:54:24 +00:00
|
|
|
INC HL
|
|
|
|
INC DE
|
2019-09-24 23:16:15 +00:00
|
|
|
? CP nullchar
|
|
|
|
? JP NZ, ___strzcopy_loop
|
|
|
|
}
|
|
|
|
}
|
2019-11-04 01:29:16 +00:00
|
|
|
void strzpaste(pointer dest, pointer src) {
|
|
|
|
asm {
|
|
|
|
? LD HL,(src)
|
|
|
|
? LD DE,(dest)
|
|
|
|
___strzpaste_loop:
|
|
|
|
LD A,(HL)
|
|
|
|
? CP nullchar
|
|
|
|
? RET Z
|
|
|
|
LD (DE),A
|
2020-04-06 09:54:24 +00:00
|
|
|
INC HL
|
|
|
|
INC DE
|
2019-11-04 01:29:16 +00:00
|
|
|
? JP ___strzpaste_loop
|
|
|
|
}
|
|
|
|
}
|
2019-09-24 23:16:15 +00:00
|
|
|
#else
|
2018-12-19 18:01:53 +00:00
|
|
|
void strzcopy(pointer dest, pointer src) {
|
|
|
|
byte c
|
|
|
|
do {
|
|
|
|
c = src[0]
|
|
|
|
dest[0] = c
|
|
|
|
src += 1
|
|
|
|
dest += 1
|
2019-08-15 22:46:11 +00:00
|
|
|
} while c != nullchar
|
2018-12-19 18:01:53 +00:00
|
|
|
}
|
2019-11-04 01:29:16 +00:00
|
|
|
void strzpaste(pointer dest, pointer src) {
|
|
|
|
byte c
|
|
|
|
while true {
|
|
|
|
c = src[0]
|
|
|
|
if c == nullchar { return }
|
|
|
|
dest[0] = c
|
|
|
|
src += 1
|
|
|
|
dest += 1
|
|
|
|
}
|
|
|
|
}
|
2019-09-24 23:16:15 +00:00
|
|
|
#endif
|