开发者

Assembly? LD & MOV

开发者 https://www.devze.com 2023-01-06 12:40 出处:网络
What\'s the difference between that instructions? By example in the ARM9 processor, it shouldn\'t be:

What's the difference between that instructions? By example in the ARM9 processor, it shouldn't be:

ASM: mov r0, 0
C: r0 = 0;
开发者_高级运维
ASM: ld r0, 0
C: r0 = 0;

?

I don't know why to use one or other :S


It must be:

ASM: mov r0, 0
C:   r0 = 0;

ASM: ld r0, 0
C:   r0 = *(pc + 0);

Check out this reference card, must have if you're developing for ARM on ASM.


Usually the LoaD instructions are used to load data from memory (directly or indirectly) into a register, while the MOVe instruction "moves" (copies) data from an operand to a register. In the ARM case, the source operand is a value (a constant) or a register (and both can be shifted/rotated before copying into the destination register).

So the first (mov r0, #0?), set to 0 the register r0; the second (a pseudo-op for ldr?) should load the data pointed by pc (r15) plus offset 0, and so be equivalent to r0 = *(pc + 0))


Try this guide: ARM Assembler Guide


Whether it is called MOV or LD depends on the particular assembly language. For example, the Z80 assembly language uses LD for everything, including assignment between registers and assignment of immediate values to registers.

In general you should always look up the meaning of mnemoics in the particular assembly language you are using.

0

精彩评论

暂无评论...
验证码 换一张
取 消