Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----------------DO NOT MODIFY--------*/
- .global Sort
- .global printf
- .global cr
- .extern value
- .extern getstring
- .syntax unified
- .text
- Sort:
- /*-----------------Students write their subroutine here--------------------*/
- PUSH {LR};
- PUSH {R4};
- LDR R0, [SP, 0x8]; //size
- .equ arrAdd, 0x20001000; //array address
- LDR R1,= arrAdd;
- SUB R0, 0x1;
- LSL R0, 0x2;
- ADD R0, R1; //converting size to final adress of array
- loop:
- LDR R3, [R1], 0x4; //n, n+1 value of array
- LDR R4, [R1];
- CMP R3, R4; //compare and swap if in wrong order
- ITTE GT;
- STRGT R3, [R1];
- MOVGT R3, R4;
- STRLE R4, [R1];
- SUB R1, 0x4;
- STR R3, [R1], 0x4;
- CMP R1, R0; //see if array adress is final array address
- ITT EQ;
- SUBEQ R0, 0x4; //if so, sub 4 from final array adress
- LDREQ R1,= arrAdd; //reset array adress
- CMP R1, R0; //see if final array adress is starting array adress
- BNE loop; //if not branch to start of loop
- POP {R4}
- POP {LR};
- BX LR;
- /*-------Code ends here ---------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement