Menu

[Solved]Cppsh 83bxg Code Know Mistake Q37282100

We will be emulating (modeling) a microcontroller datapath in this programming project. The microcontroller has a simple setWhen the processor is initialized, all ten registers and all 1000 memory addresses contain 000. The first instruction executeADD ADD STORE HALT R2, R3 RO.R1 M[RO]. R2 Il store the sum back into Mt191 ne interesting thing that we can do now is to actu
cpp.sh/83bxgthis is my codecan I know what is my mistake?We will be emulating (modeling) a microcontroller datapath in this programming project. The microcontroller has a simple set of instructions, 10 registers, and a 1000-word memory. All words stored by the registers and memory are integers from 0-999 Instructions are also 3-digit integers from 0-999 with the following format: Rd RS (or #n The instruction set is as follows: Operation HALT GOTO Rd LDI Rd,#n ADD Rd, Rs MULT Rd, Rs LOAD Rd, MIRs Description Stops execution Jumps to instruction located at MIRd Loads the number n into register Rd Adds the values in Rd and Rs and stores them in Rd Multiplies the values in Rd and Rs and stores them in Rd Takes the value stored in memory at address Rs, and Rd es it into STORE M[Rd], Rs Takes the value stored in the register Rs and saves it to location given by Rd the Any other opcodes are “NOPs” (no-operations) and have no effect on the microcontroller other than to advance to the next instruction. For example, the program: 219 would load R1 with 9 and then halt. The second command would have no effect. For HALT and GOTO instructions, the operands not used are ignored. Therefore 000 has the same effect as 082. All immediate values (#n) must be between 0-9 All of the numbers handled by this process have a maximum value of 999. If any operation (such as multiply) produces a number greater than 999, the register rolls over That is, if the operation returns 1008, the value stored would be “8.” If the operation returns 2013, the value stored would be “13.” Your datapath should never break. Calling loadMemory (120999, 987123); would not return an error, rather it would store 123 in memory location 999. The worst thing that could happen to your datapath would be if it never encounters a “HALT” instruction, in which case it should go into an infinite loop. When the processor is initialized, all ten registers and all 1000 memory addresses contain 000. The first instruction executed is always at memory location 0. load 3 into RO and 8 into R1, then place the sum of the two into RI A simple program to is as follows: LDI R0, #3 LDI R1,#8 ADD RI, R2 HALT RO-3 R1-8 /RI-3+8-11 The encoding of these instructions would be 203 218 A program to load 3 into RO and 8 into Rl, then place the sum of the two in R2 withou overwriting the values in RO and RI is as follows: LDI R0, #3 LDI R1, #8 LDI R2, #0 ADD R2, RO ADD R2, R1 HALT The encoding for this program would be: 203 218 220 320 321 The load and store instructions are for directly accessing memory. Often, we may have more data than will fit into the registers (there are only 10). Or, we may have data stored in memory that we wish to load into registers, process, then store back. For example, if we wish to read the three values at memory location 16, 17, and 18, find their sum, and store it in location 19, we could execute the following: Example 1: Summing three memory values LDI ADD LDI LOAD RO, #8 RO, RO R1, #1 R2, MIRO] RO, R1 R3, MRO] R2, R3 RO, R1 R3, MIRO) I/ RO now-16 /R1-1 / R2 now has value stored at address 16 //RO now = 17 LOAD ADD II R2-M[16]+M[17 ADD LOAD ADD ADD STORE HALT R2, R3 RO.R1 M[RO]. R2 Il store the sum back into Mt191 ne interesting thing that we can do now is to actually alter our own code as we go along. Consider the following code: Example 2: Self-Modifying Program LDI LDI ADD MULT LDI LDI STORE M[R3], R MI7]-100 (which is also “GOTO RO”) R1, #9 R2, #1 R1, R2 R1, Rl R0, #9 R3, #7 IR2-1 /RI-1010-100 IR3-7 2 4 IlU this instruction overwritten w/ GOTO RO) ll never executed Il jumped to by Instruction 7 7 R3, R3 MULT HALT Your Task: You are to implement a class called Datapath that will simulate the microcontroller datapath described above. It has the same functionality and interface as the Datapath skeleton. epp code posted, and you are free to use this file to get started You should create your own test coding files to verify your complete design. Once you are convinced that your program is working properly, run it using the three test files testl.txt, test2.txt, and test3.txt. Print out the final register results for each of these three tests and attach them to your source code Note: All stored values in registers and in memory are within the range 0-999. You should check all intermediate results to make sure they are in this range before storing them in registers or memory. Show transcribed image text We will be emulating (modeling) a microcontroller datapath in this programming project. The microcontroller has a simple set of instructions, 10 registers, and a 1000-word memory. All words stored by the registers and memory are integers from 0-999 Instructions are also 3-digit integers from 0-999 with the following format: Rd RS (or #n The instruction set is as follows: Operation HALT GOTO Rd LDI Rd,#n ADD Rd, Rs MULT Rd, Rs LOAD Rd, MIRs Description Stops execution Jumps to instruction located at MIRd Loads the number n into register Rd Adds the values in Rd and Rs and stores them in Rd Multiplies the values in Rd and Rs and stores them in Rd Takes the value stored in memory at address Rs, and Rd es it into STORE M[Rd], Rs Takes the value stored in the register Rs and saves it to location given by Rd the Any other opcodes are “NOPs” (no-operations) and have no effect on the microcontroller other than to advance to the next instruction. For example, the program: 219 would load R1 with 9 and then halt. The second command would have no effect. For HALT and GOTO instructions, the operands not used are ignored. Therefore 000 has the same effect as 082. All immediate values (#n) must be between 0-9 All of the numbers handled by this process have a maximum value of 999. If any operation (such as multiply) produces a number greater than 999, the register rolls over That is, if the operation returns 1008, the value stored would be “8.” If the operation returns 2013, the value stored would be “13.” Your datapath should never break. Calling loadMemory (120999, 987123); would not return an error, rather it would store 123 in memory location 999. The worst thing that could happen to your datapath would be if it never encounters a “HALT” instruction, in which case it should go into an infinite loop.
When the processor is initialized, all ten registers and all 1000 memory addresses contain 000. The first instruction executed is always at memory location 0. load 3 into RO and 8 into R1, then place the sum of the two into RI A simple program to is as follows: LDI R0, #3 LDI R1,#8 ADD RI, R2 HALT RO-3 R1-8 /RI-3+8-11 The encoding of these instructions would be 203 218 A program to load 3 into RO and 8 into Rl, then place the sum of the two in R2 withou overwriting the values in RO and RI is as follows: LDI R0, #3 LDI R1, #8 LDI R2, #0 ADD R2, RO ADD R2, R1 HALT The encoding for this program would be: 203 218 220 320 321 The load and store instructions are for directly accessing memory. Often, we may have more data than will fit into the registers (there are only 10). Or, we may have data stored in memory that we wish to load into registers, process, then store back. For example, if we wish to read the three values at memory location 16, 17, and 18, find their sum, and store it in location 19, we could execute the following: Example 1: Summing three memory values LDI ADD LDI LOAD RO, #8 RO, RO R1, #1 R2, MIRO] RO, R1 R3, MRO] R2, R3 RO, R1 R3, MIRO) I/ RO now-16 /R1-1 / R2 now has value stored at address 16 //RO now = 17 LOAD ADD II R2-M[16]+M[17 ADD LOAD
ADD ADD STORE HALT R2, R3 RO.R1 M[RO]. R2 Il store the sum back into Mt191 ne interesting thing that we can do now is to actually alter our own code as we go along. Consider the following code: Example 2: Self-Modifying Program LDI LDI ADD MULT LDI LDI STORE M[R3], R MI7]-100 (which is also “GOTO RO”) R1, #9 R2, #1 R1, R2 R1, Rl R0, #9 R3, #7 IR2-1 /RI-1010-100 IR3-7 2 4 IlU this instruction overwritten w/ GOTO RO) ll never executed Il jumped to by Instruction 7 7 R3, R3 MULT HALT Your Task: You are to implement a class called Datapath that will simulate the microcontroller datapath described above. It has the same functionality and interface as the Datapath skeleton. epp code posted, and you are free to use this file to get started You should create your own test coding files to verify your complete design. Once you are convinced that your program is working properly, run it using the three test files testl.txt, test2.txt, and test3.txt. Print out the final register results for each of these three tests and attach them to your source code Note: All stored values in registers and in memory are within the range 0-999. You should check all intermediate results to make sure they are in this range before storing them in registers or memory.

Expert Answer


Answer to cpp.sh/83bxgthis is my code can I know what is my mistake?… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *