ARM CODE:- (ARM GCC 8.2)
Arr:
.word 2
.word 13
.word 5
main:
str fp, [sp, #-4]!
add fp, sp, #0
sub sp, sp, #12
ldr r3, .L3
ldr r2, [r3]
ldr r3, .L3
ldr r3, [r3, #4]
add r2, r2, r3
ldr r3, .L3
ldr r3, [r3, #8]
lsl r3, r3, #1
add r3, r2, r3
str r3, [fp, #-8]
mov r3, #0
mov r0, r3
add sp, fp, #0
ldr fp, [sp], #4
bx lr
.L3:
.word Arr
(d) (20 points) Convert the following C code to ARM assembly. And indicate the HEX values of the ...
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; }
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...
its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-); (40%) Convert the following C-pseudo code into MIPS assembly code...
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; }
Convert the following code to assembly MIPS void checki() { int i = 0; while(i < 10) { switch(i) { case 1: i += 5; break; case 2: i --; break; case 3: i += 2; break; default: i++; } } } void main() { checki(); }
Convert the C++ Source code into Assembly Language (MASM) Code: int sum = 0, k = 1; while ( k < = 20 ) { if ( k % 2 == 0 ) sum + = k; k++; }
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...
Write a MIPS assembly code that corresponds to the following C code. Note: use the stack to store all register values that you use in the procedures. int aver(int * array, int N){ int i, sum = 0; for ( i=0;i i<N; i++) sum += array[i]; return sum/N;} int Max( int * array, int N){ int i, Maximum = array[i]; for ( i = 1; i< N; i++) if ( array[i] > Maximum) Maximum = array[i]; return Maximum; } int...
In the blank below, write the contents of array arr after the following code is executed up to the comment indicated in the main procedure below? #include <iostream> #include <algorithm> using namespace std; void do something(int list[], const int size); int main() { const int SIZE(10); int arr[SIZE] = { 5, 8, 1, 7, 3, 9, 4, 6, 10, 2 }; do somethingCarr, SIZE); ** Write the contents of array arr in the space below when execution reaches here. */...
Implement the following code using ARM instructions. //Objective to practice on procedure, push and pop. int a=3,b=6,c=2,d=5; /* use registers to store values in global variables*/ main { checkEvenfun() sunFun() } checkEvenfun() { Check if the register have even numbers if odd replace with 0. Push values in stack. } sunFun(){ Pop from stack find the sum }