Question

In: Computer Science

in MARIE simulator, write assembly language to BUBBLE SORT 30 hexadecimals store in two array.

in MARIE simulator, write assembly language to BUBBLE SORT 30 hexadecimals store in two array.

Solutions

Expert Solution

Org 100

JnS ldArr
JnS in
JnS sort
JnS out

Halt

//sort array
sort, Hex 0
sl2, JnS ldArr
   Load N
   Subt c1
   Store N
sl1, Load swapped//zero swapped flag
   Subt swapped
   Store swapped  
   LoadI ArrL
   Store temp
   Load ArrL
   Add c1
   Store ArrL
   LoadI ArrL
   Subt temp
   Skipcond 800
   JnS swap
   Load N
   Subt c1
   Store N  
   Skipcond 400//test N
   Jump sl1
   Load Size//reset N
   Subt c1
   Store N
   Load swapped//end if nothing swapped
   Skipcond 400
   Jump sl2
   JumpI sort

//swap curent and previous
swap,   Hex 0
   Load swapped
   Add c1
   Store swapped
   LoadI ArrL
   Store temp2
   Load temp  
   StoreI ArrL
   Load ArrL
   Subt c1
   Store ArrL
   Load temp2
   StoreI ArrL
   Load ArrL
   Add c1
   Store ArrL
   JumpI swap

//input N and N values
in,   Hex 0
   Input
   Store Size
Loop, Store N
   Input
   Output
   StoreI ArrL
   Load ArrL
   Add c1
   Store ArrL
   Load N
   Subt c1
   Skipcond 400
   Jump Loop
   Store ArrL
   load Arr
   jumpI in

//output array
out,   Hex 0
   JnS ldArr  
ol, LoadI ArrL
   Output
   Load ArrL
   Add c1
   Store ArrL
   Load N
   Subt c1   
   Store N
   Skipcond 400
   Jump ol
   JumpI out

//reset N and ArrL pointer
ldArr,   Hex 0
   Load Size
   Store N
l, Load Arr
   Load l
   Subt H1000
   Store ArrL
   JumpI ldArr

Size, Dec 5

c1, Dec 1
H1000, Hex 1000

ArrL, Dec 0
N, Dec 0
swapped, Dec 0   //flag if swapped
temp, Hex 0   //temps for swapping
temp2, Hex 0

Arr,   Dec 0
   Dec 0
   Dec 0
    Dec 0
   Dec 0


Related Solutions

Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The...
Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The parity checker should repeatedly execute a loop that performs the following tasks: 1. Ask the user for an input X, which can be any printable ASCII character from Table 1; 2. Output the decimal code of X; 3. Output the total number of 1’s that appears in the binary code of X; 4. Output the parity bit which, when added to the binary code...
ASSEMBLY PROGRAM!!! QtSpim Sorting Data Add the Bubble Sort to minMaxArray.asm to sort the array into...
ASSEMBLY PROGRAM!!! QtSpim Sorting Data Add the Bubble Sort to minMaxArray.asm to sort the array into ascending order. Use the Bubble Sort algorithm from the lecture. You can use either Base Addressing or Indexed Addressing for the arrays. For this assignment, make sure you prompt the user for the numbers. Do not hard-code them in the data section. NOTE: Declare the array last in the Data section.
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that...
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that sorts the array below in ascending order.  LISP is a recursive language so the program will use recursion to sort. Since there will be no loops, you will not need the variables i, j, and temp, but still use the variable name array for the array to be sorted.             Array to be sorted is 34, 56, 4, 10, 77, 51, 93, 30, 5, 52 The...
(code in C++ language) [Code Bubble sort, Insertion sort Create a Big array with random numbers....
(code in C++ language) [Code Bubble sort, Insertion sort Create a Big array with random numbers. Record the time. Run Bubble Check time (compute the processing time) do it 100 times (random numbers) Take the average Insertion: Compare] (some explanations please)
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality:...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality: Configures pin RA2 of the PIC24to be an output to control an attached LED. Configures pin RB13 of the PIC24 to be an input to read the value on an attached switch (this switch will connect to ground when pressed). Configures pin RB13 to use the internal pull-up resistor. After configuration, the LED will be "off" when the push-button is pressed, and "on" when...
Using the MARIE computer assembly language, write a program that computes the following expression: z =...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. Note: If any of the...
5. (20 marks) Write a recursive Bubble Sort algorithm that takes an array A of n...
5. Write a recursive Bubble Sort algorithm that takes an array A of n numbers as input. Analyze its time complexity using a recursion tree. Implement your algorithm in Java
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that in array. Display that all numbers before and after performing Bubble sort. You must have to create new function with required parameter to perform Bubble sort. Sample Run :- Enter 1 number :- 1 Enter 2 number :- 5 Enter 3 number :- 7 Enter 4 number :- 45 Enter 5 number :- 90 Enter 6 number :- 6 Enter 7 number :- 55...
Using x86 assembly language, create a flowchart and write an example of code that will sort...
Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is...
Write a sequence of assembly language instructions to subtract each entry of an array A of...
Write a sequence of assembly language instructions to subtract each entry of an array A of five two’s complement 16-bit binary integers from the corresponding entry of an array B of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4, -5 B: 25, -5, -30, 6, 10 please answer in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT