汇编语言指令及程序流程控制详解
1. 寄存器操作指令示例
1.1 移位指令示例
以下是一些移位和旋转指令的示例:
LSL R1, R1, #2 @ Shift register R1 left 2 bits (multiply by 4)
LSL R1, #2 @ Shorter form if the registers are the same
LSR R1, R2, #8 @ Shift R2 right by one bytes and place the result in R1
LSR R1, R3 @ Shift R1 right by the value in R3
ASR R1, #8 @ Arithmetic shift R1 right by one byte
ROR R1, R3 @ Rotate R1 right by value of R3
1.2 加载 32 位寄存器
可以通过 MOV 结合移位和加法操作来加载 32 位寄存器。例如,将值 0x12345678 加载到 R0 中,代码如下:
@ Initialize R0 with the leftmost byte
MOV R0, #0x12 @ load the first 8-bits
LSL R0, #24 @ shift it left 24 bits into place
@ Lo
超级会员免费看
订阅专栏 解锁全文
6012

被折叠的 条评论
为什么被折叠?



