Question: ------------------------------------------------------ C programming coding problem. Assembly related. It seems long but not. most parts are introductive steps/examples. Please read carefully and ONLY FULL ANSWERS (BOTH

 ------------------------------------------------------ C programming coding problem. Assembly related. It seems long butnot. most parts are introductive steps/examples. Please read carefully and ONLY FULL

------------------------------------------------------

C programming coding problem. Assembly related.

It seems long but not. most parts are introductive steps/examples.

Please read carefully and ONLY FULL ANSWERS (BOTH TASK 1 &2 PLEASE) will get positive rate.

Thank you.

you need to write some code, that actually does the same thing like the CPU. You code would get some instructions one by one from the memory, parse it and execute it. Your simulation should have the followings: 4 registers (name it as acc0, acc1,acc2,acc3 and it could be integer type) . One Memory o This would include both the instructions and the data The format of your instruction would be very simple. Total size of the instruction would be 16 bits. First 4 bits tells you the opcode,next 2 bits would tell you the register, and the rest 10 bits would tell you the operands (so, Memory size would be 2110). One example of the instruction would be: 0011000000001000 Say in your code, 0011 represents load operation. Then what the total instruction is doing: load the content of memory location 0000001000 (which is actually 8), to the acco (register bit is 00) So the sample pseudo code for this would be: opcode binaryToDecimal (substr(0,3): register - binaryToDecimal(substr(4,5); operand -binaryToDecimal(substr(6,15)); Select acc based on the register value if(opcode3)//decimal of binary 0011 is3 acc Memory[operand] you need to write some code, that actually does the same thing like the CPU. You code would get some instructions one by one from the memory, parse it and execute it. Your simulation should have the followings: 4 registers (name it as acc0, acc1,acc2,acc3 and it could be integer type) . One Memory o This would include both the instructions and the data The format of your instruction would be very simple. Total size of the instruction would be 16 bits. First 4 bits tells you the opcode,next 2 bits would tell you the register, and the rest 10 bits would tell you the operands (so, Memory size would be 2110). One example of the instruction would be: 0011000000001000 Say in your code, 0011 represents load operation. Then what the total instruction is doing: load the content of memory location 0000001000 (which is actually 8), to the acco (register bit is 00) So the sample pseudo code for this would be: opcode binaryToDecimal (substr(0,3): register - binaryToDecimal(substr(4,5); operand -binaryToDecimal(substr(6,15)); Select acc based on the register value if(opcode3)//decimal of binary 0011 is3 acc Memory[operand]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!