Lecture_04 - Pointer registers, indirection, Reading & writing data RAM

Lecture_04 - Pointer registers, indirection, Reading & writing data RAM

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Faculty of Science and Technology Lecture 4 Pointer registers, indirection, Reading & Writing Data RAM SEE215
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Data RAM The ATMega 128 has 4096 bytes of 8 bit memory. The data is a contiguous block from $0100 - $10FF This memory is used for data, variable storage & stack. The stack resides in the top of RAM and “grows” downwards. This data will be lost when the processor looses power. This data is not directly accessible by the ALU. (The ALU can only do arithmetic , logic & bit operations on the 32 general purpose registers (R0-R31)). Data is read from & stored in RAM using direct & indirect addressing . Data ram must be allocated before using it.
Background image of page 2
Allocating Data RAM To allocate space to variables a special directive is required to advise the compiler IE. DSEG - Data Segment The DSEG directive defines the start of a Data segment. The Data Segments have their own location counter which is a byte counter. Ie. .dseg ;start allocating data space .org $0100 ; starting address var8: .byte 1 ; reserves memory location $0100 var16: .byte 2 ; reserves memory location $0101 & $0102 String: .byte 100 ; reserves memory location $0102 - $0166 ; (an array of 100 elements)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Allocating Program space If a .dseg directive is used before writing your program code a .cseg directive must be used to indicate that code space is being allocated. Ie. .dseg ;start allocating data space .org $0100 ; starting address var8: .byte 1 ; reserves memory location $0100 .cseg .org 0 jmp init .org $46 Init: etc. Modify your template to include this possibility now!
Background image of page 4
pointers In C , we learnt about pointers & indexing to manipulate data in arrays. Pointers & pointer variables allow indirect access to data! The concept of indirect addressing is so powerful, that no microprocessor would be complete without such a mechanism.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
There are many programming tasks that can ONLY be achieved by using indirect addressing. Whenever you have a task requiring access to sequential memory , using INDIRECT addressing may be the most efficient or only way. pointers
Background image of page 6
Indirect Addressing The AVR microcontroller, has the ability to address memory with up to three pointer registers X , Y & Z (pointer variables) These registers are 16 bit registers so that they can point to 64K of memory.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/27/2009 for the course SEB 323 - S taught by Professor Professor during the Three '09 term at Deakin.

Page1 / 25

Lecture_04 - Pointer registers, indirection, Reading & writing data RAM

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online