{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

comparchextracredit

# comparchextracredit - ;Jonathan O'Donnell;This program in...

This preview shows pages 1–3. Sign up to view the full content.

;Jonathan O'Donnell ;This program in SRC will implement a Bubble Sort ;on 15 random numbers in HEX and ;Store Numbers in memory while still saving ;old order of numbers ;Setting up constants ;.org 10 ;main equ 0x1000 ;sort equ 0x2000 ;store equ 0x3500 ;swap equ 0x4000 ;backup equ 0x4500 ;one equ 1 ;Array of numbers to be sorted ;Main .org 0x1000 la r21,0x2500 brl r20,r21 la r0,0x3000 la r1,0x4000 la r3,0x2000 la r12,0x4500 sub r5,r5,r5 sub r19,r19,r19 addi r19,r19,1 ;store array brl r13,r12 nop sub r19,r19,r19 addi r19,r19,1 sub r5,r5,r5 sub r11,r11,r11 sub r16,r16,r16 addi r16,r16,0x0e sub r2,r2,r2 addi r2,r2,15 ;loop brlnz r4,r3,r2 ;sort nop sub r5,r5,r5 sub r2,r2,r19 sub r16,r16,r16 addi r16,r16,0x0e sub r11,r11,r11 sub r22,r22,r22 addi r22,r22,4 sub r4,r4,r22 brnz r4,r2 ;loop nop stop ;Bubble Sort ;for (i=0; i<n-1; i++) { ; for (j=0; j<n-1-i; j++) ; if (a[j+1] < a[j]) { /* compare the two neighbors */ ; tmp = a[j]; /* swap a[j] and a[j+1] */

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
; a[j] = a[j+1]; ; a[j+1] = tmp; ; } ;} .org 0x2000 ld r6,0x3000(r5) addi r5,r5,0x04 ld r7,0x3000(r5) sub r8,r8,r8 sub r9,r9,r9 sub r9,r7,r6 brlmi r10,r1,r9 ;swap nop st r6,0x3000(r11) addi r11,r11,0x04 st r7,0x3000(r11) sub r16,r16,r19 brnz r3,r16 ;sort nop ; sub r22,r22,r22 ; addi r22,r22,4 ; sub r4,r4,r22 br r4 ;loop ;store .org 0x2500 ;array .dc 0x3b, 0x45, 0x30, 0x5b, 0x60, 0x1f, 0x00, 0x1b, 0x02, 0x32,
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

comparchextracredit - ;Jonathan O'Donnell;This program in...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online