2 * Sources of the "LOGICAL" group instructions
5 /* $Id: do_logic.c,v 2.6 1994/06/24 10:46:37 ceriel Exp $ */
23 #define check_def(p,l) if (!st_sh(p) || !st_sh(p+l)) {warning(WUNLOG);}
25 #define check_def(p,l)
31 /* AND w: Boolean and on two groups of w bytes */
32 /* size of objects to be compared (in bytes) on top of stack */
35 LOG(("@X6 DoAND(%ld)", l));
38 for (p = SP; p < (SP + l); p++) {
40 stack_loc(p + l) &= stack_loc(p);
48 /* IOR w: Boolean inclusive or on two groups of w bytes */
51 LOG(("@X6 DoIOR(%ld)", l));
54 for (p = SP; p < (SP + l); p++) {
56 stack_loc(p + l) |= stack_loc(p);
64 /* XOR w: Boolean exclusive or on two groups of w bytes */
67 LOG(("@X6 DoXOR(%ld)", l));
70 for (p = SP; p < (SP + l); p++) {
72 stack_loc(p + l) ^= stack_loc(p);
80 /* COM w: Complement (one's complement of top w bytes) */
83 LOG(("@X6 DoCOM(%ld)", l));
86 for (p = SP; p < (SP + l); p++) {
88 stack_loc(p) = ~stack_loc(p);
95 /* ROL w: Rotate left a group of w bytes */
96 register long s, t = uwpop();
97 register long signbit;
99 LOG(("@X6 DoROL(%ld)", l));
101 signbit = (arg_wi(l) == 2) ? SIGNBIT2 : SIGNBIT4;
106 /* check shift distance */
118 /* calculate result */
120 s = (s & signbit) ? ((s<<1) | BIT(0)) : (s<<1);
128 /* ROR w: Rotate right a group of w bytes */
129 register long s, t = uwpop();
130 register long signbit;
132 LOG(("@X6 DoROR(%ld)", l));
134 signbit = (arg_wi(l) == 2) ? SIGNBIT2 : SIGNBIT4;
139 /* check shift distance */
151 /* calculate result */
153 /* the >> in C does sign extension, the ROR does not */
155 s = (s >> 1) | signbit;
156 else s = (s >> 1) & ~signbit;