s3e: fix build break
[calu.git] / 1_isacmp / ppc.s
1         .text
2         .align 2
3         .globl _sum
4         ; r3 = len
5         ; r4 = addr of arr
6 _sum:
7         mr. r0,r3     ; move register: r0 := r3; where '.' enables
8                                   ; a CR0 update
9         blelr- 0      ; branch to LR if "less than or equal" in CR0
10                                   ; is set, where '-' predicts the branch will
11                                   ; not be taken
12         mtctr r0      ; move r0 into CTR
13         li r3,0       ; load immediate: r3 := 0
14         addi r4,r4,-4 ; add immediate: r4 := r4 + (-4)
15 .loop:
16         lwzu r0,4(r4) ; load word with update: r0 := mem[r4 + 4];
17                                   ;                        r4 := r4 + 4
18         add r3,r3,r0  ; add to sum: r3 := r3 + r0
19         bdnz .loop    ; decrement CTR and branch to loop if not zero
20         blr           ; branch to LR