Register | Login
Forum Index > RTL > CharClass
Author Message
Pages: 1 2 3 4
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1447] CharClass - posted: 2015-01-13 16:02:49
I think would be useful add routines for character classification, i.e. isdigit, isletter, isupper, islower, ... etc.
I have implemented this routines in NASM. And now i want rewrite them in ZIRON. But I'm having some problems:

Code:
const CHAR_UPPER      =  1 << 2

Unexpected symbol <


Code:
CHAR_LETTER | CHAR_LOWER

Unexpected symbol "|"


Code:
CHAR_LETTER or CHAR_LOWER

Not enough parameters!


Code:
al = CHAR_TABLE[gp_ax];

Unexpected register gp_ax


Code:
movzx gp_ax, $simbol;

Instruction usage is not supported!


In my test i use
Code:
eax = IsDigit(mychar);

Error occurs:
Unexpected symbol ;


Also, seems like my CHAR_TABLE not included in result executable.
This routines use gp_ax for addressing. In 16 bit mode it will not work, need use bx, bp, si, di instead.

Routines returns 1(true) if success else 0(false).

At first NASM version: Code:
;                                                 ;
;        Character classification routines        ;
;      Copyright (c) 0CodErr, KolibriOS team      ;
;                                                 ;
DIGIT      equ 1 << 0
LETTER     equ 1 << 1
UPPER      equ 1 << 2
LOWER      equ 1 << 3
CONTROL    equ 1 << 4
WHITESPACE equ 1 << 5
PUNCT      equ 1 << 6
; ----------------------------------------------- ;
%macro isdigit 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, DIGIT
;        shr    al, 0 ; no shift because 0'th bit
%endmacro
; ----------------------------------------------- ;
%macro isletter 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, LETTER
        shr    al, 1
%endmacro
; ----------------------------------------------- ;
%macro isupper 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, UPPER
        shr    al, 2
%endmacro
; ----------------------------------------------- ;
%macro islower 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, LOWER
        shr    al, 3
%endmacro
; ----------------------------------------------- ;
%macro iscontrol 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, CONTROL
        shr    al, 4
%endmacro
; ----------------------------------------------- ;
%macro iswhitespace 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, WHITESPACE
        shr    al, 5
%endmacro
; ----------------------------------------------- ;
%macro ispunct 1
        movzx  eax, %1
        mov    al, [eax + charclass_table]
        and    al, PUNCT
        shr    al, 6
