2 * Sources of the "SETS" group instructions
5 /* $Id: do_sets.c,v 2.5 1994/06/24 10:46:53 ceriel Exp $ */
15 PRIVATE bit_test(), create_set();
20 /* INN w: Bit test on w byte set (bit number on top of stack) */
22 LOG(("@Y6 DoINN(%ld)", l));
30 /* SET w: Create singleton w byte set with bit n on (n is top of stack) */
32 LOG(("@Y6 DoSET(%ld)", l));
37 /********************************************************
40 * Tests whether the bit with number to be found *
41 * on TOS is on in 'w'-byte set. *
42 * ON --> push 1 on stack. *
43 * OFF -> push 0 on stack. *
44 ********************************************************/
50 (int) swpop(); /* bitno on TOS */
51 register char test_byte = (char) 0;/* default value to be tested */
52 register int wordoff = bitno / 8;
53 register int bitoff = bitno % 8;
55 if (bitoff < 0) bitoff += 8;
57 if (must_test && !(IgnMask&BIT(ESET))) {
58 /* Only w*8 bits CAN be tested */
63 test_byte = stack_loc(SP + wordoff);
65 wpush((long)((test_byte & BIT(bitoff)) ? 1 : 0));
68 /********************************************************
71 * Creates a singleton 'w'-byte set with as *
72 * singleton member, the bit with number on *
73 * TOS. The w bytes constituting the set are *
74 * pushed on the stack. *
75 ********************************************************/
80 register int bitno = (int) swpop();
81 register size nbytes = w;
82 register int wordoff = bitno / 8;
83 register int bitoff = bitno % 8;
85 if (bitoff < 0) bitoff += 8;
88 while (--nbytes >= 0) {
89 st_stn(SP + nbytes, 0L, 1L);
92 if (must_test && !(IgnMask&BIT(ESET))) {
97 st_stn(SP + wordoff, (long)BIT(bitoff), 1L);