00001 #ifndef __FIELD_H__ 00002 #define __FIELD_H__ 00003 00004 /* 00005 * field.h - simple field manipulation functions to get students working 00006 * with masking. This will be used in the simulator to extract 00007 * information when executing an LC3 instruction. It may also be 00008 * used in the assembler to "create" the 16 bit LC3 instructions. 00009 * If an assignment involving floating point manipulation (e.g. 00010 * 16 bit floating point addition), this file can be used to 00011 * provide support routines for extracting/setting the sign, 00012 * exponent, and mantissa fields. 00013 * 00014 * "Copyright (c) 2012 by Fritz Sieker." 00015 * 00016 * Permission to use, copy, modify, and distribute this software and its 00017 * documentation for any purpose, without fee, and without written 00018 * agreement is hereby granted, provided that the above copyright notice 00019 * and the following two paragraphs appear in all copies of this software, 00020 * that the files COPYING and NO_WARRANTY are included verbatim with 00021 * any distribution, and that the contents of the file README are included 00022 * verbatim as part of a file named README with any distribution. 00023 * 00024 * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, 00025 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00026 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR 00027 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 * 00029 * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT 00030 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00031 * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 00032 * BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, 00033 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00034 */ 00035 00116 int getField (int value, int hi, int lo); 00117 00124 int getFieldSignExtended (int value, int hi, int lo); 00125 00135 int setField (int oldValue, int hi, int lo, int newValue); 00136 00137 #endif