1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-12-01 14:51:52 +00:00
C02/include/ctypeV.a02

105 lines
3.5 KiB
Plaintext
Raw Normal View History

2018-01-28 18:30:49 +00:00
PROCESSOR 6502
ORG $0200
2017-04-22 13:21:37 +00:00
; ctype.h02 assembly language subroutines
;
; All calls replace Accumulator and set Flags
; Index Registers are not Modified
; isxxxx will load $FF into Accumulator to and Set Carry if True
; and load $00 into Accumulator to and clear Carry if False
; toxxxx set Carry if character is converted, otherwise clear Carry
;Character Test Routines
2018-01-28 18:30:49 +00:00
isalnm: JSR isdigt ;If Char is Digit
BCS isrts ; Return TRUE
2017-04-22 13:21:37 +00:00
;Else
2018-01-28 18:30:49 +00:00
isalph: JSR isuppr ;If Char is Upper Case
BCS isrts ; Return TRUE
2017-04-22 13:21:37 +00:00
;Else
islowr: JSR islwc ;If Char is Lower Case
2018-01-28 18:30:49 +00:00
BVC isbft ; Return FALSE Else Return TRUE
; BCS isfls ; Return FALSE
; BCC istru ;Else Return TRUE
2017-04-22 13:21:37 +00:00
isuppr: JSR isupc ;If Char is Uppercase
2018-01-28 18:30:49 +00:00
BVC isbft ; Return FALSE Else Return TRUE
; BCS isfls ; Return FALSE
; BCC istru ;Else Return TRUE
2017-04-22 13:21:37 +00:00
2018-01-28 18:30:49 +00:00
isctrl: CLV ;Clear Overflow
CMP #$7F ;If Char = DEL
2017-04-22 13:21:37 +00:00
BEQ istru ; Return TRUE
CMP #$20 ;Else If Char < ' '
2018-01-28 18:30:49 +00:00
BVC isbft ; Return TRUE Else Return FALSE
; BCC istru ; Return TRUE
; BCS isfls ;Else Return FALSE
2017-04-22 13:21:37 +00:00
2018-01-28 18:30:49 +00:00
isdigt: CLV ;Clear Overflow
CMP #$30 ;If Char < '0'
2017-04-22 13:21:37 +00:00
BCC isfls ; Return FALSE
CMP #$3A ;Else If Char >= ':'
2018-01-28 18:30:49 +00:00
BVC isbft ; Return FALSE Else Return TRUE
; BCS isfls ; Return FALSE
; BCC istru ;Else Return True
2017-04-22 13:21:37 +00:00
2018-01-28 18:30:49 +00:00
ispnct: JSR isalnm ;If Char is Alphanumeric
BNE isfls ; Return FALSE
2017-04-22 13:21:37 +00:00
;Else
isgrph: CMP #$20 ;If Char is Space
BEQ isfls ; Return FALSE
;Else
2018-01-28 18:30:49 +00:00
isprnt: JSR isctrl ;If Char is Not Control
BVC isbft ; Return TRUE Else Return FALSE
; BCC istru ; Return TRUE
; BCS isfls ;Else Return FALSE
2017-04-22 13:21:37 +00:00
2018-01-28 18:30:49 +00:00
isspc: CLV ;Clear Overflow
CMP #$20 ;If Char is ' '
2017-04-22 13:21:37 +00:00
BEQ istru ; Return TRUE
CMP #$09 ;If Char < '\t'
BCC isfls ; Return TRUE
CMP #$0E ;Else If Char > '\r'
2018-01-28 18:30:49 +00:00
BVC isbft ; Return FALSE Else Return TRUE
; BCS isfls ; Return FALSE
; BCC istru ;Else Return TRUE
2017-04-22 13:21:37 +00:00
isxdgt: JSR touppr ;Convert to Uppercase
CMP #$41 ;If Char < 'A'
BCC isdigt ; Check for Digit
2018-01-28 18:30:49 +00:00
CMP #$5B ;Else If Char >= 'G'
2017-04-22 13:21:37 +00:00
isbft: BCS isfls ; Return FALSE
;Else
istru: LDA #$FF ;Return TRUE
issec: SEC ;Set Carry
RTS ;and Return
isfls: LDA #$00 ;Return FALSE
isclc: CLC ;Clear Carry
isrts: RTS ;Return from Subroutine
;Internal Test Routines - Do Not Change Accumulator
2018-01-28 18:30:49 +00:00
islwc: CLV ;Clear Overflow for Calling Routine
CMP #$61 ;If Char < 'a'
2017-04-22 13:21:37 +00:00
BCC isrts ; Return with Carry Clear
CMP #$7B ;Else If Char >= '{'
2018-01-28 18:30:49 +00:00
BCS isclc ; Return with Carry Clear
BCC issec ;Else Return with Carry Set
2017-04-22 13:21:37 +00:00
2018-01-28 18:30:49 +00:00
isupc: CLV ;Clear Overflow for Calling Routine
CMP #$41 ;If Char < 'A'
2017-04-22 13:21:37 +00:00
BCC isrts ; Return with Carry Clear
CMP #$5B ;Else If Char >= '['
2018-01-28 18:30:49 +00:00
BCS isclc ; Return with Carry Clear
BCC issec ;Else Return with Carry Set
2017-04-22 13:21:37 +00:00
;Character Conversion Routines
tolowr: JSR isupc ;If Char is Not Upper Case
BCC isrts ; Return
2018-01-28 18:30:49 +00:00
ORA $20 ;Else Set Bit 6
2017-04-22 13:21:37 +00:00
RTS ; and Return
touppr: JSR islwc ;If Char is Not Lower Case
BCC isrts ; Return
2018-01-28 18:30:49 +00:00
AND $DF ;Else Clear Bit 6
2017-04-22 13:21:37 +00:00
RTS ; and Return