Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AVR Assenbly Language question.

Status
Not open for further replies.
Advanced Member level 6
Joined
Dec 4, 2012
Messages
4,280
Helped
822
Reputation
1,654
Reaction score
791
Trophy points
1,393
Location
Bangalore, India
Visit site
Activity points
0
See image. My question is with respect to LD and LDD instrunctions. I want to know why there are X, Y, and Z. Where are they used? An example will be helpful. When we use Load Indirect should we use address of the location where the value resides?

92134d1370589073-avrasm.png
 

Attachments

  • avrasm.png
    avrasm.png
    56.5 KB · Views: 78

Hello jayanth see the Example

Code:
LDI    R27,$03
LDI    R26,$50
LD     R15,x
eda.png

eda.png
now
R15 is???
 
Last edited:

What is X, Y, Z? Register pairs? I can't understand the info in image. Can you explain?

Registers R27 and R26 contains 03H and 50H. So is X a register pair of R27 and R26? Should we use LDI instructions before using LD and LDD instructions? I see final value of R15 is 37H. Registers are 8-bits wide. So, what actually did the LD instruction did?
 

What is X, Y, Z? Register pairs? I can't understand the info in image. Can you explain?
Registers R27 and R26 contains 03H and 50H. So is X a register pair of R27 and R26?
yes these register call pointer registers and contain two 8bit register see these pictures
register0.png

register.png


Should we use LDI instructions before using LD and LDD instructions? Registers are 8-bits wide. So, what actually did the LD instruction did?
first we use LDI for set the address that x-register point to it

I see final value of R15 is 37H.
exactly
 

first we use LDI for set the address that x-register point to it
But in the example R27 and R26 contains 0x03 and 0x50. What are those values? Address of some other register? Will the value 0x0350h is an address in data space? Finally value contained at address 0x0350 is 0x37 and it is copied to R15. Right? So, Indirectly we are loading the r15 register with value at address 0x0350. Right? From where did the value 0x37 came? What about LDD instruction?

 

But in the example R27 and R26 contains 0x03 and 0x50. What are those values? Address of some other register? Will the value 0x0350h is an address in data space?
let's my explain it
In this example we want to find value of the 0x0350h address in the SRAM
Finally value contained at address 0x0350 is 0x37 and it is copied to R15. Right?
Right
So, Indirectly we are loading the r15 register with value at address 0x0350. Right?
again Right:wink:
From where did the value 0x37 came? What about LDD instruction?
0x37 is just an example
about LDD please solve this example
suppose that the value of the 0x401h --- 0x403h addresses are 0x50h,0x62h,0x6F then what is the value of R0,R1,R2?
Code:
LDI      R31,$04
LDI      R30,$01
LDD     R0,Z+1
LDD     R1,Z+0
LDD     R2,Z+2
 
Last edited:

address in data space value at address

0x0401 0x50
0x0402 0x62
0x0403 0x6F

after LDI R31, $04 and LDI R30, $01

Z will be 0x0401

After LDD R0, Z+1

R0 will be 0x62


After LDD R1, Z+0

R1 will be 0x50

After LDD R2, Z+2

R2 will be 0x6F


Right?
 

I have another question.

In the document I see there are LDD Rd, Y+q and LDD Rd, Z+q. Whay there is no LDD Rd, X+q?

I think it depends on internal instruction in the micro and it's better that you ask this question from atmel company
there are different kinds of data addressing mode that they have different uses for example in some of them we can use just z register
for getting more information read doc0856.pdf document
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top