util.h
Go to the documentation of this file.
1 #ifndef __UTIL_H__
2 #define __UTIL_H__
3 
4 /*
5  * "Copyright (c) 2012-2016 by Fritz Sieker."
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation for any purpose, without fee, and without written
9  * agreement is hereby granted, provided that the above copyright notice
10  * and the following two paragraphs appear in all copies of this software.
11  *
12  * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
13  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
14  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR
15  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16  *
17  * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
20  * BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
21  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
22  */
23 
34 #include <stdbool.h>
35 
36 #include "lc3.h"
37 
39 typedef struct name_val {
40  char* name;
41  int val;
42 } name_val_t;
43 
53 name_val_t* util_bin_search (name_val_t map[], int numNames, const char* name);
54 
61 opcode_t util_get_opcode (const char* name);
62 
70 bool util_is_valid_label(const char* s);
71 
79 int util_get_reg (const char* regStr);
80 
90 int util_parse_cond (const char* condCodeStr);
91 
100 bool util_get_int (const char* token, int* value);
101 
102 #endif
int util_get_reg(const char *regStr)
Definition: util.c:63
struct name_val name_val_t
opcode_t util_get_opcode(const char *name)
Definition: util.c:36
Definition: util.h:39
enum opcode opcode_t
bool util_is_valid_label(const char *s)
Definition: util.c:41
int util_parse_cond(const char *condCodeStr)
Definition: util.c:69
name_val_t * util_bin_search(name_val_t map[], int numNames, const char *name)
Definition: util.c:31
char * name
Definition: util.h:40
int val
Definition: util.h:41
definitions of the LC3 instruction set architecture (ISA) (do not modify)
bool util_get_int(const char *token, int *value)
Definition: util.c:74