comparchextracredit

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

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

View Full Document Right Arrow Icon
;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] */
Background image of page 1

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

View Full DocumentRight Arrow Icon
; a[j] = a[j+1]; ; a[j+1] = tmp; ; } ;} .org 0x2000
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/10/2012 for the course ECE 4551 taught by Professor Johnhadjilogiou during the Fall '09 term at FIT.

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 Right Arrow Icon
Ask a homework question - tutors are online