Home / Expert Answers / Computer Science / need-python-code-for-following-requirement-1-instruction-decoding-and-disassembling-40-marks-th-pa460

(Solved): Need python code for following Requirement 1 - Instruction Decoding and Disassembling: 40 Marks Th ...



Need python code for following Requirement 1 - Instruction Decoding and Disassembling: 40 Marks
The first requirement will be to develop a program which is

Requirement 1 - Instruction Decoding and Disassembling: 40 Marks The first requirement will be to develop a program which is capable of decoding ARM based instructions from their native form (machine code) and displaying these as Assembly language instructions. This should result in the development of a computer program which has the ability to fetch, decode and display the instructions within the nrovided instruction set. One key aspect you will have to consider is how the instructions will be defined and read by your program. The op-codes should be stored in your virtual RAM (or ROM if you decide to include such a feature). However these codes need to get into the virtual machine somehow. Initially you may want to consider hard-coding some simple instructions for testing purposes. Later you may decide to load the instructions from a file. As the program is executing it should display the original op-code value along with the assembly language equivalent. For example, given the following machine code hexadecimal op-codes - to the following. Requirement 2 - Basic Emulation: 30 Marks The second requirement of the assignment is to extend the implementation so that as well as displaying each Assembly language instruction it should also emulate the behaviour of these. i.e. implement a basic CPU emulator. For this requirement only the basic ALU type instructions need to be supported, e.g. ADD, SUB, CMP, MOV. Also conditional execution of each instruction does NOT yet need to be supported. In order to achieve this you will need to create variables to represent the internal "state" of the CPU. For example, you will need to be able to store the current contents of each of the 16 registers. It is recommended that all registers are initially set to 0 (except R13 which should be set to the top of stack position). As the program is executing it should display the same output as requirement 1 , plus the contents of each of the sixteen registers. This way the correct execution of each instruction I will be verifiable. It may be a good idea to pause between each instruction and wait until the user presses the enter key before proceeding. For example -


We have an Answer from Expert

View Expert Answer

Expert Answer



I'm happy to help with your assignment! However, since the requirements you provided are quite extensive, I won't be able to provide a complete Python code solution in this text box. However, I can give you some guidance on how to approach each requirement.

Requirement 1 - Instruction Decoding and Disassembling:
To decode ARM instructions from machine code to assembly language instructions, you can use a table of opcodes and their corresponding assembly language instructions. You can read in the machine code instructions from a file, and then use bitwise operations to extract the opcode and any associated operands. You can then use the opcode to look up the corresponding assembly language instruction in your table and print out the result.
Here's some example code for how you might define your opcode table in Python:



PLEASE REFER THIS STEP AND FOLLOW THE NEXT

 

We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe