8085 assembly instructions MOV, LDA and STA
Asked Answered
L

1

12

I get the point of MOV, STA and LDA instructions, but what I don't understand is why are there three different instructions for two different processes?

  • STA is for copying data from accumulator to memory location,
  • LDA is for copying data from memory location to accumulator and
  • MOV is for copying data between registers plus registers and memory.

So, what I can do with STA and LDA instructions can be done with MOV instruction too, right?

Loaiasis answered 24/11, 2016 at 20:30 Comment(6)
which processor are you using? assembly is quite vague. I know LDA & STA from 6502 but MOV doesn't exist, so must be another one.Thadthaddaus
8080 probably. MOV can't take an immediate address like LDA and STA can, it requires the address to be stored in HL.Clave
@Jean-FrançoisFabre : 8085Loaiasis
@HansPassant MOV cannot take an immediate address but MVI can. But couldn't be there only two instructions: one for copying data from memory to any register or register pair, and another for copying data from any register or register pair to memory location? I mean, could there be only two in this case? I mean, I quite don't get the whole thing with data transfer though it sounds so simple...Loaiasis
MVI does not take an address, it takes an 8-bit value. This is all hopelessly antiquated, there certainly is no "could be" anymore, don't waste your life on dinosaur technology.Clave
It's partly just a question of designing the text assembly language. e.g. x86 uses MOV for loads, stores, and mov-immediate. Most assembly languages for RISC architectures use separate load and store mnemonics, but there's no reason they have to be that way. In both cases, loads and stores have separate opcodes.Nottingham
S
15

The instructions LDA and STA move data between memory and A. The instruction MOV either moves data between registers, or between a register and a memory location specified by HL.

LDA and STA are used when the address can be resolved at assembly/link time.

MOV is used when the memory address is computed at run time, and is placed in HL. For example, when you are iterating through an array.

You have discovered direct and indirect memory addressing.

Stiver answered 24/11, 2016 at 22:6 Comment(1)
Thank you for you well defined explanation. It really helped me a lot in understanding of data movement instructions :DLoaiasis

© 2022 - 2024 — McMap. All rights reserved.