Question: 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:

movlImmediate, Register

movq Register, Register

addq [Memory], Register

addl Immediate,[Memory]

iImulw Register,Register

mulq immediate,register


Notes:

    1. 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.
    2. 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
    3. 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:
    4. 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.
  1. 55 89 5 8b 45 0c 03 45 08 89 ec 5d 

 

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

3.40 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets break down the problem and create a C program that acts as a miniassembler for x8664 instructio... View full answer

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 Operating System Questions!