Kactung
Kactung

Reputation: 730

Assembly? LD & MOV

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

Upvotes: 5

Views: 19725

Answers (4)

starblue
starblue

Reputation: 56752

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.

Upvotes: 1

Andrejs Cainikovs
Andrejs Cainikovs

Reputation: 28424

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.

Upvotes: 8

ShinTakezou
ShinTakezou

Reputation: 9661

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))

Upvotes: 4

Lior
Lior

Reputation: 2631

Try this guide: ARM Assembler Guide

Upvotes: 2

Related Questions