27 lines
622 B
ArmAsm
27 lines
622 B
ArmAsm
|
;; MIPS program parity check
|
||
|
.data
|
||
|
N: .word 12
|
||
|
A: .double 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
|
||
|
B: .double 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
|
||
|
|
||
|
.text
|
||
|
main:
|
||
|
dadd r1,r0,r0 ; r1=i=0
|
||
|
lw r2, N(r0) ; r2=N
|
||
|
loop:
|
||
|
l.d f1, A(r1) ; f1=A[i]
|
||
|
l.d f2, B(r1) ; f2=B[i]
|
||
|
andi $t0, r1, 1 ; i&1
|
||
|
bnez $t0, impair ; if i impair
|
||
|
sub.d f2, f2, f1 ; f2=B[i]-A[i]
|
||
|
beq r0,r0,end
|
||
|
nop
|
||
|
impair:
|
||
|
add.d f2, f2, f1 ; f2=B[i]+A[i]
|
||
|
end:
|
||
|
s.d f2, B(r1) ; B = f2
|
||
|
daddi r1,r1,8 ; i++
|
||
|
daddi r2,r2,-1 ; N--;
|
||
|
bne r2, r0, loop
|
||
|
nop
|
||
|
halt
|