aLec11_IndexMode

aLec11_IndexMode - Introduction to Embedded Microcomputer...

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

View Full Document Right Arrow Icon
Introduction to Embedded Microcomputer Systems Lecture 11.1 Jonathan W. Valvano Recap Subroutines, the stack, switches, LEDs Overview Pointers Indexed mode addressing TCNT (free running 16-bit time) Introduction to Lab 3 Can we collect data to prove it works? Input, output, time Read sections 4.5, 6.1, 6.2, 6.3 and 6.11 Pt Not pointing to anything Pointing to Object1 Pt Object1 Object2 Object1 Object2 Pointing to Object2 Pt Object1 Object2 Figure 6.1. Pointers are addresses pointing to objects. The objects may be data, functions, or other pointers. 6.1. Indexed addressing modes used in implement pointers Array or string Pt Linked list Pt FIFO queue GetPt PutPt Stack SP Figure 6.2. Examples of data structures that utilize pointers. If Register X or Y contains an address, we say it points into memory Definitions in C unsigned char data; // 8-bit value unsigned char out; // 8-bit value unsigned char *pt; // 16-bit address Definitions in assembly data rmb 1 ; 8-bit value out rmb 1 ; 8-bit value pt rmb 2 ; 16-bit address Initialization in C pt = &data; // pointer to data Initialization in assembly ldx #data // pointer to data stx pt Dereference in C out = *pt; // fetch value at pointer
Background image of page 1

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

View Full Document Right Arrow Icon
Introduction to Embedded Microcomputer Systems Lecture 11.2 Jonathan W. Valvano Dereference in assembly ldx pt ; X points to data ldaa 0,x ; fetch value at pointer staa out ;read 8-bit contents pointed to by X X data pointer A ldaa 0,x 16-bit definitions in C unsigned short data; // 16-bit value unsigned short out; // 16-bit value unsigned short *pt; // 16-bit address 16-bit definitions in assembly data rmb 2 ; 16-bit value out rmb 2 ; 16-bit value pt rmb 2 ; 16-bit address Initialization in C pt = &data; // pointer to data Initialization in assembly ldx #data // pointer to data stx pt 16-bit dereference in C out = *pt; // fetch value at pointer 16-bit dereference in assembly ldy pt ; Y points to data ldd 0,y ; 16-bit fetch at pointer std out ;read 16-bit contents pointed to by Y Y pointer ldd 0,y A B data 6.1.1. Indexed addressing mode Indexed addressing uses a fixed offset with the 16-bit registers: X, Y, SP, or PC. 5-bit (-16 to +15), 9-bit (-256 to +127), or 16-bit machine opcode operand comment $6A 5C staa -4,Y [Y-4] = RegA Let n,R be the indexed address fixed offset n and index register R is the index register, then EAR will be R+n .
Background image of page 2
Introduction to Embedded Microcomputer Systems Lecture 11.3 Jonathan W. Valvano Y $0823 $081E $081F $56 $0820 $0821 A $56 $F800 $F801 $6A $F802 $5C $F803 staa -4,Y } EEPROM RAM Figure 6.3. Example of the 9S12 indexed addressing mode. 16-bit data structures with indexed addressing is different in assembly versus in C.
Background image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 7

aLec11_IndexMode - Introduction to Embedded Microcomputer...

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

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