Blob Blame History Raw
From 002d1801ec72c1dc11e90cd7e821395e6df61a5b Mon Sep 17 00:00:00 2001
From: IrgendwerA8 <c.krueger.b@web.de>
Date: Sun, 5 Jan 2020 15:57:44 +0100
Subject: [PATCH 149/170] Changes resulting from code review.

---
 asminc/ctype.inc         |  2 ++
 asminc/ctypetable.inc    |  2 +-
 libsrc/common/atoi.s     | 13 ++++++-------
 libsrc/common/isascii.s  | 13 +++++--------
 libsrc/common/strlower.s |  5 ++---
 libsrc/common/strupper.s |  3 +--
 6 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/asminc/ctype.inc b/asminc/ctype.inc
index 401e772a..29976078 100644
--- a/asminc/ctype.inc
+++ b/asminc/ctype.inc
@@ -9,6 +9,8 @@
 ;
 ; Definitions for the character type tables
 ;
+; Ullrich von Bassewitz, 08.09.2001
+;
 
 ; Define bitmapped constants for the table entries
 
diff --git a/asminc/ctypetable.inc b/asminc/ctypetable.inc
index e0a8bdcd..7134d002 100644
--- a/asminc/ctypetable.inc
+++ b/asminc/ctypetable.inc
@@ -13,7 +13,7 @@
 .include	"ctype.inc"
 .export		__ctype
 
-; This data is a table of possible ctype combinations, possible during 
+; Table definition covering all possible ctype combinations
 
 .rodata
 __ctype:
diff --git a/libsrc/common/atoi.s b/libsrc/common/atoi.s
index 8427be62..b63fcb20 100644
--- a/libsrc/common/atoi.s
+++ b/libsrc/common/atoi.s
@@ -54,10 +54,11 @@ L3:     iny
 L5:     stx     tmp1            ; remember sign flag
 
 L6:     lda     (ptr1),y        ; get next char
-                                ; get character classification
-        jsr     ctype_preprocessor_no_check
-        and     #CT_DIGIT       ; digit?
-        beq     L8              ; done
+        sec                     ; check if char is in digit space
+        sbc     #'0'            ; so subtract lower limit
+        tax                     ; remember this numeric value
+        cmp     #10             ; and check if upper limit is not crossed
+        bcs     L8              ; done
 
 ; Multiply ptr2 (the converted value) by 10
 
@@ -91,9 +92,7 @@ L6:     lda     (ptr1),y        ; get next char
 
 ; Get the character back and add it
 
-        lda     (ptr1),y        ; fetch char again
-        sec
-        sbc     #'0'            ; make numeric value
+        txa                     ; restore numeric value back to accu
         clc
         adc     ptr2
         sta     ptr2
diff --git a/libsrc/common/isascii.s b/libsrc/common/isascii.s
index dccfabaa..c15cc586 100644
--- a/libsrc/common/isascii.s
+++ b/libsrc/common/isascii.s
@@ -13,15 +13,12 @@
         .export         _isascii
 
 _isascii:
-        cpx     #$00            ; Char range ok?
-        bne     @L1             ; Jump if no
-
-        tay
-        bmi     @L1
-
-        inx
+        asl		a				; high-bit to carry
+        txa 					; check range of input param
+        bne		@L1				; out-of bounds?
+        adc 	#$FF			; calculate return value based on carry
         rts
 
-@L1:    lda     #$00            ; Return false
+@L1:    lda     #$00            ; return false
         tax
         rts
diff --git a/libsrc/common/strlower.s b/libsrc/common/strlower.s
index 8c634b6e..d4e48138 100644
--- a/libsrc/common/strlower.s
+++ b/libsrc/common/strlower.s
@@ -28,9 +28,8 @@ loop:   lda     (ptr1),y        ; get character
         jsr     ctype_preprocessor_no_check        
         and     #CT_UPPER       ; upper case char?
         beq     L1              ; jump if no
-        lda     (ptr1),y        ; fetch character again
-        sec
-        sbc     #<('A'-'a')     ; make lower case char
+        lda     (ptr1),y        ; fetch character again      
+        adc     #<('a'-'A')     ; make lower case char (ctype_preprocessor_no_check ensures carry clear)
         sta     (ptr1),y        ; store back
 L1:     iny                     ; next char
         bne     loop
diff --git a/libsrc/common/strupper.s b/libsrc/common/strupper.s
index c07fb17c..dd6c1c25 100644
--- a/libsrc/common/strupper.s
+++ b/libsrc/common/strupper.s
@@ -28,8 +28,7 @@ loop:   lda     (ptr1),y        ; get character
         and     #CT_LOWER       ; lower case char?
         beq     L1              ; jump if no
         lda     (ptr1),y        ; fetch character again
-        clc
-        adc     #<('A'-'a')     ; make upper case char
+        adc     #<('A'-'a')     ; make upper case char (ctype_preprocessor_no_check ensures carry clear)
         sta     (ptr1),y        ; store back
 L1:     iny                     ; next char
         bne     loop
-- 
2.26.0