The example below takes a list of 1000 numbers generated from a random number generator from 0-10,000, then in groups of 0-999, 1000,-1999, 2000....

# in class 9_17

# work on comparison and branch commands

.org 0x100

# clear out registers

li r1, 0

li r2, 0

li r3, 0

li r4, 0

li r5, 0

li r6, 0

li r7, 0

li r8, 0

li r9, 0

li r10, 0

li r11, 0x200

li r12, 1000

mtctr r12

loop: lhz r13, 0(r11)

cmpi 3, 0, r13, 999 # P303 for cmpi

bt 13, chk2 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r1, r1, 1

b nextv

chk2: cmpi 3, 0, r13, 1999

bt 13, chk3 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r2, r2, 1

b nextv

chk3: cmpi 3, 0, r13, 2999

bt 13, chk4 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r3, r3, 1

b nextv

chk4: cmpi 3, 0, r13, 3999

bt 13, chk5 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r4, r4, 1

b nextv

chk5: cmpi 3, 0, r13, 4999

bt 13, chk6 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r5, r5, 1

b nextv

chk6: cmpi 3, 0, r13, 5999

bt 13, chk7 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r6, r6, 1

b nextv

chk7: cmpi 3, 0, r13, 6999

bt 13, chk8 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r7, r7, 1

b nextv

chk8: cmpi 3, 0, r13, 7999

bt 13, chk9 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r8, r8, 1

b nextv

chk9: cmpi 3, 0, r13, 8999

bt 13, chk10 # bit 12 is less then, 13 is greater then, bit 14 is equal, 15 summary overflow

addi r9, r9, 1

b nextv

chk10: addi r10, r10, 1

b nextv

nextv: addi r11, 0x2

bdnz loop

nop

here: b here

Oddly enough, the spacing on the blog doesn't take so all the lines are left aligned, sorry.