-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.h
121 lines (101 loc) · 2.94 KB
/
variables.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// Created by Ilya on 31.03.2018.
//
#ifndef TEST_3_VARIABLES_H
#define TEST_3_VARIABLES_H
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
typedef unsigned char byte;
typedef unsigned short int word;
typedef word adr;
int N, Z, V, C;
// N indicating a negative value
// Z indicating a zero (equal) condition
// V indicating an overflow condition, and
// C indicating a carry condition.
unsigned int schet; // счётчик выполненных команд
#define ostat mem[0177564]
#define odata mem[0177566]
typedef union s_byte{
char sby;
unsigned char uby;
} s_byte;
typedef union s_word{
short int si;
unsigned short int ui;
} s_word;
typedef union un_int{
unsigned int ui;
int si;
} un_int;
typedef struct vozvr{
word val;
word adr;
} vozvr;
typedef struct nom{
char * load[10];
word start;
} nom;
vozvr DST;
vozvr SRC;
s_byte xx;
s_word yy;
s_word zz;
word src, dst;
FILE * f;
int t; // для трассировки
int std; // режим вывода
int eight; // вывод восьмеричного кода
byte mem[64 * 1024];
word reg[8];
/*
* 0-5 - Стандартные регистры
* 6 - Stack Pointer
* 7 - Program Counter
*/
typedef struct adr_n { // для возврата адреса и числа байтов из
adr ad; // из f_load_file
unsigned int n;
} adr_n;
typedef struct comm {
word B;
word d_s_op; // 2 if comm is double-operand, 1 if single, 0 if no operand
word pc_mode_src; // program counter addressing mode
word pc_mode_dst;
word opcode14_12;
word opcode11_9;
word opcode10_6;
word opcode10_8;
byte offset;
word st_mode; // stack addressing mode
word reg1; // first register ( [0;7] if needed)
word reg2; // second register ( [0;7] if needed)
} command;
byte b_read(adr a); // читает из "старой памяти" mem байт с "адресом" a.
void b_write(adr a, byte val); // пишет значение val в "старую память" mem в байт с "адресом" a.
word w_read(adr a); // читает из "старой памяти" mem слово с "адресом" a.
void w_write(adr a, word val); // пишет значение val в "старую память" mem в слово с "адресом" a.
int load_file();
adr_n *f_load_file(FILE * fi);
void mem_dump(adr start, word n);
void f_mem_dump(adr start, word n, char* s);
int take_mnem(word comm);
int do_command(word comm);
command take_com(word x);
void print_all();
void print_all_std();
void f_mem_dump(adr start, word n, char* s);
void f_mem_dump_1(adr start, word n, char* s);
vozvr take(word ad_mode, word regi, word B);
word read(adr a, word B);
nom nom_flags(char * str);
typedef struct func{
word msk; // mask
word opc; // opcode
int (*instr)(command com); //указателль на функцию
} func;
func func_list[100];
#endif //TEST_3_VARIABLES_H