-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.h
35 lines (32 loc) · 1.01 KB
/
utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef UTILITY_H
#define UTILITY_H
#include <string.h>
#include "data.h"
#include "instr.h"
#include "error_helper.h"
#include "memory_constants.h"
#include "debug.h"
#include "interrupt.h"
#include <stdio.h>
#include <stdlib.h>
// Macro to flush stdin
#define FLUSH_STDIN(x) {if (x[strlen(x)-1] != '\n') {do fgets(Junk,16,stdin); while (Junk[strlen(Junk)-1] != '\n'); } else x[strlen(x) - 1] = '\0';}
char Junk[16]; // buffer for discarding excessive user input,
// used by "FLUSH_STDIN" macro
/*
* Gets the instruction pointed by IP, to the argument
* Return 0 on success
* Returns -1 on error after setting IP to exception handler
*/
int getInstruction(char *);
void emptyPage(int page_no);
struct address translate (int virtual_addr);
int getInteger(char* str );
void storeInteger(char *str, int num);
int getType(char* str);
int isSafeState();
Exception isSafeState2();
char * resolveOperand(int r, int flag1, int flag2, char * string);
Exception isRegisterInaccessible(int);
void raiseException(Exception);
#endif