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-15 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  *
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
22  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
23  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR
24  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
29  * BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
31  */
32 
33 #include <stdbool.h>
34 
113 bool fieldFits (int value, int width, bool isSigned);
114 
120 int getBit (int value, int index);
121 
133 int getField (int value, int hi, int lo, bool isSigned);
134 
143 int setBit (int oldValue, int index, int newValue);
144 
154 int setField (int oldValue, int hi, int lo, int newValue);
155 
156 #endif
int setField(int oldValue, int hi, int lo, int newValue)
Definition: field.c:36
bool fieldFits(int value, int width, bool isSigned)
Definition: field.c:16
int setBit(int oldValue, int index, int newValue)
Definition: field.c:31
int getBit(int value, int index)
Definition: field.c:21
int getField(int value, int hi, int lo, bool isSigned)
Definition: field.c:26