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 
140 int getField (int value, int hi, int lo, bool isSigned);
141 
151 int setField (int oldValue, int hi, int lo, int newValue);
152 
159 int fieldFits (int value, int width, bool isSigned);
160 
161 #endif
int clearBit(int value, int position)
int setField(int oldValue, int hi, int lo, int newValue)
int fieldFits(int value, int width, bool isSigned)
int setBit(int value, int position)
int getBit(int value, int position)
int getField(int value, int hi, int lo, bool isSigned)