Loading data to register with LDI

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Knowledgeable Helpers. I'm using an ATTiny13.    If I load immediate data (LDI) to a register ( r16) and it already contains a value, does loading new data add to the existing value in the register or does the instruction LDI clear the register and load only the immediate data? Any help would be greatly appreciated.

Last Edited: Wed. Jan 10, 2018 - 11:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It replaces what was in the register with the new value

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that would be the standard meaning of "load" for any assembler.

 

In fact, the standard meaning of "load" in any programming context.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The avr instruction set description outlines what each instruction does. I’d suggest you have a read of this - it would be hard to write asm without it.

A load does not clear the register as such - the register contents are replaced with the new value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

McKinley wrote:
If ... a register ... already contains a value

Note that it is never possible for any register - or any other memory location - not to contain a value.

 

ie, the register will always already contain a value.

 

The value may be meaningless; complete random junk - but it is always a value.

 

A register - or any other memory location - always contains a value.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
The avr instruction set description outlines what each instruction does. I’d suggest you have a read of this

+999

 

it would be hard to write asm without it.

I'd say impossible - it is the essential reference for assembler programming!

 

 

the register contents are replaced with the new value.

Which is shown in the Instruction Set Manual as:

 

 

So the immediate value, K, is simply placed into the register, Rd.

 

 

If it were added to (or otherwise "combined" with) the existing value in the register, that would be shown as, for example: