solution

Create a C++ software to the COMPUTER machine (below). The software must be given a text file containing COMPUTER machine code instructions as input (Hexadecimal numbers). Your application then simulates the machine functioning, adjusting the values of entry and position locations as needed by working through the machine code instructions (in the correct order). You must create proper output that aids a client. You must create adequate output to help a machine code coder understand what is happening with the machine code instructions. Program counter, instructions entry, values of recently changed entry, and values of recently changed position locations should all be shown. Make sure you read all of the parts below.

Note: this program must have unless 2 functions.

5EZQ = Is not require. Don’t execute that instruction

Your program must use the following global variables:

int position [256];

int entry [16];

int co; // program counter

int ie; // instruction entry

Ex.1) Data in .txt file: “code.txt”

11FC

1211

7020

6012

4007

E000

First output:

Type the txt file: “code.txt”

Second output could be like below:

Position[0] = 11FC //LOAD E1 with FC

Position[1] = 1211 // LOAD E2 with 11

Position[2] = 7020 //NEGATE E2 (i.e. R2 changes to -11)

Position[3] = 6012 // E0 = E1 + E2

Position[4] = 4007 //STORE the contents of E0 into position location 07

Position[5] = E000 // STOP

11FC E1 = FC CO = 1

1211 E2 = 11 CO = 2

7020 E2 = -11 CO = 3

6012 E0 = E1 + E2 CO = 4

4007 Position[07] = EB CO = 5

E000 = STOP

Ex. 2 Data of txt file: “code1.txt”

3508

3609

6056

400A

E000

First output:

Type the txt file: “code1.txt”

Second output could be like below:

Position[0] = 3508 //LOAD E5 with the number in position location 08

Position[1] = 3609 // LOAD E6 with the number in position location 09

Position[3] = 6056 // E0 = E5 + E6

Position[4] = 400A //STORE the contents of E0 into position location 0A

Position[5] = E000 // STOP

3508 E5 = 08 CO = 1

3609 E2 = 09 CO = 2

6056 E0 = E5 + E6 CO = 3

400A Position[0A] = 11 CO = 4

E000 = STOP

EX.3 of instruction

1113 //LOAD E1 with 13 (19 in decimal)

1212 //LOAD E2 with 12 (18 in decimal)

7020 //NEGATE E2 (E2 is now -18)

6312 //E3 = E1 + E2

1480 //LOAD E4 with 80

9408 //SHIFT E4 LEFT 8 bits (2 hex digits = 8 bits) (E4 is now 8000)

A534 //E5 = E3 AND E4 (E5 will be zero if E3 is positive)

1000 //LOAD E0 with 00

D50B // JUMP to position location 0B if E5 == E0 (i.e. if E3 is positive)

1101 //LOAD E1 with 01

D00C //JUMP to position location 0C if E0 == E0 (an unconditional jump)

1102 //LOAD E1 with 02 (this instruction is in position location 0B)

410E //STORE the contents of E1 into postion location 0E (this instruction is in postition location 0B)

E000 //stop

INSTRUCTION COMPUTER MACHINE

1EXY Load entry E with the value XY.

e.g. 1213 means load entry E2 with the hexadecimal number 13 (19 in decimal).

20EZ Load entry E with the number in entry Z.

e.g. 20A7 means load entry E10 with the number in entry E7.

3EXY Load entry E with the number in the position location at address XY.

e.g. 34AB means load entry E4 with the contents from position location AB

4EXY Store the number in entry E in the position location at address XY.

e.g. 45B1 means to store the contents of entry E5 in the position location B1

5EZQ Add the numbers in entry Z and Q and load the result into entry E. Don’t execute that instruction

e.g. 534E means add the numbers in E4 and E14 and load the result into E3.

6EZQ Add the numbers in entry Z and Q and load the result into entry E.

Note: this is integer addition using 2’s complement arithmetic.

e.g. 6823 means add the contents of E2 and E3 and load the result into E8.

70E0 Negate entry E. (Carry out complement and add 1 – in effect, multiply E with -1)

e.g. 70A0 means multiply the number in E10 by -1.

8E0X Shift the number in entry E to the right X times.

e.g. 8403 means that the number in E4 must be shifted 3 bits to the right.

9E0X Shift the number in entry E to the left X times.

e.g. 9602 means that the number in E6 must be shifted 2 bits to the left.

AEZQ AND the numbers in entry Z and Q and load the result into entry E.

e.g. A045 means AND the numbers in E4 and E5 and load the result into E0.

BEZQ OR the numbers in entry Z and Q and load the result into entry E.

e.g. BC74 means OR the numbers in E7 and E4 and load the result into E12.

CEZQ XOR the numbers in entry Z and Q and load the result into entry E.

e.g. C5F3 means XOR the numbers in E15 and E3 and load the result into E5.

DEXY Jump to the instruction at address XY if the value in entry E is equal

to the value in entry E0.

e.g. D43C means the following: (a) compare the contents of E4 with E0.

(b) if they are equal load 3C into the program counter.

E000 stop

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!