summaryrefslogtreecommitdiff
path: root/programs/sub-suite/libc.s
diff options
context:
space:
mode:
Diffstat (limited to 'programs/sub-suite/libc.s')
-rw-r--r--programs/sub-suite/libc.s77
1 files changed, 30 insertions, 47 deletions
diff --git a/programs/sub-suite/libc.s b/programs/sub-suite/libc.s
index 74ad654..3dc9d63 100644
--- a/programs/sub-suite/libc.s
+++ b/programs/sub-suite/libc.s
@@ -126,53 +126,49 @@ isdigit:
sbc #'0' ; Subtract $30 from the passed character.
and #$FF ; Make sure that we have only one byte.
cmp #10 ; Is the subtracted value, less than 10?
- bcs @false ; No, so return false.
-@true:
- lda #1 ; Yes, so return true.
- bra @end ; We are done.
-@false:
- lda #0 ; Return false.
-@end:
+ lcc #1 ; Yes, so return true.
+ lcs #0 ; No, so return false.
+; bcs @false ; No, so return false.
+;@true:
+; lda #1 ; Yes, so return true.
+; bra @end ; We are done.
+;@false:
+; lda #0 ; Return false.
+;@end:
rts ; End of isdigit.
isxdigit:
pha ; Preserve the character.
jsr isdigit ; Is this character, a decimal digit?
pla ; Get the character back.
- bne @true ; Yes, so return true.
+ bne @end ; Yes, so return true.
@alpha:
- sec ; No, so prepare for a non carrying subtract.
- ora #$20 ; Convert it to lowercase.
- sbc #'a' ; Subtract $61 from the character.
+ ora #$20 ; No, so convert it to lowercase.
+ sub #'a' ; Subtract $61 from the character.
and #$FF ; Make sure that we have only one byte.
cmp #6 ; Is the subtracted value, less than 6?
- bcs @false ; No, so return false.
-@true:
- lda #1 ; Yes, so return true.
- bra @end ; We are done.
-@false:
- lda #0 ; Return false.
+ lcc #1 ; Yes, so return true.
+ lcs #0 ; No, so return false.
+; bcs @false ; No, so return false.
+;@true:
+; lda #1 ; Yes, so return true.
+; bra @end ; We are done.
+;@false:
+; lda #0 ; Return false.
@end:
rts ; End of isxdigit.
isupper:
- sec ; Prepare for a non carrying subtraction.
- sbc #'A' ; Subtract $41 from the passed character.
+ sub #'A' ; Subtract $41 from the passed character.
bra isletter ; Check if it's less than 26.
islower:
- sec ; Prepare for a non carrying subtraction.
- sbc #'a' ; Subtract $61 from the passed character.
+ sub #'a' ; Subtract $61 from the passed character.
isletter:
and #$FF ; Make sure that we have only one byte.
cmp #26 ; Is the subtracted value, less than 26?
- bcs @false ; No, so return false.
-@true:
- lda #1 ; Yes, so return true.
- bra @end ; We are done.
-@false:
- lda #0 ; Return false.
-@end:
+ lcc #1 ; Yes, so return true.
+ lcs #0 ; No, so return false
rts ; End of isletter.
@@ -209,8 +205,7 @@ malloc:
pha.q ; Preserve the size.
and #0 ; Reset A.
tay ; Reset Y.
- pha.q ; Create two more local variables.
- pha.q ;
+ sbs #$10 ; Allocate 2 local variables onto the stack.
lda.q sp+17 ; Get the size.
ora.d sp+21 ; Is the size zero?
beq @end ; Yes, so we're done.
@@ -300,9 +295,7 @@ malloc:
clc ; Prepare for a non carrying add.
adc #ublk ; Return the pointer to the real memory block.
@end:
- ply.q ; Clean up the stack frame.
- ply.q ;
- ply.q ;
+ ads #$18 ; Clean up the stack frame.
ply.q ; Restore Y.
rts ; End of malloc.
@@ -320,9 +313,7 @@ free:
pha.q ; Push the pointer argument to the stack.
and #0 ; Reset A.
tay ; Reset Y.
- pha.q ; Add 3 more local variables.
- pha.q ;
- pha.q ;
+ sbs #$18 ; Allocate 3 local variables onto the stack.
lda.q sp+25 ; Get the passed pointer.
ora.d sp+29 ; Is the passed pointer NULL?
bne @getrealblk ; No, so get the real block.
@@ -373,10 +364,7 @@ free:
ldy #fblk.next ; Delete the next block.
sta.q (sp+25), y;
@end:
- pla.q ; Clean up the stack frame.
- pla.q ;
- pla.q ;
- pla.q ;
+ ads #$20 ; Clean up the stack frame.
ply.q ; Restore Y.
plb.q ; Restore B.
pla.q ; Restore A.
@@ -500,10 +488,7 @@ free:
ldy #fblk.prev ; Set the previous block, to the left pointer.
sta.q (sp+25), y;
@end2:
- pla.q ; Clean up the stack frame.
- pla.q ;
- pla.q ;
- pla.q ;
+ ads #$20 ; Clean up the stack frame.
ply.q ; Restore Y.
plb.q ; Restore B.
pla.q ; Restore A.
@@ -534,8 +519,6 @@ memcpy:
beq @end ; The size is zero, so we're done.
bra @loop ; Keep looping.
@end:
- pla.q ; Clean up the stack frame.
- pla.q ;
- pla.q ;
+ ads #$18 ; Clean up the stack frame.
pla.q ; Restore the return value.
rts ; End of memcpy.