--- /dev/null
+ .code
+ .export _isalnum
+
+_isalnum: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ cp '9'
+ jr nc, isalnum1
+ cp '0'
+ jr c, ret0
+ret1: ld hl,1
+ ret
+isalnum1:
+ cp 'a'
+ jr c, isalnum2
+ sub 32
+isalnum2:
+ cp 'A'
+ jr c, ret0
+ cp 'Z'+1
+ jr c, ret1
+ret0: ld hl,0
+ ret
--- /dev/null
+ .code
+ .export _isalpha
+_isalpha: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ cp 'a'
+ jr c, isalpha1
+ sub 32
+isalpha1:
+ cp 'A'
+ jr c, ret0
+ cp 'Z'+1
+ jr c, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _isascii
+_isascii: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ cp 32
+ jr c, ret0
+ rlca
+ jr c, ret0
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
+ret0: ld hl,0
+ ret
--- /dev/null
+ .code
+ .export _isblank
+_isblank: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ ; Space
+ cp 32
+ jr z, ret1
+ cp 9
+ jr z, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _iscntrl
+_iscntrl: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ ; Space
+ cp 32
+ jr c, ret1
+ cp 127
+ jr z, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _isdigit
+_isdigit: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ cp '0'
+ jr c, ret0
+ cp '9'+1
+ jr c, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _isgraph
+_isgraph: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ cp 33
+ jr c, ret0
+ cp 127
+ jr nc, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _islower
+_islower: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ ; Space
+ cp 'a'
+ jr c, ret0
+ cp 'z'+1
+ jr c, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _isprint
+_isprint: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ cp 32
+ jr c, ret0
+ cp 128
+ jr c, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ispunct.s
\ No newline at end of file
--- /dev/null
+ .code
+ .export _isspace
+_isspace: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ ; Space
+ cp 32
+ jr z, ret1
+ ; 9-13
+ cp 9
+ jr c, ret0
+ cp 13
+ jr nc, ret0
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
+ret0: ld hl,0
+ ret
--- /dev/null
+ .code
+ .export _isupper
+_isupper: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ ; Space
+ cp 'A'
+ jr c, ret0
+ cp 'Z'+1
+ jr c, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .global _isxdigit
+_isxdigit: pop bc
+ pop hl
+ push hl
+ push bc
+ ld a,l
+ ; Space
+ cp '0'
+ jr c, ret0
+ cp 'A'
+ jr nc,ascii1
+ cp 'a'
+ jr nc,ascii2
+ cp '9'+1
+ jr nc, ret0
+ jr ret1
+ascii1: add 32
+ascii2:
+ cp 'a'
+ jr c, ret0
+ cp 'z'+1
+ jr c, ret1
+ret0: ld hl,0
+ ret
+ ; No need to handle -1 specially
+ret1: ld hl,1
+ ret
--- /dev/null
+ .code
+ .export _memcpy
+
+_memcpy: push ix
+ ld ix,#0
+ add ix,sp
+ ld e,4(ix)
+ ld d,5(ix)
+ ld l,6(ix)
+ ld h,7(ix)
+ ld c,8(ix)
+ ld b,9(ix)
+ ld a,b
+ or c
+ jr z, _memcpy_none
+ ldir
+_memcpy_none: ld l,4(ix)
+ ld h,5(ix)
+ ret
--- /dev/null
+ .code
+ .export _memset
+
+_memset: push ix
+ ld ix,0
+ add ix,sp
+ ld h,4(ix)
+ ld l,5(ix)
+ ld e,6(ix)
+ ld c,8(ix)
+ ld b,9(ix)
+ ld a,b
+ or c
+ jr z, _memset_none
+ ld (hl),e
+ dec bc
+ ld a,b
+ or c
+ jr z,_memset_none
+ ld e,l
+ ld d,h
+ inc de
+ ldir
+_memset_none: ld l,4(ix)
+ ld h,5(ix)
+ ret
--- /dev/null
+ .code
+ .export _strcat
+
+_strcat: pop bc ;ret
+ pop de ;dest
+ pop hl ;src
+ push hl
+ push de
+ push bc
+ push de ; for return code
+_strcat_1: ld a,(de)
+ or a
+ jr z,_strcat_2
+ inc de
+ jr _strcat_1
+_strcat_2:
+ ld a,(hl)
+ ld (de),a
+ or a
+ jr z _strcat_3
+ inc hl
+ inc de
+ jr _strcat_2
+strcat_3: pop de
+ ret
--- /dev/null
+ .code
+ .export _strchr
+
+_strchr:
+ pop de ; char
+ pop hl ; ptr
+ pop bc
+ push bc
+ push hl
+ push de
+_strchr_1: ld a,(hl) ; "The terminting nul is considered part
+ cp e ; of the string"
+ ret z
+ or a
+ inc hl
+ jr nz,_strchr_1
+ ld hl,0
+ ret
+
+
\ No newline at end of file
--- /dev/null
+ .code
+ .export _strcmp
+
+_strcmp:
+ pop bc
+ pop de
+ pop hl
+ push hl
+ push de
+
+_strcmp_1:
+ ld a,(de)
+ cp (hl)
+ jr nz, strcmp_2
+ or a
+ jr z, strcmp_4
+ inc hl
+ inc de
+ jr _strcmp_1
+_strcmp_2: jr c,_strcmp_3
+ ld hl,1
+ ret
+_strcmp_3:
+ ld hl,0xFFFF
+ ret
+_strcmp_4:
+ ld hl,0
+ ret
--- /dev/null
+ .code
+ .export _strcpy
+
+_strcpy: pop bc ;ret
+ pop de ;dest
+ pop hl ;src
+ push hl
+ push de
+ push bc
+ push de ; for return code
+_strcpy_1: ld a,(hl)
+ ld (de),a
+ or a
+ jr z _strcpy_2
+ inc hl
+ inc de
+ jr _strcpy_1
+_strcpy_2:
+ pop hl
+ ret
--- /dev/null
+ .code
+ .export _strcspn
+
+_strcspn:
+ pop bc
+ pop hl ; string
+ pop de ; match
+ push de
+ push hl
+ push bc
+
+_strcspn_1:
+ ld a,(hl)
+ or a
+ jr z,_strcspn_4
+ ld c,a
+
+ push de
+_strcspn_2:
+ ld a,(de)
+ or a
+ jr z, _strcspn_3
+ cp c
+ ret z ; Matched HL ponts to right spot
+ inc de
+ jr _strcspn_2
+_strcpsn_3: pop de
+ inc hl
+ jr _strcspn_1
+_strcspn_4: ld h,a ; A always 0 here
+ ld l,a
+ ret
--- /dev/null
+ .code
+ .export _strlen
+
+_strlen:
+ pop hl
+ pop de
+ push de
+ push hl
+ xor a
+ ld b,a
+ ld c,a
+ ld e,l
+ ld d,h
+ cpir
+ dec hl
+ sbc hl,de
+ ret
--- /dev/null
+ .code
+ .export _strncat
+
+_strncat:
+ push ix
+ ld ix,#0
+ add ix,sp
+ ld l,4(ix)
+ ld h,5(ix)
+ xor a
+ ld b,a
+ ld c,a
+ ; Move past end of original string
+ cpir
+ dec hl
+ ld e,6(ix)
+ ld d,7(ix)
+ ld c,8(ix)
+ ld b,9(ix)
+ ; Copy bytes until limit or \0
+_strncat_1:
+ ld a,b
+ or c
+ jr z, _strncat_2
+ ld a,(de)
+ ld (hl),a
+ or a
+ jr z, _strncat_3
+ inc de
+ inc hl
+ dec bc
+ jr _strncat_1
+_strncat_2: ld l,4(ix)
+ ld h,5(ix)
+ pop ix
+ ret
+ ; Copy \0 until limit
+_strncat_3: inc hl
+ dec bc
+ ld a,b
+ or c
+ jr z,_strncat_2
+ ld (hl),0
+ jr _strncat_3
--- /dev/null
+ .code
+ .export _strncpy
+
+_strncpy:
+ push ix
+ ld ix,#0
+ add ix,sp
+ ld l,4(ix)
+ ld h,5(ix)
+ ld e,6(ix)
+ ld d,7(ix)
+ ld c,8(ix)
+ ld b,9(ix)
+ ; Copy bytes until limit or \0
+_strncpy_1:
+ ld a,b
+ or c
+ jr z, _strncpy_2
+ ld a,(de)
+ ld (hl),a
+ or a
+ jr z, _strncpy_3
+ inc de
+ inc hl
+ dec bc
+ jr _strncpy_1
+_strncpy_2: ld l,4(ix)
+ ld h,5(ix)
+ pop ix
+ ret
+ ; Copy \0 until limit
+_strncpy_3: inc hl
+ dec bc
+ ld a,b
+ or c
+ jr z,_strncpy_2
+ ld (hl),0
+ jr _strncpy_3
--- /dev/null
+ .code
+ .export _strrchr
+
+_strrchr:
+ pop de ; char
+ pop hl ; ptr
+ pop bc
+ push bc
+ push hl
+ push de
+ ld bc, 0
+_strrchr_1: ld a,(hl)
+ or a
+ jr z, _strrchr_2
+ cp e
+ jr z, _strrchr_3
+ inc hl
+ jr _strrchr_1
+_strrchr_2:
+ ld h,b
+ ld l,c
+ ret
+_strrchr_3:
+ ld b,h
+ ld c,l
+ jr _strrchr_1
+
\ No newline at end of file
--- /dev/null
+ .code
+ .export _strcspn
+
+_strcspn:
+ pop bc
+ pop hl ; string
+ pop de ; match
+ push de
+ push hl
+ push bc
+
+_strcspn_1:
+ ld a,(hl)
+ or a
+ jr z,_strcspn_4
+ ld c,a
+
+ push de
+_strcspn_2:
+ ld a,(de)
+ or a
+ jr z, _strcspn_3
+ cp c
+ ret z ; Matched HL ponts to right spot
+ inc de
+ jr _strcspn_2
+_strcpsn_3: pop de
+ inc hl
+ jr _strcspn_1
+_strcspn_4: ld h,a ; A always 0 here
+ ld l,a
+ ret