Language:EN
Pages: 4
Words: 433
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
assembler c code example assignment answers

Assembler C Code Example Assignment Answers

Your 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 that comprises any combination of the following six (7) assembly instructions:

movl Immediate, Register

mulq  immediate,register

Notes:

student submitted image, transcription available below

Assignment Help Answers with Step-by-Step Explanation:

#include <stdio.h>

};

// Function to get the register code

    return -1; // Invalid register

}

    int numItems = sscanf(instruction, "%s %s, %s", op, operand1, operand2);

    if (numItems == 3) {

                // Generate machine code for movl

                printf("Machine code for 'movl %s, %s'\n", operand1, operand2);

                // Your code generation logic here

            } else if (strcmp(op, "addq") == 0) {

                printf("Syntax Error\n");

            }

        printf("Syntax Error\n");

    }

        "movl $42, rax",

        "movq rdi, rsi",

        "invalid_instruction",

    };

}

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : ocelyn

PageId: DOC8E1E4D3