compiler

Unnamed Compiled Systems Language Project
git clone http://frotz.net/git/compiler.git
Log | Files | Refs

1031-logical-and-or.src (784B)


      1 
      2 func is_three(n i32) bool {
      3 	_hexout_(0x333);
      4 	return n == 3;
      5 }
      6 func is_six(n i32) bool {
      7 	_hexout_(0x666);
      8 	return n == 6;
      9 }
     10 func is_nine(n i32) bool {
     11 	_hexout_(0x999);
     12 	return n == 9;
     13 }
     14 
     15 func or_test2(n i32) {
     16 	if (is_three(n) || is_six(n) || is_nine(n)) {
     17 		_hexout_(n | 0x1100);
     18 	} else {
     19 		_hexout_(n | 0x2200);
     20 	}
     21 }
     22 
     23 func or_test(n i32) {
     24 	if (n == 3 || n == 6 || n == 9) {
     25 		_hexout_(n | 0x100);
     26 	} else {
     27 		_hexout_(n | 0x200);
     28 	}
     29 }
     30 func and_test(n i32) {
     31 	if ((n & 1 == 1) && (n & 2 == 2) && (n < 8)) {
     32 		_hexout_(n | 0x300);
     33 	} else {
     34 		_hexout_(n | 0x400);
     35 	}
     36 }
     37 
     38 func start() i32 {
     39 	var n i32 = 0;
     40 	while n < 10 {
     41 		or_test(n);
     42 		n = n + 1;
     43 	}
     44 	n = 0;
     45 	while n < 10 {
     46 		or_test2(n);
     47 		n = n + 1;
     48 	}
     49 	n = 0;
     50 	while n < 16 {
     51 		and_test(n);
     52 		n = n + 1;
     53 	}
     54 	return 0x42;
     55 }
     56