Convert the following code in to ARM assembly language.
Triple Max
// Return max of three variables
int max(int a, int b, int c) {
// Fill in your own code for this function
}
int main() {
// Use registers for local variables
int x = 10;
int y = 5;
int z = 20;
int max = max(x, y, z);
printf("max = %d\n", max);
return 0;
}
program
pushl %eax
pushl %ecx
pushl %edx
pushl $5
pushl $4
pushl $3
call add3
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %esi
pushl %edi
subl $4, %esp
movl 8(%ebp), %eax
addl 12(%ebp), %eax
addl 16(%ebp), %eax
movl %eax, -16(%ebp)
movl -16(%ebp), %eax
movl -12(%ebp), %edi
movl -8(%ebp), %esi
movl -4(%ebp), %ebx
movl %ebp, %esp
popl %ebp
ret
addl $12, %esp
movl %eax, wherever
popl %edx
popl %ecx
popl %eax
Convert the following code in to ARM assembly language. Triple Max // Return max of three...
MIPS assembly language Covert this code to MIPS: #include <stdio.h> int function (int a) int main)i int x=5 ; int y: y function(x); printf "yd",y); return 0; int function (int a) return 3*a+5; Assumptions: . Place arguments in $a0-$a3 . Place return values in $vO-$v1 Return address saved automatically in $ra . lgnore the stack for this example. (Thus, the function will destroy registers used by calling function
Given the following C Code segment convert it to ARM assembly. Assume the following register assignment have been made before your section of code begins. C Variable Register assignment r1 y r2 r3 r10 j r11 int x=0, y=0, z=0; int main() { for (int i = 0; i<10; i++) for (int j 0; j < 20; j++) if (i* j > 100) X++; if (i j >= 15) y++; + فہه Z = X + y; }
(d) (20 points) Convert the following C code to ARM assembly. And indicate the HEX values of the Stack and Data sections in the table below. Note: you do not necessary have to fill in each blank space in the table. Address Value ーC Code int Arr [ ]= {2, 13, 5); int main (void) 0xFFFFFFFC StackOxFFFFFFF8 int Sum; Sum-Ar[0]+A+2*Arr[2] return 0 OxFFFFFFF4 0XFFFFFFFO | 0x0001000C Data Ox00010008 0x00010004 000010000 5 point (d) (20 points) Convert the following C code...
Please convert this C function into ARM ASSEMBLY LANGUAGE CORTEX M (Must be cortex m) #include<stdio.h> int ascii(char c) { return (int)c; } int computeMagicNumber(char* name) { int sum, i; //varibales sum = 0; //set sum to 0 //calculate sum int N = sizeof(name)/sizeof(name[0]); //get name size for(i=0;i<N;i++) sum = sum + (i+1)*ascii(name[i]); return sum%1001; //return magic number MAIN FUNCTION : extern int computeMagicNumber(char *); int main(void) { char name[255]="Yusuf Ozturk"; int magic; magic=computeMagicNumber(name); printf("\n Magic number is %d\n",magic); return...
How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...
PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to: -define a recursive procedure/function and call it. -use syscall operations to display integers and strings on the console window -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9 if n <= 5 =...
Translate the High order language program to assembly language and generate PEP9 assembly language code. #include <stdio.h> int main() { int number; scanf(“%d”,&number ); if (number <0) { number =- number; } printf ("%d", number); return0; }
Implement the functionality of "main" function for the following C code in MIPS assembly. Comment your code including which registers represent the variables in the main function. Include the .data and the .text sections. Do not write the bit_count function. int main() { int count = 149; int num = 432; if (count + num > 534){ count = bit_count(num); printf("%d bits to store the number", count); }else{ printf("cannot count bit in %d",) } }
NEED HELP WITH THIS . Write a MARIE assembly language program that would simulate calling and executing the following C function, as shown below: z = someFunction(a, b); where z, a and b are main( ) program variables, and the values stored in a and b are input by the user. The value stored in z will be output. Did your program execute correctly? This is the code for the function: int someFunction(int x, int y) { return 3 *...
Convert this C++ language to PEP/8 assembly language. #include <stdio.h> int main(void) { int num, rem; printf("Enter a number: "); scanf("%d", &num); printf("Roman numerals: "); while(num != 0) { if (num >= 1000) // 1000 - m { printf("m"); num -= 1000; } else if (num >= 900) // 900 - cm { printf("cm"); num -= 900; } else if (num >= 500) // 500 - d { printf("d"); num -= 500; } else if (num >= 400) // 400 - cd { printf("cd"); num -= 400; } else if (num >= 100) // 100 - c { printf("c"); num -= 100; } else if (num >= 90) // 90 - xc { printf("xc"); num -= 90; } else if (num >= 50) // 50 - l { printf("l"); num -= 50; } else if (num >= 40) // 40 - xl { printf("xl"); num -= 40; } else if (num >= 10) // 10 - x { printf("x"); num -= 10; } else if (num >= 9) // 9 - ix { printf("ix"); num -= 9; } else if (num >= 5) // 5 - v { printf("v"); num -= 5; } else if (num >= 4) // 4 - iv { printf("iv"); num -= 4; } else if (num >= 1) // 1 - i { printf("i"); num -= 1; } } return 0;}