mirror of
https://github.com/irmen/prog8.git
synced 2025-02-08 16:30:28 +00:00
add string.isspace and string.isprint
This commit is contained in:
parent
08a079a96e
commit
796add0ee2
@ -384,7 +384,7 @@ fail clc ; yes, no match found, return with c=0
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub isdigit(ubyte character @A) -> bool @Pc {
|
asmsub isdigit(ubyte petsciichar @A) -> bool @Pc {
|
||||||
%asm {{
|
%asm {{
|
||||||
cmp #'0'
|
cmp #'0'
|
||||||
bcs +
|
bcs +
|
||||||
@ -398,7 +398,7 @@ fail clc ; yes, no match found, return with c=0
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub isupper(ubyte character @A) -> bool @Pc {
|
asmsub isupper(ubyte petsciichar @A) -> bool @Pc {
|
||||||
; shifted petscii has 2 ranges that contain the upper case letters...
|
; shifted petscii has 2 ranges that contain the upper case letters...
|
||||||
%asm {{
|
%asm {{
|
||||||
cmp #97
|
cmp #97
|
||||||
@ -418,7 +418,7 @@ _yes sec
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub islower(ubyte character @A) -> bool @Pc {
|
asmsub islower(ubyte petsciichar @A) -> bool @Pc {
|
||||||
%asm {{
|
%asm {{
|
||||||
cmp #'a'
|
cmp #'a'
|
||||||
bcs +
|
bcs +
|
||||||
@ -432,7 +432,7 @@ _yes sec
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub isletter(ubyte character @A) -> bool @Pc {
|
asmsub isletter(ubyte petsciichar @A) -> bool @Pc {
|
||||||
%asm {{
|
%asm {{
|
||||||
jsr islower
|
jsr islower
|
||||||
bcs +
|
bcs +
|
||||||
@ -440,4 +440,42 @@ _yes sec
|
|||||||
+ rts
|
+ rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub isspace(ubyte petsciichar @A) -> bool @Pc {
|
||||||
|
%asm {{
|
||||||
|
cmp #32
|
||||||
|
beq +
|
||||||
|
cmp #13
|
||||||
|
beq +
|
||||||
|
cmp #9
|
||||||
|
beq +
|
||||||
|
cmp #10
|
||||||
|
beq +
|
||||||
|
cmp #141
|
||||||
|
beq +
|
||||||
|
cmp #160
|
||||||
|
beq +
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
+ sec
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub isprint(ubyte petsciichar @A) -> bool @Pc {
|
||||||
|
%asm {{
|
||||||
|
cmp #160
|
||||||
|
bcc +
|
||||||
|
rts
|
||||||
|
+ cmp #32
|
||||||
|
bcs +
|
||||||
|
rts
|
||||||
|
+ cmp #128
|
||||||
|
bcc +
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
+ sec
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,4 +190,12 @@ string {
|
|||||||
sub isletter(ubyte character) -> bool {
|
sub isletter(ubyte character) -> bool {
|
||||||
return islower(character) or isupper(character)
|
return islower(character) or isupper(character)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
sub isspace(ubyte character) -> bool {
|
||||||
|
return character in [32, 13, 9, 10, 141, 160]
|
||||||
|
}
|
||||||
|
|
||||||
|
sub isprint(ubyte character) -> bool {
|
||||||
|
return character>=32 and character<=127 or character>=160
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -275,7 +275,13 @@ Provides string manipulation routines.
|
|||||||
Returns boolean if the character is a numerical digit 0-9
|
Returns boolean if the character is a numerical digit 0-9
|
||||||
|
|
||||||
``islower (char)``, ``isupper (char)``, ``isletter (char)``
|
``islower (char)``, ``isupper (char)``, ``isletter (char)``
|
||||||
Returns boolean if the character is a shifted-PETSCII lowercase letter, uppercase letter, or any letter.
|
Returns true if the character is a shifted-PETSCII lowercase letter, uppercase letter, or any letter, respectively.
|
||||||
|
|
||||||
|
``isspace (char)``
|
||||||
|
Returns true if the PETSCII character is a whitespace (tab, space, return, and shifted versions)
|
||||||
|
|
||||||
|
``isprint (char)``
|
||||||
|
Returns true if the PETSCII character is a "printable" character (space or any visible symbol)
|
||||||
|
|
||||||
``startswith (string, prefix) -> bool``
|
``startswith (string, prefix) -> bool``
|
||||||
Returns true if string starts with prefix, otherwise false
|
Returns true if string starts with prefix, otherwise false
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
- optimize if-else expressions whose condition returns the boolean status in a status register to use a branch opcode instead of a comparison against 0
|
||||||
|
- fix "can't use Z or N flags as return 'values'" in 6502 codegen?
|
||||||
|
|
||||||
|
- merge branch optimize-st for some optimizations regardign SymbolTable use
|
||||||
|
|
||||||
- [on branch: call-pointers] allow calling a subroutine via a pointer variable (indirect JSR, optimized form of callfar())
|
- [on branch: call-pointers] allow calling a subroutine via a pointer variable (indirect JSR, optimized form of callfar())
|
||||||
modify programs (shell, paint) that now use callfar
|
modify programs (shell, paint) that now use callfar
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user