z80: more bits
authorAlan Cox <alan@linux.intel.com>
Thu, 16 Nov 2017 23:01:38 +0000 (23:01 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 16 Nov 2017 23:01:38 +0000 (23:01 +0000)
24 files changed:
Applications/SmallC/Z80/lib/TODO
Applications/SmallC/Z80/lib/_bzero.s [new file with mode: 0644]
Applications/SmallC/Z80/lib/_isalnum.s
Applications/SmallC/Z80/lib/_isalpha.s
Applications/SmallC/Z80/lib/_isascii.s
Applications/SmallC/Z80/lib/_isblank.s
Applications/SmallC/Z80/lib/_iscntrl.s
Applications/SmallC/Z80/lib/_isdigit.s
Applications/SmallC/Z80/lib/_isgraph.s
Applications/SmallC/Z80/lib/_islower.s
Applications/SmallC/Z80/lib/_isprint.s
Applications/SmallC/Z80/lib/_isspace.s
Applications/SmallC/Z80/lib/_isupper.s
Applications/SmallC/Z80/lib/_isxdigit.s
Applications/SmallC/Z80/lib/_memset.s
Applications/SmallC/Z80/lib/_strcat.s
Applications/SmallC/Z80/lib/_strchr.s
Applications/SmallC/Z80/lib/_strcmp.s
Applications/SmallC/Z80/lib/_strcpy.s
Applications/SmallC/Z80/lib/_strcspn.s
Applications/SmallC/Z80/lib/_strlen.s
Applications/SmallC/Z80/lib/_strncat.s
Applications/SmallC/Z80/lib/_strrchr.s
Applications/SmallC/Z80/lib/_swab.s [new file with mode: 0644]

index 689c231..5b0d67b 100644 (file)
@@ -4,14 +4,10 @@ _strncmp
 _strncasecmp
 _strpbrk
 _strspn
-_strstr
 _strxfrm
-_memcpy
 _memccpy
 _memchr
 _memmove
-_memset
 _bcopy
 _bzero
-_bswap
 _ispunct
diff --git a/Applications/SmallC/Z80/lib/_bzero.s b/Applications/SmallC/Z80/lib/_bzero.s
new file mode 100644 (file)
index 0000000..9770c42
--- /dev/null
@@ -0,0 +1,27 @@
+               .code
+               .export _bzero
+
+_bzero:        pop af
+       pop hl
+       pop de
+       push de
+       push hl
+       push af
+       push bc
+       ld c,e
+       ld b,d
+       ld a,b
+       or c
+       jr z, _bzero_1
+       ld (hl),0
+       dec bc
+       ld a,b
+       or c
+       jr z,_bzero_1
+       ld e,l
+       ld d,h
+       inc de
+       ldir
+_bzero_1:
+       pop bc
+       ret
\ No newline at end of file
index ccc70ff..94c581d 100644 (file)
@@ -1,10 +1,10 @@
                .code
                .export _isalnum
 
-_isalnum:      pop bc
+_isalnum:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                cp '9'
                jr nc, isalnum1
index afe0dd8..cc78c8b 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isalpha
-_isalpha:      pop bc
+_isalpha:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                cp 'a'
                jr c, isalpha1
index 8f1142b..6b598c7 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isascii
-_isascii:      pop bc
+_isascii:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                cp 32
                jr c, ret0
index 134d956..5d6d740 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isblank
-_isblank:      pop bc
+_isblank:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                ; Space
                cp 32
index 00c93c5..f536347 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _iscntrl
-_iscntrl:      pop bc
+_iscntrl:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                ; Space
                cp 32
index 283418e..018efad 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isdigit
-_isdigit:      pop bc
+_isdigit:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                cp '0'
                jr c, ret0
index e1dedbd..18436a9 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isgraph
-_isgraph:      pop bc
+_isgraph:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                cp 33
                jr c, ret0
index 8ff8dc9..7e1af27 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _islower
-_islower:      pop bc
+_islower:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                ; Space
                cp 'a'
index c5a78f4..6d1b794 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isprint
-_isprint:      pop bc
+_isprint:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                cp 32
                jr c, ret0
index ac0c6ac..f95dd56 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isspace
-_isspace:      pop bc
+_isspace:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                ; Space
                cp 32
index 810e0b3..8622266 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isupper
-_isupper:      pop bc
+_isupper:      pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                ; Space
                cp 'A'
index aaaecdd..71df5de 100644 (file)
@@ -1,9 +1,9 @@
                .code
                .export _isxdigit
-_isxdigit:     pop bc
+_isxdigit:     pop de
                pop hl
                push hl
-               push bc
+               push de
                ld a,l
                ; Space
                cp '0'
index 4bc85d9..be5dec4 100644 (file)
@@ -2,6 +2,7 @@
                .export _memset
 
 _memset:       push ix
+               push bc
                ld ix,0
                add ix,sp
                ld h,(ix+4)
@@ -23,5 +24,6 @@ _memset:      push ix
                ldir
 _memset_none:  ld l,(ix+4)
                ld h,(ix+5)
+               pop bc
                pop ix
                ret
index d06e374..65a45a9 100644 (file)
@@ -1,12 +1,12 @@
                .code
                .export _strcat
 
-_strcat:       pop bc          ;ret
+_strcat:       pop af          ;ret
                pop de          ;dest
                pop hl          ;src
                push hl
                push de
-               push bc
+               push af
                push de         ; for return code
 _strcat_1:     ld a,(de)
                or a
index 91f7340..882acbe 100644 (file)
@@ -2,12 +2,12 @@
                .export _strchr
 
 _strchr:
-               pop de          ; char
+               pop af
                pop hl          ; ptr
-               pop bc
-               push bc
-               push hl
+               pop de          ; char
                push de
+               push hl
+               push af
 _strchr_1:     ld a,(hl)       ; "The terminting nul is considered part
                cp e            ;  of the string"
                ret z
index e067cfe..4630b05 100644 (file)
@@ -2,11 +2,12 @@
                .export _strcmp
 
 _strcmp:
-               pop bc
+               pop af
                pop de
                pop hl
                push hl
                push de
+               push af
 
 _strcmp_1:
                ld a,(de)
index 8317c6d..13a6dc6 100644 (file)
@@ -1,12 +1,12 @@
                .code
                .export _strcpy
 
-_strcpy:       pop bc          ;ret
+_strcpy:       pop af          ;ret
                pop de          ;dest
                pop hl          ;src
                push hl
                push de
-               push bc
+               push af
                push de         ; for return code
 _strcpy_1:     ld a,(hl)
                ld (de),a
index 17f73b6..b394a26 100644 (file)
@@ -2,12 +2,12 @@
                .export _strcspn
 
 _strcspn:
-               pop bc
+               pop af
                pop hl          ;       string
                pop de          ;       match
                push de
                push hl
-               push bc
+               push af
 
 _strcspn_1:
                ld a,(hl)
index a45546a..da0def0 100644 (file)
@@ -6,6 +6,7 @@ _strlen:
                pop de
                push de
                push hl
+               push bc
                xor a
                ld b,a
                ld c,a
@@ -14,4 +15,5 @@ _strlen:
                cpir
                dec hl
                sbc hl,de
+               pop bc
                ret
index 3377224..051216a 100644 (file)
@@ -3,6 +3,7 @@
 
 _strncat:
                push    ix
+               push    bc
                ld      ix,#0
                add     ix,sp
                ld      l,(ix+4)
@@ -32,6 +33,7 @@ _strncat_1:
                jr      _strncat_1
 _strncat_2:    ld      l,(ix+4)
                ld      h,(ix+5)
+               pop     bc
                pop     ix
                ret
                ; Copy \0 until limit
index c707aab..90b7771 100644 (file)
@@ -2,12 +2,14 @@
                .export _strrchr
 
 _strrchr:
-               pop de          ; char
+               pop af
                pop hl          ; ptr
-               pop bc
-               push bc
+               pop de          ; char
+               push de
                push hl
+               push af
                push de
+               push bc
                ld bc, 0
 _strrchr_1:    ld a,(hl)
                or a
@@ -19,6 +21,7 @@ _strrchr_1:   ld a,(hl)
 _strrchr_2:
                ld h,b
                ld l,c
+               pop bc
                ret
 _strrchr_3:
                ld b,h
diff --git a/Applications/SmallC/Z80/lib/_swab.s b/Applications/SmallC/Z80/lib/_swab.s
new file mode 100644 (file)
index 0000000..7e53a3c
--- /dev/null
@@ -0,0 +1,28 @@
+        .code
+        .export _swab
+                    
+_swab: pop bc
+        pop hl
+        pop de
+        push de
+        push hl
+        push bc
+        push bc
+_swab1
+        bit 7,d
+        ret nz
+        ld a,d
+        or e
+        ret z
+        ld a,(hl)
+        inc hl
+        ld c,(hl)
+        ld (hl),a
+        dec hl
+        ld (hl),c
+        inc hl
+        inc hl
+        dec de
+        dec de
+        jr _swab1
+  
\ No newline at end of file