Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C programs that operates like a mini-assembler for an x86-64 processor. The program would generate the machine code corresponding to any assembly code
Write a C programs that operates like a mini-assembler for an x86-64 processor. The program would generate the machine code corresponding to any assembly code that comprises any combination of the following six (7) assembly instructions:
movl Immediate, Register
movq Register, Register
addq [Memory], Register
addl Immediate,[Memory]
iImulw Register,Register
mulq immediate,register
Notes:
- The registers can only be rdi (and derivatives), rsi(and derivatives), rax(and derivatives. Also, [Memory] is the content of memory pointed by one of these three registers.
- Your program shall be written in such a way that only one assembly instruction is written in one line. One or several lines can be inserted between instructions
- The output of your program shall display in each line the machine code corresponding to one single instruction only. Remember that the x86-86 processor is a CISCO processor. Example of Display:
- Your program shall display the message “Syntax Error” for any instruction which has a syntax error. For instance, mulq $14, %eax has a syntax error.
55 89 5 8b 45 0c 03 45 08 89 ec 5d c3 8d 76 00 This corresponds to the 1st instruction This corresponds to the 2nd instruction
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started