Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
Simple Assembly Interpreter
I need to submit screenshots and make sure there is no error
Simple Assembly Interpreter
Develop a simple assembly code interpreter for a theoretical processor with the following properties.
This processor only has seven instructions:
lod imm32 ; Load a 32-bit immediate valuelod mem32 ; Load a 32-bit value from memoryadd imm32 ; Add a 32-bit immediateadd mem32 ; Add a 32-bit value from memorysub imm32 ; Subtract a 32-bit immediatesub mem32 ; Subtract a 32-bit value from memorysto mem32 ; Stores the result into a single memory locationYou can assume this simple processor has only one register and 256 32-bit memory locations. Your simple assembler will given an array containing instructions and will convert the instructions into x86 code on the fly. You should be able to do this through a combination of C and inline assembly. The only parts that have to be in assembly are the code elements for the above instructions. For instance, a lodinstruction could become a mov eax instruction.
The mem32 addresses are in terms of bytes. For instance, an address of 0x10 would refer to the 17th byte, or the 5th integer (0 based index).
Immediate values are hex numbers without a 0x in front. Memory address are hex numbers with the 0x in front.
char *linesOfCode[] = { "lod 0x10", // mem32, hex value "add 1010", // imm32, hex value "sub 11", // imm32, hex value "sto 0x14" // mem32, hex value };As noted, your project can use a combination of C and assembly. You can use C string processing functions from the C standard library.
Your function should look like the following:
int simpleAssembler(char** linesOfCode, int lineCount, int* memory);linesOfCode is an array of strings containing the code lines you are to execute. memory is a 256 element 32-bit integer array that is given to you. lineCount is the count of the number of lines in the linesOfCodearray.
simpleAssembler should return a -1 if an error has occurred and 0 otherwise.