Use the CCS IDE to implement and debug 3 different versions of programs Listings
ID: 3755258 • Letter: U
Question
Use the CCS IDE to implement and debug 3 different versions of programs Listings 4.2 thru 4.6 . The 3 different versions of each program are as follows
1. As An Assembly-Only Program (As given in book)
2. As a C program using in-line assembly
3. As a C-only Program (use inline assembly on some parts ONLY if needed)
isting 4.2 Usage of Data Processing and Memory Access Instructions text align 2 MemAddr field 0x20000040; Memory address BitBandAddr field 0x22000810: Bit-band address global main main Data moving instructions MOV R0, #09h; R0-0x09 MOV R1, #11d; R1 0x0B MOV R2, #00001010b; R1 . 0x0A Memory access instructions LDR R3, MemAddr STR R2, R3 STR R1, [R3, #41; LDR RO, R31 PUSH (R3) POP (R4) Bit-band operation LDR RS, BitBandAddri LDR RG, RS) STR R6, [RS) Porever loop endExplanation / Answer
import java.util.Arrays;
public class BuggySearchAndSort {
public static void main(String[] args) {
int[] A = new int[10];
for (int i = 0; i < 10; i++)
A[i] = 1 + (int)(10 * Math.random());
int[] B = A.clone();
int[] C = A.clone();
int[] D = A.clone();
System.out.print("The array is:");
printArray(A);
if (contains(A,5))
System.out.println("This array DOES contain 5.");
else
System.out.println("This array DOES NOT contain 5.");
Arrays.sort(A);
System.out.print("Sorted by Arrays.sort(): ");
printArray(A);
bubbleSort(B);
System.out.print("Sorted by Bubble Sort: ");
printArray(B);
selectionSort(C);
System.out.print("Sorted by Selection Sort: ");
printArray(C);
insertionSort(D);
System.out.print("Sorted by Insertion Sort: ");
printArray(D);
}
public static boolean contains(int[] array, int val) {
for (int i = 0; i < array.length-1; i++) {
if (array[i] == val){
return true;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.