I am using easy68k to write a selection sort program, my main issue currently is I do not know how to select the largest value move it to the new memory location and then block off that highest value (i.e my highest value is 30 I need to remove it from the memory otherwise I would keep selecting 30 as the largest number)
In the future be forthright about the fact that you are working on a homework or lab problem, and post specific questions rather than a broad "How do I do everything I need to do for this exercise?" type of inquiry.
Markbnj
Programming moderator
Code:
ORG $400
START:
LEA Name,A1 Points to name
MOVE.W #11,D1 11 characters that need to be printed
MOVE.B #0,D0
Trap #15
LEA Class,A1 Points to Info
MOVE.W #7,D1 7 characters to be printed
MOVE.B #0,D0
Trap #15
LEA Info,A1 Points to Info
MOVE.W #9,D1 9 characters to be printed
MOVE.B #0,D0
Trap #15
BSR PRINT
MOVEA.L #Data, A0
MOVEA.L #Sorted, A3
CLR.B D0
CLR.B D4
Next MOVE.B (A0),D1 This portion selects the largest number
BEQ Exit
CMP.B D0,D1
BLS EndTest
MOVE.B D1, D0
MOVE.B D0, (A3) Should point to the new array and store a value
EndTest MOVE.B #-1,(A0) replaces the original value with negative one because the program ends when the pointer reaches 0 in the data and -1 < 0
ADDA.L #1,A0
MOVE.L D0,(A3,D4) Point to sorted array and D4 will increment it by 1 allowing for the new highest value to be stored in the next memory block
BEQ Exit
BRA Next
MOVEA.L #1,A1
Exit BSR PS
STOP #$2700
PRINT LEA Data,A1 Points to Info
L1 MOVE.B (A1)+,D6
MOVE.W D6,D1 41 characters to be printed
MOVE.B #3,D0
Trap #15
CMP.B #35,(A1)
BLE L1
RTS
PS LEA Sorted, A3
L2
MOVE.B (A3)+,D6
MOVE.W D6,D1 41 chracters to be printed
MOVE.B #3,D0
Trap #15
CMP.B #100,(A1)
BLE L2
RTS
*
ORG $1000
Data DC.B 10,12,8,17,9,22,18,11,23,7,30,22,19,6,7,0
Name DC.B 'XXXXX'
Class DC.B 'CIS 310'
Info DC.B 'Fall 2011'
Sorted DS.B 15
END $400
In the future be forthright about the fact that you are working on a homework or lab problem, and post specific questions rather than a broad "How do I do everything I need to do for this exercise?" type of inquiry.
Markbnj
Programming moderator
Last edited by a moderator: