-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEmulator_Claims.txt
163 lines (103 loc) · 4.56 KB
/
Emulator_Claims.txt
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*****************************************************************************
TITLE: Claims
AUTHOR: Sunny Chaturvedi
ID: 1801CS54
Declaration of Authorship
This txt file, claims.txt, is part of the assignment of CS321 - CS322 at the
department of Computer Science and Engg, IIT Patna .
*****************************************************************************/
==========
Files:
==========
*All the files I submitted, emu.cpp and Emulator_Claims.txt, have my name and student id at the start, along with a declaration of authorship.
The evidence for Assembler including the output files from the test examples has also been uploaded.
All the test files have been tested and work properly.
All .o files are to be run
They are tested and run properly.
=========================
Compilation instructions:
=========================
Windows:
g++ emu.cpp -o emu
emu <insert_file_name>.o
Ubuntu:
g++ emu.cpp -o emu
./emu <insert_file_name>.o
Footnote:
* Input files(the .o file) must be present in the same folder where the code is executed
=============================
Program format and structure:
=============================
1. The emulator:
* The emulator is interactive and can run single or multiple instructions according to user's input.
* Assumes that set and data insrtuctions will be written only after halt statement and should never be run else can produce ambigious results.
* Error handling: Throws error if instruction with invalid opcode comes, Throws error is segmentation fault occurs.
* Functionalities:
- Single trace: Performs a single operation and shows current register values. ( Command: -t )
- Multiple trace: Performs a given number of operations and shows current register values. ( Command: -t 10 (Here 10 has the value in decimal))
- Full program trace: Performs all remaining operations. ( Command: -f )
- Memory dump: Shows current memory dump i.e. data values at all PC values(total PC = number of instructions) ( Command: -bd )
- Show data: Displays the contents of given data location ( Command: -data 0xFF (Here the data has to be inputted as hexadecimal) )
- After memory dump: Performs all the instructions in a program and then dumps the final memory. ( Command: -ad )
- Show future instructions: Displays instructions written after current pc (displays at max 10 future instructions). ( Command: -u )
===========================================
Testing: (using a windows machine)
===========================================
The emulator:
I have tested four examples shown as below.
1)
#Input:
emu sum.o
#Output:
write -bd to see before memory dump
Before Dump:
00000010 FFFFFB01 FFFFEE10 00000012 00000001
00000014 00000002 00000003 00000004 00000005
To complete whole program and see final memory write "-ad"
After Dump :
00000010 FFFFFB01 FFFFEE10 00000012 00000001
00000014 00000002 00000003 00000004 00000005
00000018 0000000F
Output has the current sum value at location 0x18 with value 0x0000000F ( which is the sum of all values from 0x13 to 0x17 )
2)
#Input:
emu max.o
#Output:
write -bd to see before memory dump
Before Dump:
00000018 00000012 0000000A 00000002 FFFFFFFD
0000001c 00000004 00000032 00000000 00000000
To complete whole program and see final memory write "-ad"
After Dump:
00000018 00000012 0000000A 00000002 FFFFFFFD
0000001c 00000004 00000032 00000032 00000005
Output has the current maximum value at location 0x1e with value 0x00000005 ( which is the maximum of all values from 0x19 to 0x1d )
3)
#Input:
emu min.o
#Output:
write -bd to see before memory dump
Before Dump:
0000001c FFFFE710 00000012 0000000A 00000002
00000020 FFFFFFFD 00000004 00000032 00000000
To complete whole program and see final memory write "-ad"
After Dump:
0000001c FFFFE710 00000012 0000000A 00000002
00000020 FFFFFFFD 00000004 00000032 FFFFFFFD
Output has the current maximum value at location 0x23 with value 0xFFFFFFFD ( which is the minimum of all values from 0x1e to 0x22 )
4)
#Input:
emu bubblesort.o
#Output:
write -bd to see before memory dump
Before Dump:
0000004c 00000032 00000005 00000002 00000001
00000050 00000008 00000001 00000001 00000003
00000054 00000004 00000007 00000007
These are the 10 array values
To complete whole program and see final memory write "-ad"
After Dump :
0000004c 00000032 00000008 00000007 00000007
00000050 00000005 00000004 00000003 00000002
00000054 00000001 00000001 00000001
Here we can see that the array values are sorted in decreasing order.