计算100个整数的最大值和最小值
方法:使用space创建连续的空间用于存储数据,存储100个整数,初始化最大值和最小值为第一个数,和100个数逐次比较,求得最大值和最小值
stack_top EQU 0x30200000
AREA compare,CODE,READWRITE
code32
entry
start ;/* code start */
ldr r0,= array ;r0 point to the 100 array
mov r2, #1
ldr sp,= stack_top
arrayinit
mul r3, r2, r2
str r3, [r0], #4
add r2, r2, #1
cmp r2, #101
bne arrayinit
maxmininit
ldr r0,= array
ldr r2, [r0] ;r2 point to the max
ldr r3, [r0] ;r3 point to the min
mov r1, #1
maxmin
ldr r4, [r0], #4
cmp r2, r4
movcc r2, r4
cmp r4, r3
movcc r3, r4
add r1, r1, #1
cmp r1, #101
bne maxmin
stop
b stop
ltorg
array space 100
end