2 * Sources of the "UNSIGNED ARITHMETIC" group instructions
5 /* $Id: do_unsar.c,v 2.5 1994/06/24 10:47:04 ceriel Exp $ */
17 /************************************************************************
18 * No checking is performed, except for division by zero. *
19 * The operands popped from the stack are put in unsigned *
20 * longs. Now the required operation can be performed *
21 * immediately. Whether the wordsize is two or four bytes *
22 * doesn't matter. Alas, arithmetic is performed modulo *
23 * the highest unsigned number for the given size plus 1. *
24 ************************************************************************/
30 #define adu(w1,w2) (unsigned long)(w1 + w2)
31 #define sbu(w1,w2) (unsigned long)(w1 - w2)
32 #define mlu(w1,w2) (unsigned long)(w1 * w2)
34 PRIVATE unsigned long dvu(), rmu(), slu(), sru();
40 register unsigned long t = upop(arg_wi(l));
42 LOG(("@U6 DoADU(%ld)", l));
44 npush((long) adu(upop(l), t), l);
50 /* SBU w: Subtraction */
51 register unsigned long t = upop(arg_wi(l));
53 LOG(("@U6 DoSBU(%ld)", l));
55 npush((long) sbu(upop(l), t), l);
61 /* MLU w: Multiplication */
62 register unsigned long t = upop(arg_wi(l));
64 LOG(("@U6 DoMLU(%ld)", l));
66 npush((long) mlu(upop(l), t), l);
73 register unsigned long t = upop(arg_wi(l));
75 LOG(("@U6 DoDVU(%ld)", l));
77 npush((long) dvu(upop(l), t), l);
83 /* RMU w: Remainder */
84 register unsigned long t = upop(arg_wi(l));
86 LOG(("@U6 DoRMU(%ld)", l));
88 npush((long) rmu(upop(l), t), l);
94 /* SLU w: Shift left */
95 register unsigned long t = uwpop();
97 LOG(("@U6 DoSLU(%ld)", l));
100 npush((long) slu(upop(l), t, l), l);
106 /* SRU w: Shift right */
107 register unsigned long t = uwpop();
109 LOG(("@U6 DoSRU(%ld)", l));
112 npush((long) sru(upop(l), t, l), l);
115 PRIVATE unsigned long dvu(w1, w2)
116 unsigned long w1, w2;
119 if (!(IgnMask&BIT(EIDIVZ))) {
127 PRIVATE unsigned long rmu(w1, w2)
128 unsigned long w1, w2;
131 if (!(IgnMask&BIT(EIDIVZ))) {
140 PRIVATE unsigned long slu(w1, w2, nbytes) /* w1 << w2 */
141 unsigned long w1, w2;
146 /* check shift distance */
147 if (w2 >= nbytes*8) {
154 /* calculate result */
159 PRIVATE unsigned long sru(w1, w2, nbytes) /* w1 >> w2 */
160 unsigned long w1, w2;
165 /* check shift distance */
166 if (w2 >= nbytes*8) {
173 /* calculate result */