You are on page 1of 1

load x, NUM_OF_INTEGERS ; *size of integer if your addressing mode doesn't com

pensate
number_loop:
load r1, H50,x
; Read byte at 50+x into r1
cmp
r1, H50-1,x ; Compare with previous value
bcs
bigger
; carry set - greater than previous one
; Swap H50,x with H50-1,x
push r1
; save onto stack (or use a different register if you have o
ne available)
load r1, H50-1,x; get previous value
store r1, H50,x ; save it in current position
pop r1
; restore it from stack
store r1, H50-1,x ; save it in earlier position
; probably want to take note that you've done this somewhere so that you kno
w to do another pass
bigger:
dec
x
; subtract 1 from index (or 2 or 4 if multi-byte numbers and
addressing in your CPU doesn't compensate)
bne
number_loop ; if index not zero, do it again on the next numbers

---------------------------------------------

You might also like