ARM 32bit RISC셈
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | bubbleSort PROC ; argms ; r0 int* number ; r1 int n ; ; local var. ; r1 int n ; r2 int j ; r4 _swper ; r5 number[j+1] ; r12 number[j] ; PUSH {r4-r6,lr} ; _for0 MOV r2,#0 ; j = 0 CMP r2,r1 ; j == n ? |L0.24| ;_for0body BEQ |L0.08| ; if j == n then return ; _if0 ADD r4,r0,r2,LSL #2 ; _swper = int[j] LDR r12,[r0,r2,LSL #2] ; _if0lh = number[j] LDR r5,[r4,#4] ; _if0rh = number[_swper as j + 1] CMP r12,r5 ; _if0lh == if0rh ? ; swap STRGT r5,[r0,r2,LSL #2] ; if _if0lh > _if0rh then ; number[j] = _if0rh STRGT r12,[r4,#4] ; if _if0lh > _if0rh then ; number[j+1] = _if0lh ; /swap ; /_if0 ; _if1 CMP r2, r1 ; j == n? MVNEQ r2, #0 ; if j == n then j = -1 SUBEQ r1, r1, #1 ; if j == n then n-- ; /_if1 ADD r2, #1 ; j++ B |L0.24| ; loop ; /_for0 |L0.08| POP {r4-r6,pc} ; return ENDP | cs |
버블 살려주세요