%endmacro
; ----------------------------------------------- ;
charclass_table:
; 0..15
db CONTROL              ; 00 (NUL)
db CONTROL              ; 01 (SOH)
db CONTROL              ; 02 (STX)
db CONTROL              ; 03 (ETX)
db CONTROL              ; 04 (EOT)
db CONTROL              ; 05 (ENQ)
db CONTROL              ; 06 (ACK)
db CONTROL              ; 07 (BEL)
db CONTROL              ; 08 (BS)
db CONTROL | WHITESPACE ; 09 (HT)
db CONTROL | WHITESPACE ; 0A (LF)
db CONTROL | WHITESPACE ; 0B (VT)
db CONTROL | WHITESPACE ; 0C (FF)
db CONTROL | WHITESPACE ; 0D (CR)
db CONTROL              ; 0E (SI)
db CONTROL              ; 0F (SO)
; 16..31                
db CONTROL              ; 10 (DLE)
db CONTROL              ; 11 (DC1)
db CONTROL              ; 12 (DC2)
db CONTROL              ; 13 (DC3)
db CONTROL              ; 14 (DC4)
db CONTROL              ; 15 (NAK)
db CONTROL              ; 16 (SYN)
db CONTROL              ; 17 (ETB)
db CONTROL              ; 18 (CAN)
db CONTROL              ; 19 (EM)
db CONTROL              ; 1A (SUB)
db CONTROL              ; 1B (ESC)
db CONTROL              ; 1C (FS)
db CONTROL              ; 1D (GS)
db CONTROL              ; 1E (RS)
db CONTROL              ; 1F (US)
; 32..47                
db WHITESPACE           ; 20 SPACE
db PUNCT                ; 21 !
db PUNCT                ; 22 "
db PUNCT                ; 23 #
db PUNCT                ; 24 $
db PUNCT                ; 25 %
db PUNCT                ; 26 &
db PUNCT                ; 27 '
db PUNCT                ; 28 (
db PUNCT                ; 29 )
db PUNCT                ; 2A *
db PUNCT                ; 2B +
db PUNCT                ; 2C ,
db PUNCT                ; 2D -
db PUNCT                ; 2E .
db PUNCT                ; 2F /
; 48..63                
db DIGIT                ; 30 0
db DIGIT                ; 31 1
db DIGIT                ; 32 2
db DIGIT                ; 33 3
db DIGIT                ; 34 4
db DIGIT                ; 35 5
db DIGIT                ; 36 6
db DIGIT                ; 37 7
db DIGIT                ; 38 8
db DIGIT                ; 39 9
db PUNCT                ; 3A :
db PUNCT                ; 3B ;
db PUNCT                ; 3C <
db PUNCT                ; 3D =
db PUNCT                ; 3E >
db PUNCT                ; 3F ?
; 64..79                
db PUNCT                ; 40 @
db LETTER | UPPER       ; 41 A
db LETTER | UPPER       ; 42 B
db LETTER | UPPER       ; 43 C
db LETTER | UPPER       ; 44 D
db LETTER | UPPER       ; 45 E
db LETTER | UPPER       ; 46 F
db LETTER | UPPER       ; 47 G
db LETTER | UPPER       ; 48 H
db LETTER | UPPER       ; 49 I
db LETTER | UPPER       ; 4A J
db LETTER | UPPER       ; 4B K
db LETTER | UPPER       ; 4C L
db LETTER | UPPER       ; 4D M
db LETTER | UPPER       ; 4E N
db LETTER | UPPER       ; 4F O
; 80..95                
db LETTER | UPPER       ; 50 P
db LETTER | UPPER       ; 51 Q
db LETTER | UPPER       ; 52 R
db LETTER | UPPER       ; 53 S
db LETTER | UPPER       ; 54 T
db LETTER | UPPER       ; 55 U
db LETTER | UPPER       ; 56 V
db LETTER | UPPER       ; 57 W
db LETTER | UPPER       ; 58 X
db LETTER | UPPER       ; 59 Y
db LETTER | UPPER       ; 5A Z
db PUNCT                ; 5B [
db PUNCT                ; 5C \
db PUNCT                ; 5D ]
db PUNCT                ; 5E ^
db PUNCT                ; 5F _
; 96..111               
db PUNCT                ; 60 `
db LETTER | LOWER       ; 61 a
db LETTER | LOWER       ; 62 b
db LETTER | LOWER       ; 63 c
db LETTER | LOWER       ; 64 d
db LETTER | LOWER       ; 65 e
db LETTER | LOWER       ; 66 f
db LETTER | LOWER       ; 67 g
db LETTER | LOWER       ; 68 h
db LETTER | LOWER       ; 69 i
db LETTER | LOWER       ; 6A j
db LETTER | LOWER       ; 6B k
db LETTER | LOWER       ; 6C l
db LETTER | LOWER       ; 6D m
db LETTER | LOWER       ; 6E n
db LETTER | LOWER       ; 6F o
; 112..127              
db LETTER | LOWER       ; 70 p
db LETTER | LOWER       ; 71 q
db LETTER | LOWER       ; 72 r
db LETTER | LOWER       ; 73 s
db LETTER | LOWER       ; 74 t
db LETTER | LOWER       ; 75 u
db LETTER | LOWER       ; 76 v
db LETTER | LOWER       ; 77 w
db LETTER | LOWER       ; 78 x
db LETTER | LOWER       ; 79 y
db LETTER | LOWER       ; 7A z
db PUNCT                ; 7B {
db PUNCT                ; 7C |
db PUNCT                ; 7D }
db PUNCT                ; 7E ~
db CONTROL              ; 7F (DEL)
; 128..255
times 128 db 0

Next, ZIRON version: Code:
/*
/    Character classification routines(CharClass.zir)
/    Copyright (c) 0CodErr, KolibriOS team
*/
const CHAR_DIGIT      = 0x01; // 1<<0; // 1b        ; 0 bit
const CHAR_LETTER     = 0x02; // 1<<1; // 10b       ; 1 bit
const CHAR_UPPER      = 0x04; // 1<<2; // 100b      ; 2 bit
const CHAR_LOWER      = 0x08; // 1<<3; // 1000b     ; 3 bit
const CHAR_CONTROL    = 0x10; // 1<<4; // 10000b    ; 4 bit
const CHAR_WHITESPACE = 0x20; // 1<<5; // 100000b   ; 5 bit
const CHAR_PUNCT      = 0x40; // 1<<6; // 1000000b  ; 6 bit

const CHAR_CONTROL_or_CHAR_WHITESPACE = CHAR_CONTROL or CHAR_WHITESPACE;
const CHAR_LETTER_or_CHAR_UPPER = CHAR_LETTER or CHAR_UPPER;
const CHAR_LETTER_or_CHAR_LOWER = CHAR_LETTER or CHAR_LOWER;
inline procedure IsDigit($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_DIGIT;
//al >> 0 ; no shift because 0'th bit
}
inline procedure IsLetter($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_LETTER;
  al >> 1;
}
inline procedure IsUpper($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_UPPER;
  al >> 2;
}
inline procedure IsLower($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_LOWER;
  al >> 3;
}
inline procedure IsControl($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_CONTROL;
  al >> 4;
}
inline procedure IsWhiteSpace($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_WHITESPACE;
  al >> 5;
}
inline procedure IsPunct($simbol) {
  movzx gp_ax, $simbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_PUNCT;
  al >> 6;
}
char CHAR_TABLE[] =
/* 0..15 */
CHAR_CONTROL;                    // 00 (NUL)
CHAR_CONTROL;                    // 01 (SOH)
CHAR_CONTROL;                    // 02 (STX)
CHAR_CONTROL;                    // 03 (ETX)
CHAR_CONTROL;                    // 04 (EOT)
CHAR_CONTROL;                    // 05 (ENQ)
CHAR_CONTROL;                    // 06 (ACK)
CHAR_CONTROL;                    // 07 (BEL)
CHAR_CONTROL;                    // 08 (BS)
CHAR_CONTROL_or_CHAR_WHITESPACE; // 09 (HT)
CHAR_CONTROL_or_CHAR_WHITESPACE; // 0A (LF)
CHAR_CONTROL_or_CHAR_WHITESPACE; // 0B (VT)
CHAR_CONTROL_or_CHAR_WHITESPACE; // 0C (FF)
CHAR_CONTROL_or_CHAR_WHITESPACE; // 0D (CR)
CHAR_CONTROL;                    // 0E (SI)
CHAR_CONTROL;                    // 0F (SO)
/* 16..31 */
CHAR_CONTROL;                    // 10 (DLE)
CHAR_CONTROL;                    // 11 (DC1)
CHAR_CONTROL;                    // 12 (DC2)
CHAR_CONTROL;                    // 13 (DC3)
CHAR_CONTROL;                    // 14 (DC4)
CHAR_CONTROL;                    // 15 (NAK)
CHAR_CONTROL;                    // 16 (SYN)
CHAR_CONTROL;                    // 17 (ETB)
CHAR_CONTROL;                    // 18 (CAN)
CHAR_CONTROL;                    // 19 (EM)
CHAR_CONTROL;                    // 1A (SUB)
CHAR_CONTROL;                    // 1B (ESC)
CHAR_CONTROL;                    // 1C (FS)
CHAR_CONTROL;                    // 1D (GS)
CHAR_CONTROL;                    // 1E (RS)
CHAR_CONTROL;                    // 1F (US)
/* 32..47 */
CHAR_WHITESPACE;                 // 20 SPACE
CHAR_PUNCT;                      // 21 !
CHAR_PUNCT;                      // 22 "
CHAR_PUNCT;                      // 23 #
CHAR_PUNCT;                      // 24 $
CHAR_PUNCT;                      // 25 %
CHAR_PUNCT;                      // 26 &
CHAR_PUNCT;                      // 27 '
CHAR_PUNCT;                      // 28 (
CHAR_PUNCT;                      // 29 )
CHAR_PUNCT;                      // 2A *
CHAR_PUNCT;                      // 2B +
CHAR_PUNCT;                      // 2C ,
CHAR_PUNCT;                      // 2D -
CHAR_PUNCT;                      // 2E .
CHAR_PUNCT;                      // 2F /
/* 48..63 */
CHAR_DIGIT;                      // 30 0
CHAR_DIGIT;                      // 31 1
CHAR_DIGIT;                      // 32 2
CHAR_DIGIT;                      // 33 3
CHAR_DIGIT;                      // 34 4
CHAR_DIGIT;                      // 35 5
CHAR_DIGIT;                      // 36 6
CHAR_DIGIT;                      // 37 7
CHAR_DIGIT;                      // 38 8
CHAR_DIGIT;                      // 39 9
CHAR_PUNCT;                      // 3A :
CHAR_PUNCT;                      // 3B ;
CHAR_PUNCT;                      // 3C <
CHAR_PUNCT;                      // 3D =
CHAR_PUNCT;                      // 3E >
CHAR_PUNCT;                      // 3F ?
/* 64..79 */
CHAR_PUNCT;                      // 40 @
CHAR_LETTER_or_CHAR_UPPER;       // 41 A
CHAR_LETTER_or_CHAR_UPPER;       // 42 B
CHAR_LETTER_or_CHAR_UPPER;       // 43 C
CHAR_LETTER_or_CHAR_UPPER;       // 44 D
CHAR_LETTER_or_CHAR_UPPER;       // 45 E
CHAR_LETTER_or_CHAR_UPPER;       // 46 F
CHAR_LETTER_or_CHAR_UPPER;       // 47 G
CHAR_LETTER_or_CHAR_UPPER;       // 48 H
CHAR_LETTER_or_CHAR_UPPER;       // 49 I
CHAR_LETTER_or_CHAR_UPPER;       // 4A J
CHAR_LETTER_or_CHAR_UPPER;       // 4B K
CHAR_LETTER_or_CHAR_UPPER;       // 4C L
CHAR_LETTER_or_CHAR_UPPER;       // 4D M
CHAR_LETTER_or_CHAR_UPPER;       // 4E N
CHAR_LETTER_or_CHAR_UPPER;       // 4F O
/* 80..95 */
CHAR_LETTER_or_CHAR_UPPER;       // 50 P
CHAR_LETTER_or_CHAR_UPPER;       // 51 Q
CHAR_LETTER_or_CHAR_UPPER;       // 52 R
CHAR_LETTER_or_CHAR_UPPER;       // 53 S
CHAR_LETTER_or_CHAR_UPPER;       // 54 T
CHAR_LETTER_or_CHAR_UPPER;       // 55 U
CHAR_LETTER_or_CHAR_UPPER;       // 56 V
CHAR_LETTER_or_CHAR_UPPER;       // 57 W
CHAR_LETTER_or_CHAR_UPPER;       // 58 X
CHAR_LETTER_or_CHAR_UPPER;       // 59 Y
CHAR_LETTER_or_CHAR_UPPER;       // 5A Z
CHAR_PUNCT;                      // 5B [
CHAR_PUNCT;                      // 5C \
CHAR_PUNCT;                      // 5D ]
CHAR_PUNCT;                      // 5E ^
CHAR_PUNCT;                      // 5F _
/* 96..111 */
CHAR_PUNCT;                      // 60 `
CHAR_LETTER_or_CHAR_LOWER;       // 61 a
CHAR_LETTER_or_CHAR_LOWER;       // 62 b
CHAR_LETTER_or_CHAR_LOWER;       // 63 c
CHAR_LETTER_or_CHAR_LOWER;       // 64 d
CHAR_LETTER_or_CHAR_LOWER;       // 65 e
CHAR_LETTER_or_CHAR_LOWER;       // 66 f
CHAR_LETTER_or_CHAR_LOWER;       // 67 g
CHAR_LETTER_or_CHAR_LOWER;       // 68 h
CHAR_LETTER_or_CHAR_LOWER;       // 69 i
CHAR_LETTER_or_CHAR_LOWER;       // 6A j
CHAR_LETTER_or_CHAR_LOWER;       // 6B k
CHAR_LETTER_or_CHAR_LOWER;       // 6C l
CHAR_LETTER_or_CHAR_LOWER;       // 6D m
CHAR_LETTER_or_CHAR_LOWER;       // 6E n
CHAR_LETTER_or_CHAR_LOWER;       // 6F o
/* 112..127 */
CHAR_LETTER_or_CHAR_LOWER;       // 70 p
CHAR_LETTER_or_CHAR_LOWER;       // 71 q
CHAR_LETTER_or_CHAR_LOWER;       // 72 r
CHAR_LETTER_or_CHAR_LOWER;       // 73 s
CHAR_LETTER_or_CHAR_LOWER;       // 74 t
CHAR_LETTER_or_CHAR_LOWER;       // 75 u
CHAR_LETTER_or_CHAR_LOWER;       // 76 v
CHAR_LETTER_or_CHAR_LOWER;       // 77 w
CHAR_LETTER_or_CHAR_LOWER;       // 78 x
CHAR_LETTER_or_CHAR_LOWER;       // 79 y
CHAR_LETTER_or_CHAR_LOWER;       // 7A z
CHAR_PUNCT;                      // 7B {
CHAR_PUNCT;                      // 7C |
CHAR_PUNCT;                      // 7D }
CHAR_PUNCT;                      // 7E ~
CHAR_CONTROL;                    // 7F (DEL)
/* 128..255 */
$repeat 128: 0 $end;

