Answer:
MIPS Assembly Language Code:
.zero 1
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], 0
mov DWORD PTR [rbp-8], 10
mov DWORD PTR [rbp-12], 100
mov edx, DWORD PTR [rbp-12]
mov ecx, DWORD PTR [rbp-8]
mov eax, DWORD PTR [rbp-4]
mov esi, ecx
mov edi, eax
call isSorted(int, int, int)
mov DWORD PTR [rbp-16], eax
cmp DWORD PTR [rbp-16], 0
jne .L2
mov edx, DWORD PTR [rbp-4]
mov ecx, DWORD PTR [rbp-8]
mov eax, DWORD PTR [rbp-12]
mov esi, ecx
mov edi, eax
call isSorted(int, int, int)
.L2:
mov eax, 0
leave
ret
isSorted(int, int, int):
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
mov DWORD PTR [rbp-12], edx
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-8]
jge .L5
mov eax, DWORD PTR [rbp-8]
cmp eax, DWORD PTR [rbp-12]
jge .L5
mov eax, 1
jmp .L6
.L5:
mov eax, 0
.L6:
pop rbp
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L9
cmp DWORD PTR [rbp-8], 65535
jne .L9
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
Convert the following program into MIPS Instructions: int a = 0; int b = 10; int...
Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) { if( j < 10) { a = 0; } else { a = 1;} } else { a = 2; }
How do i convert the following C program into MIPS assembly? int main(void) { short var1[4] ={5, 8, 13, 6}; short var2[4]= {16, 4, 7, 15}; short result[4]={0}; for (int i=0 ; i< 4; i++) result[i] = var1[i] - var2[i]; }
Convert the following C code into ARM int foo(int a, int b) { int result = 0; int i; for (i = 20; i <= 30; i++) { if (i == 24) result += 20; else if (i == 27) result = result * 2; else result = result + a + 3*b; } return result; }
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2; B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...
Convert the following high-level language into MIPS instructions. Please write comments for each instructions. Assume a, b, c, d are associated with registers $s0, $s1, $s2, $s3, respectively. void main () { int a = 10, b = 20; int c = add(a, b); int d = sub(a, b); swap (a, b); } int add( int var1, int var2) { return (var1 + var2); } int sub(int var1, int var2) { return (var1 - var2); } void swap(int var1, int...
1. (a) Convert the following C function to the corresponding MIPS assembly procedure: int count(int a[], int n, int x){ int res = 0; int i = 0; for(i = 0; i != n; i++) if(a[i] == x) res = res + 1; return res; } Cannot use converter need hard copy!!!
C to MIPS Conversion C variable h i j k x int a[] or &a[0] MIPS register replacement $s0 $s1 $s2 $s3 $s4 $a0 Translate to MIPS. DO NOT USE pseudo MIPS instructions (e.g., BGE). Answer MUST use true 32-bit MIPS instructions: if(j < k ) a[j] = 1; else j = a[j];
C2. Convert the following c-code to MIPS code. The base memory address of the array a is 0x8000_400C, which must be loaded in the base register Ss0. Register assignments: int a[10]; while (i !- 10) 1 if ( i%2 == 0) a[i] = i * 2; else ail - i* 3 i++i C2. Convert the following c-code to MIPS code. The base memory address of the array a is 0x8000_400C, which must be loaded in the base register Ss0. Register...
For C to MIPS Conversion C variable h i j k x int a[] or &a[0] MIPS register replacement $s0 $s1 $s2 $s3 $s4 $a0 Translate to MIPS. No credit for pseudo-MIPS instructions (e.g., BGE). The answer MUST use true 32-bit MIPS instructions: if(j < k ) a[j] = 1; else j = a[j];
For C to MIPS Conversion h i u. k х C variable int a[] or &a[0] $50 $51 $52 $s3 $54 $a0 MIPS register replacement Translate to MIPS. No credit for pseudo MIPS instructions (e.g., BGE). Answer MUST use true 32-bit MIPS instructions: if(j <k) a[j] = 1; else j = a[j];