Explorar el Código

Fix masks

They need to zero out everything *except* the bits containing the mask,
which means they need to be as wide as the shift, and filled with ones.
Lucas Stadler %!s(int64=8) %!d(string=hace) años
padre
commit
20e1b53fef
Se han modificado 1 ficheros con 6 adiciones y 6 borrados
  1. 6 6
      scm/inc/driver.c

+ 6 - 6
scm/inc/driver.c

@ -6,12 +6,12 @@
6 6
#define fixnum_tag   0 // 00
7 7
#define fixnum_shift 2
8 8
9
#define char_mask 240  // 11110000
10
#define char_tag  15   // 00001111
9
#define char_mask 0xff  // 11111111
10
#define char_tag  15    // 00001111
11 11
#define char_shift 8
12 12
13
#define boolean_mask  96 // 1100000
14
#define boolean_tag   31 // 0011111
13
#define boolean_mask  0x3f // 1111111
14
#define boolean_tag   31   // 0011111
15 15
#define boolean_shift 7
16 16
17 17
#define empty_list   47 // 00101111
@ -22,9 +22,9 @@ int main(int argc, char **argv) {
22 22
	int val = scheme_entry();
23 23
	if ((val & fixnum_mask) == fixnum_tag) {
24 24
		printf("%d\n", val >> fixnum_shift);
25
	} else if ((val & char_mask) == 0) {
25
	} else if ((val & char_mask) == char_tag) {
26 26
		printf("#\\%c\n", val >> char_shift);
27
	} else if ((val & boolean_mask) == 0) {
27
	} else if ((val & boolean_mask) == boolean_tag) {
28 28
		printf("#%s\n", (val >> boolean_shift) == 1 ? "t" : "f");
29 29
	} else if (val == empty_list) {
30 30
		printf("()\n");