BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | 159.102 Technical Programming 2 Assignment 3

C语言代写 | 159.102 Technical Programming 2 Assignment 3

这个作业是编写一个模拟“ Brookshear Machine”的C程序

159.102 Technical Programming 2  Assignment 3

Where PC is the program counter, INST is the current instruction and R0 through to RF are the value of the sixteen registers. Each field is output as a 2 or 4 digit hexadecimal value (use the X format specifier to get capital letters) with a leading 0 if necessary.

Output continues (with no user intervention) until the Halt instruction is executed, at which time your program also stops.

A Halt instruction will occur in all test programs.

Example: if a3.txt contains:

B404

239A

2412

5345

350C

C000

Then the output is:

00 B404 – [00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]

04 2412 – [00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]

06 5345 – [00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00]

08 350C – [00 00 00 00 12 12 00 00 00 00 00 00 00 00 00 00]

0A C000 – [00 00 00 00 12 12 00 00 00 00 00 00 00 00 00 00]

Use unsigned char‘s for your PC, registers and memory.

When reading the a3.txt file, be careful with alignment problems in the scanf-like functions. First read each line into an unsigned int variable, then extract out the two bytes using bit-wise operators and store them in your memory array.

Brookshear machine instructions

         1RXY           Load register R with the value at memory address XY

2RXY           Load register R with the value XY

3RXY           Store the value in register R at memory address XY

40RS       Copy/move the value in register R to register S

5RST       Add the values in registers R and S and put the answer in register T

7RST       Bit-wise OR the values in registers R and S and put the answer in                       register T

8RST       Bit-wise AND the values in registers R and S and put the answer in                       register T

9RST       Bit-wise XOR the values in registers R and S and put the answer in                       register T

AR0X           Rotate the contents of register R   X times to the right

BRXY           Jump to the instruction located at memory address XY if the value in                    register R is equal to the value in register 0 (i.e. change the PC to XY)

C000       Halt

bestdaixie

评论已关闭。