Test app with charclass: Code:
program PE32_CUI 'Test';

#include 'win_def.zir';
#include 'console.zir';

#include 'CharClass.zir';

char mychar = '0';

if (IsDigit(mychar) == true){
  print('TRUE \n');
}else{
  print('FALSE \n');
}

wait_key();
ExitProcess(0);

Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1448] - posted: 2015-01-13 18:06:38
Hi 0CodErr,

Thanks for posting. It is certainly a good idea. OK the first issues I see are:

consts support worded math ops

Code:
const CHAR_DIGIT = 1 shl 0;       // 1b        ; 0 bit
const CHAR_LETTER = 1 shl 1;       // 10b       ; 1 bit
const CHAR_UPPER = 1 shl 2;       // 100b      ; 2 bit
const CHAR_LOWER = 1 shl 3;       // 1000b     ; 3 bit
const CHAR_CONTROL = 1 shl 4;     // 10000b    ; 4 bit
const CHAR_WHITESPACE = 1 shl 5;   // 100000b   ; 5 bit
const CHAR_PUNCT = 1 shl 6;       // 1000000b  ; 6 bit

const CHAR_CONTROL_or_CHAR_WHITESPACE = CHAR_CONTROL or CHAR_WHITESPACE;
const CHAR_LETTER_or_CHAR_UPPER = CHAR_LETTER or CHAR_UPPER;
const CHAR_LETTER_or_CHAR_LOWER = CHAR_LETTER or CHAR_LOWER;


I will add this to my TODO list for using << >> etc.

Next is the table:

