can some one help me with this please? Part 1 (15 pts): Write an assembly progra
ID: 3598478 • Letter: C
Question
can some one help me with this please?
Part 1 (15 pts): Write an assembly program to sort the letters in a string from Z to A. You may use any sorting algorithm you wish, but using a bubble sort is highly recommended. (See http:len.wikipedia.org/wikiBubble_sort for information on how it works.) Use DC.B (or similar) to allocate memory for the letters: z, A, C, E. B, S. L. Your program must also find the MIDDLE letter and the MAXIMUM letter (i.e. the last letter in the string following sorting). As an example, if you are given the string ckEkge, your sort algorithm should return Egkkec, sorting capital lelters first, then lower-case letters. Part 2 (S pts): List the bits of the CCR following the completion of your program As a tip, write your program in Motorola 68K assembly, and test it in your Easy68K simulator. This can assist you in making sure that your program works cormectly.Explanation / Answer
package com;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
public class ListExample extends JFrame
{
BufferedReader br = null;
FileReader fr = null;
List<String> ListA=new ArrayList<String>();
List<String> ListE=new ArrayList<String>();
List<String> ListI=new ArrayList<String>();
List<String> ListO=new ArrayList<String>();
List<String> ListU=new ArrayList<String>();
DefaultListModel<String> l1 = new DefaultListModel<>();
DefaultListModel<String> l2 = new DefaultListModel<>();
DefaultListModel<String> l3 = new DefaultListModel<>();
DefaultListModel<String> l4 = new DefaultListModel<>();
DefaultListModel<String> l5 = new DefaultListModel<>();
JFrame f= new JFrame();
private JButton jButton1 = new JButton("Add");
ListExample(){
try{
fr = new FileReader("D:\test.txt.txt");
br = new BufferedReader(fr);
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
if(sCurrentLine.charAt(0)=='A' || sCurrentLine.charAt(0)=='a'){
System.out.println("A : " + sCurrentLine);
ListA.add(sCurrentLine);
}
else if(sCurrentLine.charAt(0)=='E' || sCurrentLine.charAt(0)=='e'){
System.out.println("E : " + sCurrentLine);
ListE.add(sCurrentLine);
}
else if(sCurrentLine.charAt(0)=='I' || sCurrentLine.charAt(0)=='i'){
System.out.println("I : " + sCurrentLine.charAt(0));
ListI.add(sCurrentLine);
}
else if(sCurrentLine.charAt(0)=='O' || sCurrentLine.charAt(0)=='o'){
System.out.println("O : " + sCurrentLine.charAt(0));
ListO.add(sCurrentLine);
}
else if(sCurrentLine.charAt(0)=='U' || sCurrentLine.charAt(0)=='u'){
System.out.println("U : " + sCurrentLine.charAt(0));
ListU.add(sCurrentLine);
}
}
JList<String> list1 = new JList<>(l1);
JList<String> list2 = new JList<>(l2);
JList<String> list3 = new JList<>(l3);
JList<String> list4 = new JList<>(l4);
JList<String> list5 = new JList<>(l5);
list1.setBounds(30, 35, 115, 200);
f.add(list1);
list2.setBounds(180, 35, 110, 195);
f.add(list2);
list3.setBounds(330, 35, 100, 195);
f.add(list3);
list4.setBounds(460, 30, 95, 200);
f.add(list4);
list5.setBounds(590, 35, 110, 190);
f.add(list5);
jButton1.setSize(70,20);
jButton1.setVisible(true);
jButton1.setText("Add");
f.add(jButton1);
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
f.setSize(816, 537);
f.setLayout(null);
f.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)
br.close();
if (fr != null)
fr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
private void jButton1_actionPerformed(ActionEvent e) {
System.out.println("Click Me");
for(String str:ListA){
l1.addElement(str);
}
for(String str:ListE){
l2.addElement(str);
}
for(String str:ListI){
l3.addElement(str);
}
for(String str:ListO){
l4.addElement(str);
}
for(String str:ListU){
l5.addElement(str);
}
JList<String> list1 = new JList<>(l1);
JList<String> list2 = new JList<>(l2);
JList<String> list3 = new JList<>(l3);
JList<String> list4 = new JList<>(l4);
JList<String> list5 = new JList<>(l5);
list1.setBounds(30, 35, 115, 200);
f.add(list1);
list2.setBounds(180, 35, 110, 195);
f.add(list2);
list3.setBounds(330, 35, 100, 195);
f.add(list3);
list4.setBounds(460, 30, 95, 200);
f.add(list4);
list5.setBounds(590, 35, 110, 190);
f.add(list5);
}
public static void main(String args[])
{
new ListExample();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.