My Project
field.h
Go to the documentation of this file.
1 #ifndef __FIELD_H__
2 #define __FIELD_H__
3 
4 /*
5  * field.h - simple field manipulation functions to get students working
6  * with masking. This will be used in the simulator to extract
7  * information when executing an LC3 instruction. It may also be
8  * used in the assembler to "create" the 16 bit LC3 instructions.
9  * If an assignment involving floating point manipulation (e.g.
10  * 16 bit floating point addition), this file can be used to
11  * provide support routines for extracting/setting the sign,
12  * exponent, and mantissa fields.
13  *
14  * "Copyright (c) 2013 by Fritz Sieker."
15  *
16  * Permission to use, copy, modify, and distribute this software and its
17  * documentation for any purpose, without fee, and without written
18  * agreement is hereby granted, provided that the above copyright notice
19  * and the following two paragraphs appear in all copies of this software,
20  * that the files COPYING and NO_WARRANTY are included verbatim with
21  * any distribution, and that the contents of the file README are included
22  * verbatim as part of a file named README with any distribution.
23  *
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
25  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
26  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR
27  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
32  * BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
33  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
34  */
35 
107 #include <stdbool.h>
108 
114 int getBit (int value, int position);
115 
121 int setBit (int value, int position);
122 
128 int clearBit (int value, int position);
129 
143 int getField (int value, int hi, int lo, bool isSigned);
144 
154 int setField (int oldValue, int hi, int lo, int newValue);
155 
162 int fieldFits (int value, int width, bool isSigned);
163 
164 #endif
int clearBit(int value, int position)
Definition: field.c:27
int setField(int oldValue, int hi, int lo, int newValue)
Definition: field.c:37
int fieldFits(int value, int width, bool isSigned)
Definition: field.c:42
int setBit(int value, int position)
Definition: field.c:22
int getBit(int value, int position)
Definition: field.c:17
int getField(int value, int hi, int lo, bool isSigned)
Definition: field.c:32