0

anybody help this C programming language convert to x64 assembly language if please, write x64 assembly code in reply. thank you

int sum(int n, int *a){
    int s = 0;
    for (int i = 0; i < n; i++)
    s += a[i];
    return s;
}

int main(void){
    int A[] = {
        1,2,3,4,5,6,7,8,9,10
        };
    printf("sum = %d\n", sum(10, A));
    return 0;
}
  • 5
    It looks like you want us to write some code for you. While many users are willing to produce code for a coder in distress, they usually only help when the poster has already tried to solve the problem on their own. A good way to demonstrate this effort is to include the code you've written so far, example input (if there is any), the expected output, and the output you actually get (output, tracebacks, etc.). The more detail you provide, the more answers you are likely to receive. Check the FAQ and [ask]. – Paul R Dec 21 '19 at 07:31
  • 1
    One way to approach this is to look at [compiler output](https://godbolt.org/z/xcwKgC). – Paul R Dec 21 '19 at 07:39
  • 1
    I'm voting to close this question as off-topic because this is not a code conversion service. – machine_1 Dec 21 '19 at 07:56

1 Answers1

1

Just compile it and open it with a debugger or an assembly editor/viewer.

You can compile it using(assuming your source file is named main.c:

gcc main.c - o main

and disassemble it e.g. with objdump:

objdump -d main

Or, as @David C. Rankin pointed out in the comments, you can compile it to assembly:

gcc -S -O2 -masm=intel -o main.asm main.c

and view the file main.asm

See https://stackoverflow.com/a/5125914/10871900

dan1st
  • 12,568
  • 8
  • 34
  • 67