简体   繁体   English

如何保持汇编代码中的运行总数? ARM cortex M3(Keil软件)

[英]How to keep a running total in assembly code? ARM cortex M3 (Keil software)

Total beginner here. 总初学者在这里。 I'm trying to keep a running total of R5 but it keeps resetting back to the original value I had it set to. 我正在尝试保持R5的总运行速度,但它会一直重置为我设置的原始值。 R3 is keeping up but R5 won't R3跟上,但R5不会

This is the part of the problem I am working on. 这是我正在解决的问题的一部分。

Summation 求和

lessThan
    CMP R3, R4
    ADD R5, R3, R3
    RSB R5, R5, #60
    ADDLE R3, R3, #1
    ADD R5, R5, #6
    ADD R5, R5, R4
    BLE lessThan

I am ending up with my R5 being (in decimal) 48 when it's actually supposed to be 780. 我最终将R5设置为(十进制)48,而实际上应该是780。

ADD R5, R3, R3 sets r5 = r3*2 , throwing away the old value of R5 inside every loop iteration. ADD R5, R3, R3设置r5 = r3*2 ,在每次循环迭代中丢弃R5的旧值。

Did you mean add r5, r5, r3 to do r5 += r3 ? 您是说要add r5, r5, r3来做r5 += r3吗? Or did you need a scratch register? 还是您需要暂存器?

IDK what you want your code to do, or why, but the my first paragraph is the answer to why R5 isn't accumulating a separate total. IDK您想要代码做什么,或者为什么,但是我的第一段是为什么R5不累积单独总数的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM