Question

Write an embedded (continuous input) e-LMC little man program using bubble sort. Zero to end. Constant...

Write an embedded (continuous input) e-LMC little man program using bubble sort. Zero to end. Constant registers ( R0 = 0, R1 = 1, R2 = 2, R3 = 999)?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANS:-

Algorith for extended Little Man Computer Program (E-LMC):-

Load the three values into registers R0-R2

// loop 1 step 1
if R1-R0>0
do nothing
else // swap using a temp register
temp=R1
R1=R0
R0=temp
end if
// loop 1 step 2
if R2-R1>0
do nothing
else // swap using a temp register
temp=R2
R2=R1
R1=temp
end if
// loop 2 step 1
if R1-R0>0
do nothing
else // swap using a temp register
temp=R1
R1=R0
R0=temp
end if

Write registers in order: R0,R1,R2.

---------------------

INP //read 1st value
STA 0 // for store
INP // read 2nd value
   STA 1 // store
INP // read 3rd value
STA 2 // store
LDA 1 // LOOP 1, STEP 1:
    SUB 0 //
BRP STEP2 // if R0 and R1 are in order, don't swap them
LDA 1 // Begin swapping registers
STA 3   
LDA 0
STA 1 // R1 = R0
LDA 3
STA 0 //R0 = temp
STEP2 LDA 2 // LOOP 1, STEP 2
SUB 1
BRP STEP3 // If R1 and R2 are in order, don't swap them
LDA 2 // Begin swapping registers
STA 3 // temp =R2
LDA 1
STA 2 //R2=R1
   LDA 3
STA 1 // R1 = temp
STEP3 LDA 1 // LOOP 2, STEP 1
SUB 0
BRP STEP4 // if R0 andR1 are in order, don't swap them
LDA 1 // Begin swapping registers
STA 3 // temp = R1
LDA 0
STA 1 //R1=R0
LDA 3
STO 0 // R0 = temp

STEP4 LDA 0
OUT
   LDA 1
   OUT
LDA 2
OUT
   HLT

Add a comment
Know the answer?
Add Answer to:
Write an embedded (continuous input) e-LMC little man program using bubble sort. Zero to end. Constant...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program in Java that obtains the execution time of selection sort, insertion sort, bubble...

    Write a program in Java that obtains the execution time of selection sort, insertion sort, bubble sort, merge sort, quick sort, and radix sort. Your program should test all sort methods for input sizes of 10000, 20000, 30000, 40000, 50000, and 60000. The selection sort, bubble sort, and radix sort should also be tested for input sizes 100000 and 200000. Your program should create the data that is sorted from randomly generated integers and should output the results in a...

  • Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and...

    Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and Insertion Sort. The numbers to be sorted will be obtained using a library function which generates pseudo-random numbers. TO Do 1. Fill an array with 140 real numbers between 0.00 and 945.00. Generate the numbers using the subroutine that generates random numbers. Make a spare copy of the array; you will need it later. 2. Call a subroutine to print the contents of the...

  • Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers

    Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...

  • Create MIPS program that sorts positive numbers. Inputs the numbers until a zero is inputted and the program displays the sorted numbers. Can use any sorting algorithm except bubble sort.

    Write a MIPS assembly program that sorts a sequence of positive integersentered from the console (one number in one line). The end of thesequence is indicated by a 0 (zero). Verify that the program is correct bysimulation. You can use any sorting algorithm in your code except bubblesort, such as selection sort, merge sort, quick sort, etc. There must be aprocedure call as well as looping in your code. use recursive procedurecalls instead of looping to solve the same problem....

  • Objective: 1. Understand sorting algorithm 2. Implement bubble sort in C++ Check slides for a template...

    Objective: 1. Understand sorting algorithm 2. Implement bubble sort in C++ Check slides for a template of the solution, if you need Write a program that asks users to input 10 integers into an array, write a function that takes the array as its argument, use bubble sort to sort the array and output the sorted array in increasing order. #include <iostream> using namespace std; C:IWINDOWSSystems2cmd.exe lease input 10 integers: void bubblesort(int a[10]) int help; int b[10]; for (int i...

  • You will create a dimple Bubble Sort program to sort a string of random integers or...

    You will create a dimple Bubble Sort program to sort a string of random integers or text. Please read instructions and examples Please show screenshot of proof that the code works in the C program ECE 216 Programming Project 2 The Bubble Sort You will create a simple Bubble Sort program to sort a string of random integers or text or whatever you can punch in from the keyboard. For the input data, you will input a string of single...

  • . For the following operations in the ARC tool program bellow 11. (10 pts) For the...

    . For the following operations in the ARC tool program bellow 11. (10 pts) For the following operations in the ARCTool program below: the instruction he is defined in table 4, 10 as branch equal ( the instruction bu is defined as branch always: ) Write the instruction the program jumps to when be here+4 branches on the 1st pass through the code? Answer a. b. Write the instruction the program jumps to when ba here-4 completes its branch? Answer...

  • For the cubic equation , where a, b, c and d are real input coefficients. Write...

    For the cubic equation , where a, b, c and d are real input coefficients. Write a MATLAB function root.m of the form: function [largestRoot] = root(a, b, c, d) % a: Coefficient of x^3 % b: Coefficient of x^2 % c: Coefficient of x % d: Coefficient of 1 % largestRoot: The largest real root of the cubic to find the largest real root of this equation accurate to within a relative error using any methods such as Newton's,...

  • Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method.

     Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. Your program should output the words and their frequencies (the number of times each word appears in the file) without any duplicates. Ex: If the input is: inputl.csv and the contents of input1.csv are: hello, cat, man, hey, dog, boy, Hello, man, cat, woman, dog, Cat, hey, boy the output is: hello 1 cat 2 man...

  • Write a java program: Create a method fillRandom() that accepts an array of int as input...

    Write a java program: Create a method fillRandom() that accepts an array of int as input and populates it with random numbers in the range -999 to 1000 Explicitly store zero in index [0] and 900 in index [1]. (0 and 900 will be used as search keys) Create a method DisplayLastInts() that accepts an array of int as input and displays the last hundred elements to the screen in rows of 10 elements. Format the output so the 10...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT