ARM集成环境下求1-2+3-4+5...+99-100的值
01 |
; |
02 |
; 1-2+3-4+5...+99-100 |
03 |
; |
04 |
|
05 |
AREA sum2Code, CODE, READONLY |
06 |
ENTRY |
07 |
start |
08 |
|
09 |
mov r0, #0 ;保存结果 |
10 |
mov r1, #1 ;循环计数器 |
11 |
sum2loop ;特点奇数加偶数减 |
12 |
tst r1, #1 ;测试奇偶性 |
13 |
addne r0, r0, r1 ;加奇数 |
14 |
subeq r0, r0, r1 ;减偶数 |
15 |
add r1, r1, #1 |
16 |
cmp r1, #101 |
17 |
bmi sum2loop |
18 |
|
19 |
|
20 |
stop |
21 |
mov r0, #0x18 |
22 |
ldr r1, =0x20026 |
23 |
swi 0x123456 |
24 |
|
25 |
end |
有梦想就不会觉得苦.
Do you know what is the glittering life?