Code:
char CHAR_TABLE[256] = [
  CHAR_CONTROL,                    // 00 (NUL)
  CHAR_CONTROL,                    // 01 (SOH)
  CHAR_CONTROL,                    // 02 (STX)
  CHAR_CONTROL,                    // 03 (ETX)
  CHAR_CONTROL,                    // 04 (EOT)
  CHAR_CONTROL,                    // 05 (ENQ)
  CHAR_CONTROL,                    // 06 (ACK)
  CHAR_CONTROL,                    // 07 (BEL)
  CHAR_CONTROL,                    // 08 (BS)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 09 (HT)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0A (LF)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0B (VT)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0C (FF)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0D (CR)
  CHAR_CONTROL,                    // 0E (SI)
  CHAR_CONTROL,                    // 0F (SO)
  /* 16..31 */
  CHAR_CONTROL,                    // 10 (DLE)
  CHAR_CONTROL,                    // 11 (DC1)
  CHAR_CONTROL,                    // 12 (DC2)
  CHAR_CONTROL,                    // 13 (DC3)
  CHAR_CONTROL,                    // 14 (DC4)
  CHAR_CONTROL,                    // 15 (NAK)
  CHAR_CONTROL,                    // 16 (SYN)
  CHAR_CONTROL,                    // 17 (ETB)
  CHAR_CONTROL,                    // 18 (CAN)
  CHAR_CONTROL,                    // 19 (EM)
  CHAR_CONTROL,                    // 1A (SUB)
  CHAR_CONTROL,                    // 1B (ESC)
  CHAR_CONTROL,                    // 1C (FS)
  CHAR_CONTROL,                    // 1D (GS)
  CHAR_CONTROL,                    // 1E (RS)
  CHAR_CONTROL,                    // 1F (US)
  /* 32..47 */
  CHAR_WHITESPACE,                 // 20 SPACE
  CHAR_PUNCT,                      // 21 !
  CHAR_PUNCT,                      // 22 "
  CHAR_PUNCT,                      // 23 #
  CHAR_PUNCT,                      // 24 $
  CHAR_PUNCT,                      // 25 %
  CHAR_PUNCT,                      // 26 &
  CHAR_PUNCT,                      // 27 '
  CHAR_PUNCT,                      // 28 (
  CHAR_PUNCT,                      // 29 )
  CHAR_PUNCT,                      // 2A *
  CHAR_PUNCT,                      // 2B +
  CHAR_PUNCT,                      // 2C ,
  CHAR_PUNCT,                      // 2D -
  CHAR_PUNCT,                      // 2E .
  CHAR_PUNCT,                      // 2F /
  /* 48..63 */
  CHAR_DIGIT,                      // 30 0
  CHAR_DIGIT,                      // 31 1
  CHAR_DIGIT,                      // 32 2
  CHAR_DIGIT,                      // 33 3
  CHAR_DIGIT,                      // 34 4
  CHAR_DIGIT,                      // 35 5
  CHAR_DIGIT,                      // 36 6
  CHAR_DIGIT,                      // 37 7
  CHAR_DIGIT,                      // 38 8
  CHAR_DIGIT,                      // 39 9
  CHAR_PUNCT,                      // 3A :
  CHAR_PUNCT,                      // 3B ;
  CHAR_PUNCT,                      // 3C <
  CHAR_PUNCT,                      // 3D =
  CHAR_PUNCT,                      // 3E >
  CHAR_PUNCT,                      // 3F ?
  /* 64..79 */
  CHAR_PUNCT,                      // 40 @
  CHAR_LETTER_or_CHAR_UPPER,       // 41 A
  CHAR_LETTER_or_CHAR_UPPER,       // 42 B
  CHAR_LETTER_or_CHAR_UPPER,       // 43 C
  CHAR_LETTER_or_CHAR_UPPER,       // 44 D
  CHAR_LETTER_or_CHAR_UPPER,       // 45 E
  CHAR_LETTER_or_CHAR_UPPER,       // 46 F
  CHAR_LETTER_or_CHAR_UPPER,       // 47 G
  CHAR_LETTER_or_CHAR_UPPER,       // 48 H
  CHAR_LETTER_or_CHAR_UPPER,       // 49 I
  CHAR_LETTER_or_CHAR_UPPER,       // 4A J
  CHAR_LETTER_or_CHAR_UPPER,       // 4B K
  CHAR_LETTER_or_CHAR_UPPER,       // 4C L
  CHAR_LETTER_or_CHAR_UPPER,       // 4D M
  CHAR_LETTER_or_CHAR_UPPER,       // 4E N
  CHAR_LETTER_or_CHAR_UPPER,       // 4F O
  /* 80..95 */
  CHAR_LETTER_or_CHAR_UPPER,       // 50 P
  CHAR_LETTER_or_CHAR_UPPER,       // 51 Q
  CHAR_LETTER_or_CHAR_UPPER,       // 52 R
  CHAR_LETTER_or_CHAR_UPPER,       // 53 S
  CHAR_LETTER_or_CHAR_UPPER,       // 54 T
  CHAR_LETTER_or_CHAR_UPPER,       // 55 U
  CHAR_LETTER_or_CHAR_UPPER,       // 56 V
  CHAR_LETTER_or_CHAR_UPPER,       // 57 W
  CHAR_LETTER_or_CHAR_UPPER,       // 58 X
  CHAR_LETTER_or_CHAR_UPPER,       // 59 Y
  CHAR_LETTER_or_CHAR_UPPER,       // 5A Z
  CHAR_PUNCT,                      // 5B [
  CHAR_PUNCT,                      // 5C \
  CHAR_PUNCT,                      // 5D ]
  CHAR_PUNCT,                      // 5E ^
  CHAR_PUNCT,                      // 5F _
  /* 96..111 */
  CHAR_PUNCT,                      // 60 `
  CHAR_LETTER_or_CHAR_LOWER,       // 61 a
  CHAR_LETTER_or_CHAR_LOWER,       // 62 b
  CHAR_LETTER_or_CHAR_LOWER,       // 63 c
  CHAR_LETTER_or_CHAR_LOWER,       // 64 d
  CHAR_LETTER_or_CHAR_LOWER,       // 65 e
  CHAR_LETTER_or_CHAR_LOWER,       // 66 f
  CHAR_LETTER_or_CHAR_LOWER,       // 67 g
  CHAR_LETTER_or_CHAR_LOWER,       // 68 h
  CHAR_LETTER_or_CHAR_LOWER,       // 69 i
  CHAR_LETTER_or_CHAR_LOWER,       // 6A j
  CHAR_LETTER_or_CHAR_LOWER,       // 6B k
  CHAR_LETTER_or_CHAR_LOWER,       // 6C l
  CHAR_LETTER_or_CHAR_LOWER,       // 6D m
  CHAR_LETTER_or_CHAR_LOWER,       // 6E n
  CHAR_LETTER_or_CHAR_LOWER,       // 6F o
  /* 112..127 */
  CHAR_LETTER_or_CHAR_LOWER,       // 70 p
  CHAR_LETTER_or_CHAR_LOWER,       // 71 q
  CHAR_LETTER_or_CHAR_LOWER,       // 72 r
  CHAR_LETTER_or_CHAR_LOWER,       // 73 s
  CHAR_LETTER_or_CHAR_LOWER,       // 74 t
  CHAR_LETTER_or_CHAR_LOWER,       // 75 u
  CHAR_LETTER_or_CHAR_LOWER,       // 76 v
  CHAR_LETTER_or_CHAR_LOWER,       // 77 w
  CHAR_LETTER_or_CHAR_LOWER,       // 78 x
  CHAR_LETTER_or_CHAR_LOWER,       // 79 y
  CHAR_LETTER_or_CHAR_LOWER,       // 7A z
  CHAR_PUNCT,                      // 7B {
  CHAR_PUNCT,                      // 7C |
  CHAR_PUNCT,                      // 7D }
  CHAR_PUNCT,                      // 7E ~
  CHAR_CONTROL                    // 7F (DEL)
];


Macros will not work as expected like conventional assembly since code is not directly output, the assembler decides where code should be placed inside the file (better support for later cross compilation).

So as above we create the table with size which then will auto fill in missing entries as 0.

Next is the inline macro, since it will return a result is must be an inline function

Code:
inline function IsDigit($symbol) {



The rest looks fine, there is actually a few issues with the assembler that I will work on today and tomorrow and hopefully be able to post a complete working version of your code.

Thanks,

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1450] - posted: 2015-01-13 19:58:21
Thank you for your reply.

And also currently we have in char_table values not used 7'th bit. I don't know for what we should use it.

There is way to do more shorter macro. If we accept that true is just non-zero value. Then we not need shifts(i.e. "al>>2" etc).

We could use: Code:
if (IsDigit(mychar) == false){
  print('FALSE \n');
}else{
  print('TRUE \n');
}
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1452] - posted: 2015-01-14 05:57:57
OK, i have finished correcting the issues.

Here is my sample code based off yours:

Code:
program PE32_CUI 'test';

#include 'win_def.zir';
#include 'console.zir';


const CHAR_DIGIT = 1 << 0;       // 1b        ; 0 bit
const CHAR_LETTER = 1 << 1;       // 10b       ; 1 bit
const CHAR_UPPER = 1 << 2;       // 100b      ; 2 bit
const CHAR_LOWER = 1 << 3;       // 1000b     ; 3 bit
const CHAR_CONTROL = 1 << 4;     // 10000b    ; 4 bit
const CHAR_WHITESPACE = 1 << 5;   // 100000b   ; 5 bit
const CHAR_PUNCT = 1 << 6;       // 1000000b  ; 6 bit

const CHAR_CONTROL_or_CHAR_WHITESPACE = CHAR_CONTROL or CHAR_WHITESPACE;
const CHAR_LETTER_or_CHAR_UPPER = CHAR_LETTER or CHAR_UPPER;
const CHAR_LETTER_or_CHAR_LOWER = CHAR_LETTER or CHAR_LOWER;

