我想知道如何在arm汇编语言中做模数
我在arm网站上尝试了这个页面MOD操作符的代码:
MOV R1,#12 MOD 7 ; R1 = 5
MOV R2,#99 MOD 10 ; R2 = 9
Run Code Online (Sandbox Code Playgroud)
但它没有组装.
我正在使用keil汇编程序.
如果你正在寻找运行时模数而不是汇编时间,你可以使用两个指令来做div和mod:
;Precondition: R0 % R1 is the required computation
;Postcondition: R0 has the result of R0 % R1
: R2 has R0 / R1
; Example comments for 10 % 7
UDIV R2, R0, R1 ; 1 <- 10 / 7 ; R2 <- R0 / R1
MLS R0, R1, R2, R0 ; 3 <- 10 - (7 * 1) ; R0 <- R0 - (R1 * R2 )
Run Code Online (Sandbox Code Playgroud)
MLS的文档,专为此用例设计.
| 归档时间: |
|
| 查看次数: |
6858 次 |
| 最近记录: |