Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Easy68K or similar! Sorry for the confusion in my previous question. In th

ID: 3771846 • Letter: U

Question

Using Easy68K or similar!

Sorry for the confusion in my previous question.

In this program, there is an array, which is [5, 7, 12, 3, 8, 21, 11, 1, 2, 16], and all the data in this array are WORD size. :

1. Load this array into a stack.

2. Create a subroutine to find out the minimum number in this array, and then swap the position of this minimum number with the first number. (You are suggested to use a loop, which is within the subroutine, to help you find the minimum number)

3. Return back to the main function, clean up the stack, and then print out the array that begins from the smallest number.

You guys(and gals) rock. Thank you for everything.

Explanation / Answer

min equ 0

max equ $3f

org $1000


lea $7ffe,a7
ori.w #$700,sr
andi.w #$7fff,sr


lea $2000,a0

move.l #min,d0


move.l #max,d1


bsr q_sort


trap #0


move.w d0,-(a7)
move.w d1,-(a7)


move.w d1,d2
sub.w d0,d2
lsr.w #1,d2
add.w d0,d2

move.b 0(a0,d2.w),d3

next1 equ *
cmp.b 0(a0,d0.w),d3
bls next2
addq.w #1,d0
bra next1


move.b 0(a0,d1.w),d4
cmp.b d3,d4
bls swap
subq.w #1,d1
bra next2

swap equ *
cmp.w d1,d0
bgt suite


move.b 0(a0,d0.w),d5
move.b 0(a0,d1.w),0(a0,d0.w)
move.b d5,0(a0,d1.w)


addq.w #1,d0
subq.w #1,d1

cmp.w d1,d0
bgt suite
bra next1

cmp.w 2(a7),d1
ble next3

  
move.w 2(a7),d6
move.w d0,-(a7)
move.w d1,-(a7)
move.w d6,d0

bsr q_sort


move.w (a7)+,d1
move.w (a7)+,d0


cmp.w (a7),d0
bge fin


move.w (a7),d6
move.w d0,-(a7)
move.w d1,-(a7)
move.w d6,d1

bsr q_sort


move.w (a7)+,d1
move.w (a7)+,d0


adda.l #4,a7

rts

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote