Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / RTL

CharClass

A community discussion post from the original code:zIRON forum.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Seems I forgot to add a type for the operand when none is present.

inline function IsDigit($symbol) {
	$tt = tokentype($_operand);
	$if $tt == TOKEN_EOF:
		$tt = TOKEN_FLAG;
	$end;
  
	$C = CHAR_DIGIT; gp_ax = 0; al = $symbol;
	$if $tt == TOKEN_FLAG:
		test CHAR_TABLE[gp_ax], $C;
		$res = ZF;
	$else
		al = CHAR_TABLE[gp_ax]; al &= $C;
		$res = gp_ax;
	$end;
	$return $res;
}

try this for now, on next release this will be corrected and instead will receive type TOKEN_FLAG on conditional statements.

TOKEN_EOF will be received when the macro is just present without any conditions. e.g.

IsDigit(ord('1'));  // $_operand = TOKEN_EOF type
if (IsDigit(...     // $_operand = TOKEN_FLAG type
//etc
0CodErr member
Posts
201
Threads
37
Location
Unknown

I tried use changed 'charclass.zir' as i posted above.

This for test:

program RAW_IMAGE 'test';

#set bits 32;

#include 'charclass.zir';

  eax = IsDigit(ord('5')); nop;
   //ax = IsDigit(ord('5')); nop; // Operand is invalid
   //ah = IsDigit(ord('5')); nop; // Operand is invalid
   //al = IsDigit(ord('5')); nop; // Operand is invalid
  
  if              (IsDigit(ord('5')) == true) {} ; nop;
  while           (IsDigit(ord('5')) == true) {} ; nop;
  repeat {} until (IsDigit(ord('5')) == true)    ; nop;
  
  case (true) {
  state IsDigit(ord('5')):      break;
  state IsWhiteSpace(ord('5')): break;
  state IsLetter(ord('5')):     break;
  default:
  }

Result(i post only part without table):

00000000  33C0              xor eax,eax
00000002  B035              mov al,0x35
00000004  8A806F000000      mov al,[eax+0x6f]
0000000A  2401              and al,0x1
0000000C  90                nop
0000000D  33C0              xor eax,eax
0000000F  B035              mov al,0x35
00000011  F6806F00000001    test byte [eax+0x6f],0x1
00000018  7400              jz 0x1a
0000001A  90                nop
0000001B  33C0              xor eax,eax
0000001D  B035              mov al,0x35
0000001F  F6806F00000001    test byte [eax+0x6f],0x1
00000026  7402              jz 0x2a
00000028  EBF1              jmp short 0x1b
0000002A  90                nop
0000002B  33C0              xor eax,eax
0000002D  B035              mov al,0x35
0000002F  F6806F00000001    test byte [eax+0x6f],0x1
00000036  74F3              jz 0x2b
00000038  90                nop
00000039  33C0              xor eax,eax
0000003B  B035              mov al,0x35
0000003D  8A806F000000      mov al,[eax+0x6f]
00000043  2401              and al,0x1
00000045  85C0              test eax,eax
00000047  740E              jz 0x57
00000049  EB24              jmp short 0x6f
0000004B  33C0              xor eax,eax
0000004D  B035              mov al,0x35
0000004F  8A806F000000      mov al,[eax+0x6f]
00000055  2410              and al,0x10
00000057  85C0              test eax,eax
00000059  750E              jnz 0x69
0000005B  EB12              jmp short 0x6f
0000005D  33C0              xor eax,eax
0000005F  B035              mov al,0x35
00000061  8A806F000000      mov al,[eax+0x6f]
00000067  2406              and al,0x6
00000069  85C0              test eax,eax
0000006B  7502              jnz 0x6f
0000006D  EB00              jmp short 0x6f
; .........................................................

Seems that "case" statement not use "just test" i.e.

0000001B  33C0              xor eax,eax
0000001D  B035              mov al,0x35
0000001F  F6806F00000001    test byte [eax+0x6f],0x1
00000026  7402              jz 0x2a

it use "and + test"

0000005D  33C0              xor eax,eax
0000005F  B035              mov al,0x35
00000061  8A806F000000      mov al,[eax+0x6f]
00000067  2406              and al,0x6
00000069  85C0              test eax,eax
0000006B  7502              jnz 0x6f

Is it possible to do "case" statement such as others?

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Should be fixed in next release, case states was not passing the flag operand.

0CodErr member
Posts
201
Threads
37
Location
Unknown

My test example above cannot be compiled:

Instruction usage is not supported!
0CodErr member
Posts
201
Threads
37
Location
Unknown

Also i use new version(as above) of 'charclass.zir' but currently still included old version.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Both fixed for next release.