char CHAR_TABLE[256] = [
  CHAR_CONTROL,                    // 00 (NUL)
  CHAR_CONTROL,                    // 01 (SOH)
  CHAR_CONTROL,                    // 02 (STX)
  CHAR_CONTROL,                    // 03 (ETX)
  CHAR_CONTROL,                    // 04 (EOT)
  CHAR_CONTROL,                    // 05 (ENQ)
  CHAR_CONTROL,                    // 06 (ACK)
  CHAR_CONTROL,                    // 07 (BEL)
  CHAR_CONTROL,                    // 08 (BS)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 09 (HT)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0A (LF)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0B (VT)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0C (FF)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0D (CR)
  CHAR_CONTROL,                    // 0E (SI)
  CHAR_CONTROL,                    // 0F (SO)
  // 16..31 /
  CHAR_CONTROL,                    // 10 (DLE)
  CHAR_CONTROL,                    // 11 (DC1)
  CHAR_CONTROL,                    // 12 (DC2)
  CHAR_CONTROL,                    // 13 (DC3)
  CHAR_CONTROL,                    // 14 (DC4)
  CHAR_CONTROL,                    // 15 (NAK)
  CHAR_CONTROL,                    // 16 (SYN)
  CHAR_CONTROL,                    // 17 (ETB)
  CHAR_CONTROL,                    // 18 (CAN)
  CHAR_CONTROL,                    // 19 (EM)
  CHAR_CONTROL,                    // 1A (SUB)
  CHAR_CONTROL,                    // 1B (ESC)
  CHAR_CONTROL,                    // 1C (FS)
  CHAR_CONTROL,                    // 1D (GS)
  CHAR_CONTROL,                    // 1E (RS)
  CHAR_CONTROL,                    // 1F (US)
  // 32..47 /
  CHAR_WHITESPACE,                 // 20 SPACE
  CHAR_PUNCT,                      // 21 !
  CHAR_PUNCT,                      // 22 "
  CHAR_PUNCT,                      // 23 #
  CHAR_PUNCT,                      // 24 $
  CHAR_PUNCT,                      // 25 %
  CHAR_PUNCT,                      // 26 &
  CHAR_PUNCT,                      // 27 '
  CHAR_PUNCT,                      // 28 (
  CHAR_PUNCT,                      // 29 )
  CHAR_PUNCT,                      // 2A *
  CHAR_PUNCT,                      // 2B +
  CHAR_PUNCT,                      // 2C ,
  CHAR_PUNCT,                      // 2D -
  CHAR_PUNCT,                      // 2E .
  CHAR_PUNCT,                      // 2F /
  // 48..63 /
  CHAR_DIGIT,                      // 30 0
  CHAR_DIGIT,                      // 31 1
  CHAR_DIGIT,                      // 32 2
  CHAR_DIGIT,                      // 33 3
  CHAR_DIGIT,                      // 34 4
  CHAR_DIGIT,                      // 35 5
  CHAR_DIGIT,                      // 36 6
  CHAR_DIGIT,                      // 37 7
  CHAR_DIGIT,                      // 38 8
  CHAR_DIGIT,                      // 39 9
  CHAR_PUNCT,                      // 3A :
  CHAR_PUNCT,                      // 3B ;
  CHAR_PUNCT,                      // 3C <
  CHAR_PUNCT,                      // 3D =
  CHAR_PUNCT,                      // 3E >
  CHAR_PUNCT,                      // 3F ?
  // 64..79 /
  CHAR_PUNCT,                      // 40 @
  CHAR_LETTER_or_CHAR_UPPER,       // 41 A
  CHAR_LETTER_or_CHAR_UPPER,       // 42 B
  CHAR_LETTER_or_CHAR_UPPER,       // 43 C
  CHAR_LETTER_or_CHAR_UPPER,       // 44 D
  CHAR_LETTER_or_CHAR_UPPER,       // 45 E
  CHAR_LETTER_or_CHAR_UPPER,       // 46 F
  CHAR_LETTER_or_CHAR_UPPER,       // 47 G
  CHAR_LETTER_or_CHAR_UPPER,       // 48 H
  CHAR_LETTER_or_CHAR_UPPER,       // 49 I
  CHAR_LETTER_or_CHAR_UPPER,       // 4A J
  CHAR_LETTER_or_CHAR_UPPER,       // 4B K
  CHAR_LETTER_or_CHAR_UPPER,       // 4C L
  CHAR_LETTER_or_CHAR_UPPER,       // 4D M
  CHAR_LETTER_or_CHAR_UPPER,       // 4E N
  CHAR_LETTER_or_CHAR_UPPER,       // 4F O
  // 80..95 /
  CHAR_LETTER_or_CHAR_UPPER,       // 50 P
  CHAR_LETTER_or_CHAR_UPPER,       // 51 Q
  CHAR_LETTER_or_CHAR_UPPER,       // 52 R
  CHAR_LETTER_or_CHAR_UPPER,       // 53 S
  CHAR_LETTER_or_CHAR_UPPER,       // 54 T
  CHAR_LETTER_or_CHAR_UPPER,       // 55 U
  CHAR_LETTER_or_CHAR_UPPER,       // 56 V
  CHAR_LETTER_or_CHAR_UPPER,       // 57 W
  CHAR_LETTER_or_CHAR_UPPER,       // 58 X
  CHAR_LETTER_or_CHAR_UPPER,       // 59 Y
  CHAR_LETTER_or_CHAR_UPPER,       // 5A Z
  CHAR_PUNCT,                      // 5B [
  CHAR_PUNCT,                      // 5C \
  CHAR_PUNCT,                      // 5D ]
  CHAR_PUNCT,                      // 5E ^
  CHAR_PUNCT,                      // 5F _
  // 96..111 /
  CHAR_PUNCT,                      // 60 `
  CHAR_LETTER_or_CHAR_LOWER,       // 61 a
  CHAR_LETTER_or_CHAR_LOWER,       // 62 b
  CHAR_LETTER_or_CHAR_LOWER,       // 63 c
  CHAR_LETTER_or_CHAR_LOWER,       // 64 d
  CHAR_LETTER_or_CHAR_LOWER,       // 65 e
  CHAR_LETTER_or_CHAR_LOWER,       // 66 f
  CHAR_LETTER_or_CHAR_LOWER,       // 67 g
  CHAR_LETTER_or_CHAR_LOWER,       // 68 h
  CHAR_LETTER_or_CHAR_LOWER,       // 69 i
  CHAR_LETTER_or_CHAR_LOWER,       // 6A j
  CHAR_LETTER_or_CHAR_LOWER,       // 6B k
  CHAR_LETTER_or_CHAR_LOWER,       // 6C l
  CHAR_LETTER_or_CHAR_LOWER,       // 6D m
  CHAR_LETTER_or_CHAR_LOWER,       // 6E n
  CHAR_LETTER_or_CHAR_LOWER,       // 6F o
  // 112..127 /
  CHAR_LETTER_or_CHAR_LOWER,       // 70 p
  CHAR_LETTER_or_CHAR_LOWER,       // 71 q
  CHAR_LETTER_or_CHAR_LOWER,       // 72 r
  CHAR_LETTER_or_CHAR_LOWER,       // 73 s
  CHAR_LETTER_or_CHAR_LOWER,       // 74 t
  CHAR_LETTER_or_CHAR_LOWER,       // 75 u
  CHAR_LETTER_or_CHAR_LOWER,       // 76 v
  CHAR_LETTER_or_CHAR_LOWER,       // 77 w
  CHAR_LETTER_or_CHAR_LOWER,       // 78 x
  CHAR_LETTER_or_CHAR_LOWER,       // 79 y
  CHAR_LETTER_or_CHAR_LOWER,       // 7A z
  CHAR_PUNCT,                      // 7B {
  CHAR_PUNCT,                      // 7C |
  CHAR_PUNCT,                      // 7D }
  CHAR_PUNCT,                      // 7E ~
  CHAR_CONTROL                    // 7F (DEL)
];

inline function IsDigit($symbol) {  
  eax = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_DIGIT
  
  $return gp_ax;
}


char mychar = '4';

if (IsDigit(@mychar) == true) {
  print('TRUE \n');
} else {
  print('FALSE \n');
}


wait_key();
ExitProcess(0);


You can update your include file as appropriate. If you would like this file to be included please let me know and I will bundle it inside the include pack on further releases.

It may be worth for you to add checks in the macros for the char scale, in case a wchar is passed.

Please grab the latest update of Ziron for the fixes: 2.0.0.14

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1454] - posted: 2015-01-14 14:03:50
Now i tested Ziron 2.0.0.14. with CharClass sample.
In your code i found Code:
if (IsDigit(@mychar) == true) {
But there is need value of char and not address. If i use your original code then program crashes.

Next, because Code:
movzx eax, $simbol
yet not supported i do this way: Code:
gp_ax = 0; al = $symbol;


Code which correctly works: Code:
program PE32_CUI 'test';

#include 'win_def.zir';
#include 'console.zir';

const CHAR_DIGIT      = 1 << 0; // 1b       ; 0 bit
const CHAR_LETTER     = 1 << 1; // 10b      ; 1 bit
const CHAR_UPPER      = 1 << 2; // 100b     ; 2 bit
const CHAR_LOWER      = 1 << 3; // 1000b    ; 3 bit
const CHAR_CONTROL    = 1 << 4; // 10000b   ; 4 bit
const CHAR_WHITESPACE = 1 << 5; // 100000b  ; 5 bit
const CHAR_PUNCT      = 1 << 6; // 1000000b ; 6 bit

const CHAR_CONTROL_or_CHAR_WHITESPACE = CHAR_CONTROL | CHAR_WHITESPACE;
const CHAR_LETTER_or_CHAR_UPPER       = CHAR_LETTER  | CHAR_UPPER;
const CHAR_LETTER_or_CHAR_LOWER       = CHAR_LETTER  | CHAR_LOWER;

char CHAR_TABLE[256] = [
  // 0..15 /
  CHAR_CONTROL,                    // 00 (NUL)
  CHAR_CONTROL,                    // 01 (SOH)
  CHAR_CONTROL,                    // 02 (STX)
  CHAR_CONTROL,                    // 03 (ETX)
  CHAR_CONTROL,                    // 04 (EOT)
  CHAR_CONTROL,                    // 05 (ENQ)
  CHAR_CONTROL,                    // 06 (ACK)
  CHAR_CONTROL,                    // 07 (BEL)
  CHAR_CONTROL,                    // 08 (BS)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 09 (HT)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0A (LF)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0B (VT)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0C (FF)
  CHAR_CONTROL_or_CHAR_WHITESPACE, // 0D (CR)
  CHAR_CONTROL,                    // 0E (SI)
  CHAR_CONTROL,                    // 0F (SO)
  // 16..31 /
  CHAR_CONTROL,                    // 10 (DLE)
  CHAR_CONTROL,                    // 11 (DC1)
  CHAR_CONTROL,                    // 12 (DC2)
  CHAR_CONTROL,                    // 13 (DC3)
  CHAR_CONTROL,                    // 14 (DC4)
  CHAR_CONTROL,                    // 15 (NAK)
  CHAR_CONTROL,                    // 16 (SYN)
  CHAR_CONTROL,                    // 17 (ETB)
  CHAR_CONTROL,                    // 18 (CAN)
  CHAR_CONTROL,                    // 19 (EM)
  CHAR_CONTROL,                    // 1A (SUB)
  CHAR_CONTROL,                    // 1B (ESC)
  CHAR_CONTROL,                    // 1C (FS)
  CHAR_CONTROL,                    // 1D (GS)
  CHAR_CONTROL,                    // 1E (RS)
  CHAR_CONTROL,                    // 1F (US)
  // 32..47 /
  CHAR_WHITESPACE,                 // 20 SPACE
  CHAR_PUNCT,                      // 21 !
  CHAR_PUNCT,                      // 22 "
  CHAR_PUNCT,                      // 23 #
  CHAR_PUNCT,                      // 24 $
  CHAR_PUNCT,                      // 25 %
  CHAR_PUNCT,                      // 26 &
  CHAR_PUNCT,                      // 27 '
  CHAR_PUNCT,                      // 28 (
  CHAR_PUNCT,                      // 29 )
  CHAR_PUNCT,                      // 2A *
  CHAR_PUNCT,                      // 2B +
  CHAR_PUNCT,                      // 2C ,
  CHAR_PUNCT,                      // 2D -
  CHAR_PUNCT,                      // 2E .
  CHAR_PUNCT,                      // 2F /
  // 48..63 /
  CHAR_DIGIT,                      // 30 0
  CHAR_DIGIT,                      // 31 1
  CHAR_DIGIT,                      // 32 2
  CHAR_DIGIT,                      // 33 3
  CHAR_DIGIT,                      // 34 4
  CHAR_DIGIT,                      // 35 5
  CHAR_DIGIT,                      // 36 6
  CHAR_DIGIT,                      // 37 7
  CHAR_DIGIT,                      // 38 8
  CHAR_DIGIT,                      // 39 9
  CHAR_PUNCT,                      // 3A :
  CHAR_PUNCT,                      // 3B ;
  CHAR_PUNCT,                      // 3C <
  CHAR_PUNCT,                      // 3D =
  CHAR_PUNCT,                      // 3E >
  CHAR_PUNCT,                      // 3F ?
  // 64..79 /
  CHAR_PUNCT,                      // 40 @
  CHAR_LETTER_or_CHAR_UPPER,       // 41 A
  CHAR_LETTER_or_CHAR_UPPER,       // 42 B
  CHAR_LETTER_or_CHAR_UPPER,       // 43 C
  CHAR_LETTER_or_CHAR_UPPER,       // 44 D
  CHAR_LETTER_or_CHAR_UPPER,       // 45 E
  CHAR_LETTER_or_CHAR_UPPER,       // 46 F
  CHAR_LETTER_or_CHAR_UPPER,       // 47 G
  CHAR_LETTER_or_CHAR_UPPER,       // 48 H
  CHAR_LETTER_or_CHAR_UPPER,       // 49 I
  CHAR_LETTER_or_CHAR_UPPER,       // 4A J
  CHAR_LETTER_or_CHAR_UPPER,       // 4B K
  CHAR_LETTER_or_CHAR_UPPER,       // 4C L
  CHAR_LETTER_or_CHAR_UPPER,       // 4D M
  CHAR_LETTER_or_CHAR_UPPER,       // 4E N
  CHAR_LETTER_or_CHAR_UPPER,       // 4F O
  // 80..95 /
  CHAR_LETTER_or_CHAR_UPPER,       // 50 P
  CHAR_LETTER_or_CHAR_UPPER,       // 51 Q
  CHAR_LETTER_or_CHAR_UPPER,       // 52 R
  CHAR_LETTER_or_CHAR_UPPER,       // 53 S
  CHAR_LETTER_or_CHAR_UPPER,       // 54 T
  CHAR_LETTER_or_CHAR_UPPER,       // 55 U
  CHAR_LETTER_or_CHAR_UPPER,       // 56 V
  CHAR_LETTER_or_CHAR_UPPER,       // 57 W
  CHAR_LETTER_or_CHAR_UPPER,       // 58 X
  CHAR_LETTER_or_CHAR_UPPER,       // 59 Y
  CHAR_LETTER_or_CHAR_UPPER,       // 5A Z
  CHAR_PUNCT,                      // 5B [
  CHAR_PUNCT,                      // 5C \
  CHAR_PUNCT,                      // 5D ]
  CHAR_PUNCT,                      // 5E ^
  CHAR_PUNCT,                      // 5F _
  // 96..111 /
  CHAR_PUNCT,                      // 60 `
  CHAR_LETTER_or_CHAR_LOWER,       // 61 a
  CHAR_LETTER_or_CHAR_LOWER,       // 62 b
  CHAR_LETTER_or_CHAR_LOWER,       // 63 c
  CHAR_LETTER_or_CHAR_LOWER,       // 64 d
  CHAR_LETTER_or_CHAR_LOWER,       // 65 e
  CHAR_LETTER_or_CHAR_LOWER,       // 66 f
  CHAR_LETTER_or_CHAR_LOWER,       // 67 g
  CHAR_LETTER_or_CHAR_LOWER,       // 68 h
  CHAR_LETTER_or_CHAR_LOWER,       // 69 i
  CHAR_LETTER_or_CHAR_LOWER,       // 6A j
  CHAR_LETTER_or_CHAR_LOWER,       // 6B k
  CHAR_LETTER_or_CHAR_LOWER,       // 6C l
  CHAR_LETTER_or_CHAR_LOWER,       // 6D m
  CHAR_LETTER_or_CHAR_LOWER,       // 6E n
  CHAR_LETTER_or_CHAR_LOWER,       // 6F o
  // 112..127 /
  CHAR_LETTER_or_CHAR_LOWER,       // 70 p
  CHAR_LETTER_or_CHAR_LOWER,       // 71 q
  CHAR_LETTER_or_CHAR_LOWER,       // 72 r
  CHAR_LETTER_or_CHAR_LOWER,       // 73 s
  CHAR_LETTER_or_CHAR_LOWER,       // 74 t
  CHAR_LETTER_or_CHAR_LOWER,       // 75 u
  CHAR_LETTER_or_CHAR_LOWER,       // 76 v
  CHAR_LETTER_or_CHAR_LOWER,       // 77 w
  CHAR_LETTER_or_CHAR_LOWER,       // 78 x
  CHAR_LETTER_or_CHAR_LOWER,       // 79 y
  CHAR_LETTER_or_CHAR_LOWER,       // 7A z
  CHAR_PUNCT,                      // 7B {
  CHAR_PUNCT,                      // 7C |
  CHAR_PUNCT,                      // 7D }
  CHAR_PUNCT,                      // 7E ~
  CHAR_CONTROL                     // 7F (DEL)
];

inline function IsDigit($symbol) {  
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_DIGIT
  
  $return gp_ax;
}

char mychar_0 = '0';
char mychar_1 = '1';
char mychar_2 = '2';
char mychar_3 = '3';
char mychar_4 = '4';
char mychar_5 = '5';
char mychar_6 = '6';
char mychar_7 = '7';
char mychar_8 = '8';
char mychar_9 = '9';

char mychar_q = 'q';
char mychar_w = 'w';
char mychar_e = 'e';
char mychar_r = 'r';
char mychar_t = 't';
char mychar_y = 'y';
char mychar_u = 'u';
char mychar_i = 'i';
char mychar_o = 'o';
char mychar_p = 'p';
char mychar_a = 'a';
char mychar_s = 's';
char mychar_d = 'd';
char mychar_f = 'f';
char mychar_g = 'g';
char mychar_h = 'h';
char mychar_j = 'j';
char mychar_k = 'k';
char mychar_l = 'l';
char mychar_z = 'z';
char mychar_x = 'x';
char mychar_c = 'c';
char mychar_v = 'v';
char mychar_b = 'b';
char mychar_n = 'n';
char mychar_m = 'm';

print('Next 10 values must be TRUE \n');

if (IsDigit(mychar_0) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_1) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_2) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_3) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_4) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_5) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_6) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_7) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_8) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_9) == true){print('TRUE \n');}else{print('FALSE \n');}

print('Next 26 values must be FALSE \n');

if (IsDigit(mychar_q) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_w) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_e) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_r) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_t) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_y) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_u) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_i) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_o) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_p) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_a) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_s) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_d) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_f) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_g) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_h) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_j) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_k) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_l) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_z) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_x) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_c) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_v) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_b) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_n) == true){print('TRUE \n');}else{print('FALSE \n');}
if (IsDigit(mychar_m) == true){print('TRUE \n');}else{print('FALSE \n');}

wait_key();
ExitProcess(0);
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1455] - posted: 2015-01-14 14:24:04
Sorry, I didn't really pay attention I guess it was a little bit late (or early in the morning)... you are correct. Thanks.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1463] - posted: 2015-01-15 10:15:10
At now CharClass.zir looks like this: Code:
/*
/    Character classification routines(CharClass.zir)
/    Copyright (c) 0CodErr, KolibriOS team
*/
const CHAR_DIGIT      = 1 << 0; // 1b       ; 0 bit
const CHAR_LETTER     = 1 << 1; // 10b      ; 1 bit
const CHAR_UPPER      = 1 << 2; // 100b     ; 2 bit
const CHAR_LOWER      = 1 << 3; // 1000b    ; 3 bit
const CHAR_CONTROL    = 1 << 4; // 10000b   ; 4 bit
const CHAR_WHITESPACE = 1 << 5; // 100000b  ; 5 bit
const CHAR_PUNCT      = 1 << 6; // 1000000b ; 6 bit

const CHAR_CONTROL_or_CHAR_WHITESPACE = CHAR_CONTROL | CHAR_WHITESPACE;
const CHAR_LETTER_or_CHAR_UPPER       = CHAR_LETTER  | CHAR_UPPER;
const CHAR_LETTER_or_CHAR_LOWER       = CHAR_LETTER  | CHAR_LOWER;

inline function IsDigit($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_DIGIT;
  $return gp_ax;
}
inline function IsLetter($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_LETTER;
  $return gp_ax;
}
inline function IsUpper($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_UPPER;
  $return gp_ax;
}
inline function IsLower($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_LOWER;
  $return gp_ax;
}
inline function IsControl($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_CONTROL;
  $return gp_ax;
}
inline function IsWhiteSpace($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_WHITESPACE;
  $return gp_ax;
}
inline function IsPunct($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  and al, CHAR_PUNCT;
  $return gp_ax;
}

