Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is wrong with the bubble sort assembly 68k program START ORG $400 * Your sorting code starts here LEA LIST,A0 MOVE.W COUNT,D1 ;get number

What is wrong with the bubble sort assembly 68k program

START ORG $400 * Your sorting code starts here LEA LIST,A0 MOVE.W COUNT,D1 ;get number of elements SUBI.W #1, D1 ;adjust count for passes (outer loop) DOPASS MOVE.W D1, D4 ;init loop counter/comparisons MOVEA.L COUNT, A0 ;init data pointer CHECK MOVE.B (A0), D2 ;get first element MOVE.B 1(A0), D3 ;get second element CMP.B D2, D3 ;compare elements BCC NOSWAP ;if D3 > D2 (unsigned) MOVE.B D2,1(A0) ;swap elements MOVE.B D3,(A0) NOSWAP ADDA.L #1,A0 ;point to next pair SUBI.W #1,D4 ;decrement loop counter BNE CHECK SUBI.W #1,D1 ;decrement pass counter BNE DOPASS

RTS * Your sorting code ends here * * Code to output data in the list to the Output Window * (Do not modify code below this point!) MOVE.B COUNT,D7 Size of the array LEA LIST,A0 A0 references the array LOOP MOVE.B (A0)+,D1 Put value to display into D1 EXT.W D1 Sign extend D1 to word EXT.L D1 and then to longword MOVE #3,D0 Task number 3 (display [D1]) TRAP #15 Display [D1] BSR NEWLINE Display "/n" SUB #1,D7 BNE LOOP * STOP #$2700 *---------------------------------------------------- * Subroutine to display Carriage Return and Line Feed * (Do not modify!) *---------------------------------------------------- NEWLINE MOVEM.L D0/A1,-(A7) Push D0 & A1 MOVE #14,D0 Task number 14 (diplay null-ended string) LEA CRLF,A1 Put address of string in A1 TRAP #15 Display return, linefeed MOVEM.L (A7)+,D0/A1 Restore D0 & A1 RTS Return * *----------------------------------------------------------------- * Data Section * Comment current and uncomment next data set for a different test *----------------------------------------------------------------- ORG $1000 * Data 1 COUNT DC.B 4 LIST DC.B 2,9,5,3 * Data 2 * COUNT DC.B 8 * LIST DC.B 1,2,5,4,7,5,4,2 * Data 3 * Count DC.B 9 * List DC.B 82,73,64,55,46,37,28,4,2 * To be completed by you * Data 4 * COUNT DC.B 9 * LIST DC.B 1,-5,2,5,0,3,5,7,-1 * Data 5 * COUNT DC.B 10 * LIST DC.B 1,2,3,4,5,6,7,8,9,10 * * Do not change the following CRLF DC.B $D,$A,0 Carriage return & line feed, null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

how would you have done things differently?

Answered: 1 week ago