Question: [ARM ASSEMBLY] Program;Keil uVision Can someone fix my code? It can sort by pushing the larger value to the end and smaller forward 5 3

[ARM ASSEMBLY] Program;Keil uVision

Can someone fix my code? It can sort by pushing the larger value to the end and smaller forward

5 3 4 6 2 > 3 5 4 6 2 > 3 4 5 6 2 > 3 4 5 2 6

I need it to sort again but starting at the end so that this happens:

3 4 5 2 6 > 3 4 5 2 6 > 3 4 2 5 6 > 3 2 4 5 6 > [ 2 3 4 5 6 ]

My CODE:

AREA PROGBUBBLE, CODE, READONLY

ENTRY

LDR r0, =entries; loads address of entries

LDR r7, =sorted;

MOV r10, #5;

LDRB r3, [r0]

STRB r3, [r7]

while

SUB r9,r10, #1

for

ADD r2, r2, #1;

LDRB r4, [r0, r2]

STRB r4, [r7, r2]

SUB r8, r2, #1;

CMP r3, r4

BGT ifs

BLT store

ifs

MOV r5,r3;

MOV r3,r4;

MOV r4,r5

MOV r10, r2;

;previous swapped with next.

STRB r3, [r7, r8];

STRB r4, [r7, r2];

CMP r2, r9

BEQ stop

CMP r10, #0

LDRB r3, [r0, r8]

BGT while

store

ADD r8, r2, #1;

LDRB r3, [r0, r2];

LDRB r4, [r0, r8];

STRB r3, [r7, r2];

B while

;r3 least r4 greatest

;starting with r4's address

;r8 = r2 + 1;

;r4 = r4, [r0, r8] 1 address ahead of r3

;r3 = r3, [r0, r2]

;by sub r2 - 1, r4' = r3 and r3 = r3 -1; [This case, keeps r4]

; r5 -> r4 -> r3-> r5 [Next case: If r3 > r4.]

;CMP r4, r3;

;BGT store

stop B stop

AREA Nums, DATA, READONLY

entries

DCB 5,3,6,4,2;

AREA List, DATA, READWRITE

sorted SPACE 20;

END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!