1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00

Improved ctype.s from Greg King

git-svn-id: svn://svn.cc65.org/cc65/trunk@2148 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-05-05 09:04:36 +00:00
parent cd4a9e3fb0
commit 7b4d3b9a9f

View File

@ -1,77 +1,65 @@
;
; Ullrich von Bassewitz, 02.06.1998
;
; Character specification table.
;
; Ullrich von Bassewitz, 02.06.1998
; 2003-05-02, Greg King
;
; The tables are readonly, put them into the rodata segment
.rodata
; The following 256 byte wide table specifies attributes for the isxxx type
; The following 256-byte-wide table specifies attributes for the isxxx type
; of functions. Doing it by a table means some overhead in space, but it
; has major advantages:
;
; * It is fast. If it were'nt for the slow parameter passing of cc65, one
; could even define macros for the isxxx functions (this is usually
; done on other platforms).
; * It is fast. If it weren't for the slow parameter-passing of cc65,
; one even could define C-language macroes for the isxxx functions
; (as it usually is done, on other platforms).
;
; * It is highly portable. The only unportable part is the table itself,
; * It is highly portable. The only unportable part is the table itself;
; all real code goes into the common library.
;
; * We save some code in the isxxx functions.
;
;
; Bit assignments:
;
; 0 - Lower case char
; 1 - Upper case char
; 2 - Numeric digit
; 3 - Hex digit (both, lower and upper)
; 4 - Control character
; 5 - The space character itself
; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v')
; 7 - Space or tab character
; This table is taken from Craig S. Bruce's technical docs. for the ACE OS.
; The table is taken from Craig S. Bruce technical docs for the ACE os
.include "ctype.inc"
.export __ctype
; The table is read-only, put it into the RODATA segment.
.rodata
__ctype:
.byte $10 ; 0/00 ___rvs_@___
.byte $10 ; 1/01 ___rvs_a___
.byte $10 ; 2/02 ___rvs_b___
.byte $10 ; 3/03 ___rvs_c___
.byte $10 ; 4/04 ___rvs_d___
.byte $10 ; 5/05 ___rvs_e___
.byte $10 ; 6/06 ___rvs_f___
.byte $10 ; 7/07 _BEL/rvs_g_
.byte $10 ; 8/08 ___rvs_h___
.byte $D0 ; 9/09 _TAB/rvs_i_
.byte $50 ; 10/0a _BOL/rvs_j_
.byte $10 ; 11/0b ___rvs_k___
.byte $10 ; 12/0c ___rvs_l___
.byte $50 ; 13/0d _CR_/rvs_m_
.byte $10 ; 14/0e ___rvs_n___
.byte $10 ; 15/0f ___rvs_o___
.byte $10 ; 16/10 ___rvs_p___
.byte $50 ; 17/11 _VT_/rvs_q_
.byte $10 ; 18/12 ___rvs_r___
.byte $10 ; 19/13 ___rvs_s___
.byte $50 ; 20/14 _BS_/rvs_t_
.byte $10 ; 21/15 ___rvs_u___
.byte $10 ; 22/16 ___rvs_v___
.byte $10 ; 23/17 ___rvs_w___
.byte $10 ; 24/18 ___rvs_x___
.byte $10 ; 25/19 ___rvs_y___
.byte $10 ; 26/1a ___rvs_z___
.byte $10 ; 27/1b ___rvs_[___
.byte $10 ; 28/1c ___rvs_\___
.byte $10 ; 29/1d ___rvs_]___
.byte $10 ; 30/1e ___rvs_^___
.byte $10 ; 31/1f _rvs_under_
.byte $A0 ; 32/20 ___SPACE___
.byte CT_CTRL ; 0/00 ___rvs_@___
.byte CT_CTRL ; 1/01 ___rvs_a___
.byte CT_CTRL ; 2/02 ___rvs_b___
.byte CT_CTRL ; 3/03 ___rvs_c___
.byte CT_CTRL ; 4/04 ___rvs_d___
.byte CT_CTRL ; 5/05 ___rvs_e___
.byte CT_CTRL ; 6/06 ___rvs_f___
.byte CT_CTRL ; 7/07 _BEL/rvs_g_
.byte CT_CTRL ; 8/08 ___rvs_h___
.byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB ; 9/09 _TAB/rvs_i_
.byte CT_CTRL | CT_OTHER_WS ; 10/0a _BOL/rvs_j_
.byte CT_CTRL ; 11/0b ___rvs_k___
.byte CT_CTRL ; 12/0c ___rvs_l___
.byte CT_CTRL | CT_OTHER_WS ; 13/0d _CR_/rvs_m_
.byte CT_CTRL ; 14/0e ___rvs_n___
.byte CT_CTRL ; 15/0f ___rvs_o___
.byte CT_CTRL ; 16/10 ___rvs_p___
.byte CT_CTRL | CT_OTHER_WS ; 17/11 _VT_/rvs_q_
.byte CT_CTRL ; 18/12 ___rvs_r___
.byte CT_CTRL | CT_OTHER_WS ; 19/13 HOME/rvs_s_
.byte CT_CTRL | CT_OTHER_WS ; 20/14 _BS_/rvs_t_
.byte CT_CTRL ; 21/15 ___rvs_u___
.byte CT_CTRL ; 22/16 ___rvs_v___
.byte CT_CTRL ; 23/17 ___rvs_w___
.byte CT_CTRL ; 24/18 ___rvs_x___
.byte CT_CTRL ; 25/19 ___rvs_y___
.byte CT_CTRL ; 26/1a ___rvs_z___
.byte CT_CTRL ; 27/1b ___rvs_[___
.byte CT_CTRL ; 28/1c ___rvs_\___
.byte CT_CTRL | CT_OTHER_WS ; 29/1d cursr-right
.byte CT_CTRL ; 30/1e ___rvs_^___
.byte CT_CTRL ; 31/1f _rvs_under_
.byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___
.byte $00 ; 33/21 _____!_____
.byte $00 ; 34/22 _____"_____
.byte $00 ; 35/23 _____#_____
@ -87,16 +75,16 @@ __ctype:
.byte $00 ; 45/2d _____-_____
.byte $00 ; 46/2e _____._____
.byte $00 ; 47/2f _____/_____
.byte $0C ; 48/30 _____0_____
.byte $0C ; 49/31 _____1_____
.byte $0C ; 50/32 _____2_____
.byte $0C ; 51/33 _____3_____
.byte $0C ; 52/34 _____4_____
.byte $0C ; 53/35 _____5_____
.byte $0C ; 54/36 _____6_____
.byte $0C ; 55/37 _____7_____
.byte $0C ; 56/38 _____8_____
.byte $0C ; 57/39 _____9_____
.byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____
.byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____
.byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____
.byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____
.byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____
.byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____
.byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____
.byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____
.byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____
.byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____
.byte $00 ; 58/3a _____:_____
.byte $00 ; 59/3b _____;_____
.byte $00 ; 60/3c _____<_____
@ -105,32 +93,32 @@ __ctype:
.byte $00 ; 63/3f _____?_____
.byte $00 ; 64/40 _____@_____
.byte $09 ; 65/41 _____a_____
.byte $09 ; 66/42 _____b_____
.byte $09 ; 67/43 _____c_____
.byte $09 ; 68/44 _____d_____
.byte $09 ; 69/45 _____e_____
.byte $09 ; 70/46 _____f_____
.byte $01 ; 71/47 _____g_____
.byte $01 ; 72/48 _____h_____
.byte $01 ; 73/49 _____i_____
.byte $01 ; 74/4a _____j_____
.byte $01 ; 75/4b _____k_____
.byte $01 ; 76/4c _____l_____
.byte $01 ; 77/4d _____m_____
.byte $01 ; 78/4e _____n_____
.byte $01 ; 79/4f _____o_____
.byte $01 ; 80/50 _____p_____
.byte $01 ; 81/51 _____q_____
.byte $01 ; 82/52 _____r_____
.byte $01 ; 83/53 _____s_____
.byte $01 ; 84/54 _____t_____
.byte $01 ; 85/55 _____u_____
.byte $01 ; 86/56 _____v_____
.byte $01 ; 87/57 _____w_____
.byte $01 ; 88/58 _____x_____
.byte $01 ; 89/59 _____y_____
.byte $01 ; 90/5a _____z_____
.byte CT_LOWER | CT_XDIGIT ; 65/41 _____a_____
.byte CT_LOWER | CT_XDIGIT ; 66/42 _____b_____
.byte CT_LOWER | CT_XDIGIT ; 67/43 _____c_____
.byte CT_LOWER | CT_XDIGIT ; 68/44 _____d_____
.byte CT_LOWER | CT_XDIGIT ; 69/45 _____e_____
.byte CT_LOWER | CT_XDIGIT ; 70/46 _____f_____
.byte CT_LOWER ; 71/47 _____g_____
.byte CT_LOWER ; 72/48 _____h_____
.byte CT_LOWER ; 73/49 _____i_____
.byte CT_LOWER ; 74/4a _____j_____
.byte CT_LOWER ; 75/4b _____k_____
.byte CT_LOWER ; 76/4c _____l_____
.byte CT_LOWER ; 77/4d _____m_____
.byte CT_LOWER ; 78/4e _____n_____
.byte CT_LOWER ; 79/4f _____o_____
.byte CT_LOWER ; 80/50 _____p_____
.byte CT_LOWER ; 81/51 _____q_____
.byte CT_LOWER ; 82/52 _____r_____
.byte CT_LOWER ; 83/53 _____s_____
.byte CT_LOWER ; 84/54 _____t_____
.byte CT_LOWER ; 85/55 _____u_____
.byte CT_LOWER ; 86/56 _____v_____
.byte CT_LOWER ; 87/57 _____w_____
.byte CT_LOWER ; 88/58 _____x_____
.byte CT_LOWER ; 89/59 _____y_____
.byte CT_LOWER ; 90/5a _____z_____
.byte $00 ; 91/5b _____[_____
.byte $00 ; 92/5c _____\_____
.byte $00 ; 93/5d _____]_____
@ -169,39 +157,39 @@ __ctype:
.byte $00 ; 126/7e _cap_thorn_
.byte $00 ; 127/7f _Es-sed_B__
.byte $00 ; 128/80 __bullet___
.byte $00 ; 129/81 __v_line___
.byte $00 ; 130/82 __h_line___
.byte $00 ; 131/83 ___cross___
.byte $00 ; 132/84 _tl_corner_
.byte $00 ; 133/85 _tr_corner_
.byte $00 ; 134/86 _bl_corner_
.byte $00 ; 135/87 _br_corner_
.byte $00 ; 136/88 ___l_tee___
.byte $00 ; 137/89 ___r_tee___
.byte $00 ; 138/8a ___t_tee___
.byte $00 ; 139/8b ___b_tee___
.byte $00 ; 140/8c ___heart___
.byte $00 ; 141/8d __diamond__
.byte $00 ; 142/8e ___club____
.byte $00 ; 143/8f ___spade___
.byte $00 ; 144/90 _s_circle__
.byte $00 ; 145/91 __circle___
.byte $00 ; 146/92 ___pound___
.byte $10 ; 147/93 _CLS/check_
.byte $00 ; 148/94 ____pi_____
.byte $00 ; 149/95 ____+/-____
.byte $00 ; 150/96 __divide___
.byte $00 ; 151/97 __degree___
.byte $00 ; 152/98 _c_checker_
.byte $00 ; 153/99 _f_checker_
.byte $00 ; 154/9a _solid_sq__
.byte $00 ; 155/9b __cr_char__
.byte $00 ; 156/9c _up_arrow__
.byte $00 ; 157/9d _down_arro_
.byte $00 ; 158/9e _left_arro_
.byte $00 ; 159/9f _right_arr_
.byte $00 ; 160/a0 _req space_
.byte CT_CTRL ; 128/80 __bullet___
.byte CT_CTRL ; 129/81 __v_line___
.byte CT_CTRL ; 130/82 __h_line___
.byte CT_CTRL ; 131/83 ___cross___
.byte CT_CTRL ; 132/84 _tl_corner_
.byte CT_CTRL ; 133/85 _tr_corner_
.byte CT_CTRL ; 134/86 _bl_corner_
.byte CT_CTRL ; 135/87 _br_corner_
.byte CT_CTRL ; 136/88 ___l_tee___
.byte CT_CTRL ; 137/89 ___r_tee___
.byte CT_CTRL ; 138/8a ___t_tee___
.byte CT_CTRL ; 139/8b ___b_tee___
.byte CT_CTRL ; 140/8c ___heart___
.byte CT_CTRL | CT_OTHER_WS ; 141/8d _CR/diamond
.byte CT_CTRL ; 142/8e ___club____
.byte CT_CTRL ; 143/8f ___spade___
.byte CT_CTRL ; 144/90 _s_circle__
.byte CT_CTRL | CT_OTHER_WS ; 145/91 _cursor-up_
.byte CT_CTRL ; 146/92 ___pound___
.byte CT_CTRL | CT_OTHER_WS ; 147/93 _CLS/check_
.byte CT_CTRL | CT_OTHER_WS ; 148/94 __INSert___
.byte CT_CTRL ; 149/95 ____+/-____
.byte CT_CTRL ; 150/96 __divide___
.byte CT_CTRL ; 151/97 __degree___
.byte CT_CTRL ; 152/98 _c_checker_
.byte CT_CTRL ; 153/99 _f_checker_
.byte CT_CTRL ; 154/9a _solid_sq__
.byte CT_CTRL ; 155/9b __cr_char__
.byte CT_CTRL ; 156/9c _up_arrow__
.byte CT_CTRL | CT_OTHER_WS ; 157/9d cursor-left
.byte CT_CTRL ; 158/9e _left_arro_
.byte CT_CTRL ; 159/9f _right_arr_
.byte CT_SPACE | CT_SPACE_TAB ; 160/a0 _req space_
.byte $00 ; 161/a1 _!_invertd_
.byte $00 ; 162/a2 ___cent____
.byte $00 ; 163/a3 ___pound___
@ -235,32 +223,32 @@ __ctype:
.byte $00 ; 191/bf _?_invertd_
.byte $00 ; 192/c0 _____`_____
.byte $0A ; 193/c1 _____A_____
.byte $0A ; 194/c2 _____B_____
.byte $0A ; 195/c3 _____C_____
.byte $0A ; 196/c4 _____D_____
.byte $0A ; 197/c5 _____E_____
.byte $0A ; 198/c6 _____F_____
.byte $02 ; 199/c7 _____G_____
.byte $02 ; 200/c8 _____H_____
.byte $02 ; 201/c9 _____I_____
.byte $02 ; 202/ca _____J_____
.byte $02 ; 203/cb _____K_____
.byte $02 ; 204/cc _____L_____
.byte $02 ; 205/cd _____M_____
.byte $02 ; 206/ce _____N_____
.byte $02 ; 207/cf _____O_____
.byte $02 ; 208/d0 _____P_____
.byte $02 ; 209/d1 _____Q_____
.byte $02 ; 210/d2 _____R_____
.byte $02 ; 211/d3 _____S_____
.byte $02 ; 212/d4 _____T_____
.byte $02 ; 213/d5 _____U_____
.byte $02 ; 214/d6 _____V_____
.byte $02 ; 215/d7 _____W_____
.byte $02 ; 216/d8 _____X_____
.byte $02 ; 217/d9 _____Y_____
.byte $02 ; 218/da _____Z_____
.byte CT_UPPER | CT_XDIGIT ; 193/c1 _____A_____
.byte CT_UPPER | CT_XDIGIT ; 194/c2 _____B_____
.byte CT_UPPER | CT_XDIGIT ; 195/c3 _____C_____
.byte CT_UPPER | CT_XDIGIT ; 196/c4 _____D_____
.byte CT_UPPER | CT_XDIGIT ; 197/c5 _____E_____
.byte CT_UPPER | CT_XDIGIT ; 198/c6 _____F_____
.byte CT_UPPER ; 199/c7 _____G_____
.byte CT_UPPER ; 200/c8 _____H_____
.byte CT_UPPER ; 201/c9 _____I_____
.byte CT_UPPER ; 202/ca _____J_____
.byte CT_UPPER ; 203/cb _____K_____
.byte CT_UPPER ; 204/cc _____L_____
.byte CT_UPPER ; 205/cd _____M_____
.byte CT_UPPER ; 206/ce _____N_____
.byte CT_UPPER ; 207/cf _____O_____
.byte CT_UPPER ; 208/d0 _____P_____
.byte CT_UPPER ; 209/d1 _____Q_____
.byte CT_UPPER ; 210/d2 _____R_____
.byte CT_UPPER ; 211/d3 _____S_____
.byte CT_UPPER ; 212/d4 _____T_____
.byte CT_UPPER ; 213/d5 _____U_____
.byte CT_UPPER ; 214/d6 _____V_____
.byte CT_UPPER ; 215/d7 _____W_____
.byte CT_UPPER ; 216/d8 _____X_____
.byte CT_UPPER ; 217/d9 _____Y_____
.byte CT_UPPER ; 218/da _____Z_____
.byte $00 ; 219/db _____{_____
.byte $00 ; 220/dc _____|_____
.byte $00 ; 221/dd _____}_____