-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopcodes.h
More file actions
54 lines (45 loc) · 1.38 KB
/
opcodes.h
File metadata and controls
54 lines (45 loc) · 1.38 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef OPCODES_H
#define OPCODES_H
#define LINUX
#include <stdint.h>
#include <stdio.h>
typedef uint16_t uint16;
#ifdef WIN32
#include "windows.h"
#elif defined(__linux__)
#include "linux.h"
#endif
void handle_interrupt(int signal);
uint16 mem_read(const uint16 mem_address);
void mem_write(const uint16 address, uint16 reg);
uint16 sign_extend(uint16 x, int bit_count);
void update_flags(const uint16 r);
void load_args(int argc, const char* argv[]); //load arguments
// reading image file
int read_image(const char* image_path);
uint16 swap16(uint16 x);
void read_image_file(FILE* file); // reads lc-3 program into memory
// TRAP OPERATIONS
void GETC();
void OUT();
void PUTS();
void IN();
void PUTSP();
void HALT();
// operations
void BAD(); // bad opcode
void ADD(uint16 instruction); // add
void AND(uint16 instruction); // bitwise and
void NOT(uint16 instruction); // bitwise not
void BR(uint16 instruction); // brach
void JMP(uint16 instruction); // jump
void JSR(uint16 instruction); // jump to register
void LD(uint16 instruction); // load
void LDI(uint16 instruction); // load indirect
void LDR(uint16 instruction); // load register
void LEA(uint16 instruction); // load effective address
void ST(uint16 instruction); // store
void STI(uint16 instruction); // store indirect
void STR(uint16 instruction); // store register
void TRAP(uint16 instruction, int* running); // trap operations
#endif