It is currently Mon Jul 06, 2020 11:30 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Nov 11, 2012 5:57 pm 

Joined: Sun Nov 11, 2012 8:39 am
Posts: 1
Location: Rochester
I have a problem with M68 K sorting an array in ascending order:

Here it part of the problem:
* Program Number:
* Written by    :
* Date Created  :
* Description   :
START   ORG   $1000
* My sorting code starts here: 

MOVE.W #4,D1                      *load loop counter for list
LEA   LIST , A0                      *A0 points to beginning of LIST

FOR MOVE.W (A0), +, D0                *A0 points to next item on list
DBRA       D1,FOR                           *GO AROUND LOOP AGAIN
* My sorting code ends here
* Code to output data in the list to the Output Window
* Only modify the first two lines for a different test case
   MOVE.B   COUNT,D2   Change it for another array
   LEA   LIST,A0      Change it for another 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,D2
   STOP   #$2700

* Subroutine to display Carriage Return and Line Feed
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
   ORG   $2000
COUNT   DC.B   4
LIST   DC.B   2,1,5,4
COUNT1   DC.B   8
LIST1   DC.B   1,2,5,4,8,5,4,2
Count2   DC.B   9
List2   DC.B    10,9,8,7,6,5,4,3,2
* To be completed by you
COUNT3  DC.B   1      
LIST3   DC.B   1      
COUNT4   DC.B   1      
LIST4   DC.B   1      
* Do not change the following
CRLF   DC.B   $D,$A,0      Carriage return & line feed, null


PostPosted: Wed Dec 12, 2012 3:42 am 

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
That's a start, you at least have the loop thing going on and d0 gets the value of each item on the list in turn.

What you need to do now is turn that into something like this


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 10 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group