Added variable and constant to common.retro module
[retro.git] / toka / bits.c
blobc87674414268857131ea7aeaf0394365df25d604
1 /******************************************************
2 * Toka
4 *|F|
5 *|F| FILE: bits.c
6 *|F|
8 * Copyright (c) 2006, 2007 Charles R. Childers
10 * Permission to use, copy, modify, and distribute this
11 * software for any purpose with or without fee is hereby
12 * granted, provided that the above copyright notice and
13 * this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
16 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
19 * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
22 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
23 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE.
25 ******************************************************/
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
31 #include "toka.h"
32 extern VM_STACK data, address, alternate;
36 /******************************************************
37 *|G| << ( ab-c ) Shift 'a' left by 'b' bits
39 *|F| lshift()
40 *|F| Shift NOS left by TOS bits
41 *|F|
42 ******************************************************/
43 void lshift()
45 NOS = NOS << TOS; DROP;
49 /******************************************************
50 *|G| >> ( ab-c ) Shift 'a' right by 'b' bits
52 *|F| rshift()
53 *|F| Shift NOS right by TOS bits
54 *|F|
55 ******************************************************/
56 void rshift()
58 NOS = NOS >> TOS; DROP;
62 /******************************************************
63 *|G| and ( ab-c ) Perform a bitwise AND
65 *|F| and()
66 *|F| Perform a bitwise AND
67 *|F|
68 ******************************************************/
69 void and()
71 NOS = TOS & NOS; DROP;
75 /******************************************************
76 *|G| or ( ab-c ) Perform a bitwise OR
78 *|F| or()
79 *|F| Perform a bitwise OR
80 *|F|
81 ******************************************************/
82 void or()
84 NOS = TOS | NOS; DROP;
88 /******************************************************
89 *|G| xor ( ab-c ) Perform a bitwise XOR
91 *|F| xor()
92 *|F| Perform a bitwise XOR
93 *|F|
94 ******************************************************/
95 void xor()
97 NOS = TOS ^ NOS; DROP;