char CHAR_TABLE[256] = [
// 0..15
CHAR_CONTROL,                    // 00 (NUL)
CHAR_CONTROL,                    // 01 (SOH)
CHAR_CONTROL,                    // 02 (STX)
CHAR_CONTROL,                    // 03 (ETX)
CHAR_CONTROL,                    // 04 (EOT)
CHAR_CONTROL,                    // 05 (ENQ)
CHAR_CONTROL,                    // 06 (ACK)
CHAR_CONTROL,                    // 07 (BEL)
CHAR_CONTROL,                    // 08 (BS)
CHAR_CONTROL_or_CHAR_WHITESPACE, // 09 (HT)
CHAR_CONTROL_or_CHAR_WHITESPACE, // 0A (LF)
CHAR_CONTROL_or_CHAR_WHITESPACE, // 0B (VT)
CHAR_CONTROL_or_CHAR_WHITESPACE, // 0C (FF)
CHAR_CONTROL_or_CHAR_WHITESPACE, // 0D (CR)
CHAR_CONTROL,                    // 0E (SI)
CHAR_CONTROL,                    // 0F (SO)
// 16..31
CHAR_CONTROL,                    // 10 (DLE)
CHAR_CONTROL,                    // 11 (DC1)
CHAR_CONTROL,                    // 12 (DC2)
CHAR_CONTROL,                    // 13 (DC3)
CHAR_CONTROL,                    // 14 (DC4)
CHAR_CONTROL,                    // 15 (NAK)
CHAR_CONTROL,                    // 16 (SYN)
CHAR_CONTROL,                    // 17 (ETB)
CHAR_CONTROL,                    // 18 (CAN)
CHAR_CONTROL,                    // 19 (EM)
CHAR_CONTROL,                    // 1A (SUB)
CHAR_CONTROL,                    // 1B (ESC)
CHAR_CONTROL,                    // 1C (FS)
CHAR_CONTROL,                    // 1D (GS)
CHAR_CONTROL,                    // 1E (RS)
CHAR_CONTROL,                    // 1F (US)
// 32..47
CHAR_WHITESPACE,                 // 20 SPACE
CHAR_PUNCT,                      // 21 !
CHAR_PUNCT,                      // 22 "
CHAR_PUNCT,                      // 23 #
CHAR_PUNCT,                      // 24 $
CHAR_PUNCT,                      // 25 %
CHAR_PUNCT,                      // 26 &
CHAR_PUNCT,                      // 27 '
CHAR_PUNCT,                      // 28 (
CHAR_PUNCT,                      // 29 )
CHAR_PUNCT,                      // 2A *
CHAR_PUNCT,                      // 2B +
CHAR_PUNCT,                      // 2C ,
CHAR_PUNCT,                      // 2D -
CHAR_PUNCT,                      // 2E .
CHAR_PUNCT,                      // 2F /
// 48..63
CHAR_DIGIT,                      // 30 0
CHAR_DIGIT,                      // 31 1
CHAR_DIGIT,                      // 32 2
CHAR_DIGIT,                      // 33 3
CHAR_DIGIT,                      // 34 4
CHAR_DIGIT,                      // 35 5
CHAR_DIGIT,                      // 36 6
CHAR_DIGIT,                      // 37 7
CHAR_DIGIT,                      // 38 8
CHAR_DIGIT,                      // 39 9
CHAR_PUNCT,                      // 3A :
CHAR_PUNCT,                      // 3B ;
CHAR_PUNCT,                      // 3C <
CHAR_PUNCT,                      // 3D =
CHAR_PUNCT,                      // 3E >
CHAR_PUNCT,                      // 3F ?
// 64..79
CHAR_PUNCT,                      // 40 @
CHAR_LETTER_or_CHAR_UPPER,       // 41 A
CHAR_LETTER_or_CHAR_UPPER,       // 42 B
CHAR_LETTER_or_CHAR_UPPER,       // 43 C
CHAR_LETTER_or_CHAR_UPPER,       // 44 D
CHAR_LETTER_or_CHAR_UPPER,       // 45 E
CHAR_LETTER_or_CHAR_UPPER,       // 46 F
CHAR_LETTER_or_CHAR_UPPER,       // 47 G
CHAR_LETTER_or_CHAR_UPPER,       // 48 H
CHAR_LETTER_or_CHAR_UPPER,       // 49 I
CHAR_LETTER_or_CHAR_UPPER,       // 4A J
CHAR_LETTER_or_CHAR_UPPER,       // 4B K
CHAR_LETTER_or_CHAR_UPPER,       // 4C L
CHAR_LETTER_or_CHAR_UPPER,       // 4D M
CHAR_LETTER_or_CHAR_UPPER,       // 4E N
CHAR_LETTER_or_CHAR_UPPER,       // 4F O
// 80..95
CHAR_LETTER_or_CHAR_UPPER,       // 50 P
CHAR_LETTER_or_CHAR_UPPER,       // 51 Q
CHAR_LETTER_or_CHAR_UPPER,       // 52 R
CHAR_LETTER_or_CHAR_UPPER,       // 53 S
CHAR_LETTER_or_CHAR_UPPER,       // 54 T
CHAR_LETTER_or_CHAR_UPPER,       // 55 U
CHAR_LETTER_or_CHAR_UPPER,       // 56 V
CHAR_LETTER_or_CHAR_UPPER,       // 57 W
CHAR_LETTER_or_CHAR_UPPER,       // 58 X
CHAR_LETTER_or_CHAR_UPPER,       // 59 Y
CHAR_LETTER_or_CHAR_UPPER,       // 5A Z
CHAR_PUNCT,                      // 5B [
CHAR_PUNCT,                      // 5C \
CHAR_PUNCT,                      // 5D ]
CHAR_PUNCT,                      // 5E ^
CHAR_PUNCT,                      // 5F _
// 96..111
CHAR_PUNCT,                      // 60 `
CHAR_LETTER_or_CHAR_LOWER,       // 61 a
CHAR_LETTER_or_CHAR_LOWER,       // 62 b
CHAR_LETTER_or_CHAR_LOWER,       // 63 c
CHAR_LETTER_or_CHAR_LOWER,       // 64 d
CHAR_LETTER_or_CHAR_LOWER,       // 65 e
CHAR_LETTER_or_CHAR_LOWER,       // 66 f
CHAR_LETTER_or_CHAR_LOWER,       // 67 g
CHAR_LETTER_or_CHAR_LOWER,       // 68 h
CHAR_LETTER_or_CHAR_LOWER,       // 69 i
CHAR_LETTER_or_CHAR_LOWER,       // 6A j
CHAR_LETTER_or_CHAR_LOWER,       // 6B k
CHAR_LETTER_or_CHAR_LOWER,       // 6C l
CHAR_LETTER_or_CHAR_LOWER,       // 6D m
CHAR_LETTER_or_CHAR_LOWER,       // 6E n
CHAR_LETTER_or_CHAR_LOWER,       // 6F o
// 112..127
CHAR_LETTER_or_CHAR_LOWER,       // 70 p
CHAR_LETTER_or_CHAR_LOWER,       // 71 q
CHAR_LETTER_or_CHAR_LOWER,       // 72 r
CHAR_LETTER_or_CHAR_LOWER,       // 73 s
CHAR_LETTER_or_CHAR_LOWER,       // 74 t
CHAR_LETTER_or_CHAR_LOWER,       // 75 u
CHAR_LETTER_or_CHAR_LOWER,       // 76 v
CHAR_LETTER_or_CHAR_LOWER,       // 77 w
CHAR_LETTER_or_CHAR_LOWER,       // 78 x
CHAR_LETTER_or_CHAR_LOWER,       // 79 y
CHAR_LETTER_or_CHAR_LOWER,       // 7A z
CHAR_PUNCT,                      // 7B {
CHAR_PUNCT,                      // 7C |
CHAR_PUNCT,                      // 7D }
CHAR_PUNCT,                      // 7E ~
CHAR_CONTROL                     // 7F (DEL)
];
Currently in CHAR_TABLE values 7'th bit not used.
Also because Code:
movzx gp_ax, $symbol;
not supported then Code:
gp_ax = 0; al = $symbol;
used instead.
Anyway i think that we can add this into include pack.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1467] - posted: 2015-01-15 11:09:04
OK, done.

I have also added

Code:
inline function GetCharType($symbol) {
  gp_ax = 0; al = $symbol;
  al = CHAR_TABLE[gp_ax];
  $return gp_ax;
}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1 2 3 4
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 8 user(s) online. 0 member(s) and 8 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd