TOPIC 6 AVR Addressing Modes (review)

Published on Slideshow
Static slideshow
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Scene 1 (0s)

TOPIC 6 AVR Addressing Modes (review).

Scene 2 (2s)

AVR Addressing Modes. Register Direct, with 1 and 2 registers I/O Direct Data Direct Data Indirect: – with pre-decrement – with post-increment.

Scene 3 (10s)

Register Direct : 1 register. Instruction operands involve only 1 single register.

Scene 4 (27s)

Register Direct : 2 registers. Instruction operands (source and destination) involve only registers.

Scene 5 (37s)

I/O Direct. Instructions are used to access I/O space i.e. I/O registers Port Address:$00 (Mem:$20) - Port Address:$3F (Mem: $5F).

Scene 6 (54s)

Data Direct. LDS - Data loaded into a register from data space described by 16-bit addr . in opcode LDS Rd, <mem>.

Scene 7 (1m 12s)

Data Indirect : LD. LD – Load data from a location in data space pointed by 16-bit addr . pointer of register X, Y,or Z. into a destination register (Rd).

Scene 8 (1m 28s)

Data Indirect : LD. LD – Load 1 byte data from a location in data space pointed by 16-bit addr . pointer of register X, Y or Z. into a destination register (Rd). Register X, Y and Z are made out of combination of registers R26..R31. These registers are 16-bit address pointers for indirect addressing of the data space..

Scene 9 (1m 51s)

Data Indirect : LD/ ST. LD/ ST – Load/ Store 1 byte data from / into a location in data space pointed by 16-bit addr . pointer of register X, Y or Z. into a destination register (Rd). Register X, Y and Z are made out of combination of registers R26..R31. These registers are 16-bit address pointers for indirect addressing of the data space..

Scene 10 (2m 14s)

Data Indirect : LD. Data indirect uses the X, Y, Z registers as a pointer to access data location in the data memory area, purposefully at general purpose RAM (data) area. AVR ATmega32 comes with 2KB RAM, therefore the memory area is: 0x0060 – 0x03FF.

Scene 11 (2m 34s)

0 0 6 3 0x0063 X – r27:r26 6 3 r12. What is the difference between instructions LDS r12, 0x0063 and LD r12, X (shown above) ?.

Scene 12 (2m 54s)

Data Indirect : LD - Pre decrement & Post increment.

Scene 13 (3m 12s)

Data Indirect : LD - Pre decrement & Post increment.

Scene 14 (3m 30s)

Data Indirect : ST - Pre decrement & Post increment.

Scene 15 (4m 3s)

Data Indirect : Pre decrement & Post increment. The pre decrement and post increment feature is extremely useful as it keeps you from having to reload your pointers each time you need to access data. It is best used to access array..

Scene 16 (4m 22s)

Registers. r16. 01. r17. 23. VAR: .byte 4 ;reserves 4 bytes of data at location VAR ldi r16,0x01 ; r16= 01 ldi r17,0x23 ; r17 = 23 ldi r18,0x45 ; r18 = 45 ldi r19,0x67 ; r19 = 67 ldi r27,high(VAR) ; initialize X pointer ldi r26,low(VAR) ; to var address ; [R27:R26] = [X] = address VAR ; lets assume ‘VAR’ holds address is 0x0200 st X+,r16 ; store r16 to VAR+0 and increment pointer ; ( i ) store data ~ VAR  R16 , [VAR] = 0x01 ; (ii) increment pointer ~ X = VAR  VAR + 1 st X+,r17 ; store r17 to var+1 and increment pointer ; ( i ) store data ~ VAR  R17 , [VAR] = 0x23 ; (ii) increment pointer ~ X = VAR  VAR + 1 st X+,r18 ; store r18 to var+2 and increment pointer.

Scene 17 (5m 10s)

45. X= VAR. $0203. VAR: .byte 4 ;reserves 4 bytes of data at location VAR : : : : : continue from previous slide st X+,r18 ; store r18 to var+2 and increment pointer ; ( i ) store data ~ VAR  R18 , [VAR] = 0x45 ; (ii) increment pointer ~ X = VAR  VAR + 1 st X+,r19 ; store r19 to var+3 and increment pointer ; ( i ) store data ~ VAR  R19 , [VAR] = 0x67 ; (ii) increment pointer ~ X = VAR  VAR + 1.

Scene 18 (5m 48s)

r26. r27. 03. VAR: .byte 4 ;reserves 4 bytes of data at location VAR : : : : : continue from previous slide ld r3,-X ; decrement pointer and load var+3 to r3 ; ( i ) decrement pointer ~ X = VAR  VAR – 1 ; (ii) load data ~ R3  VAR , R3=[$203] ld r2,-X ; decrement pointer and load var+2 to r2 ; ( i ) decrement pointer ~ X = VAR  VAR – 1 ; (ii) load data ~ R2  VAR , R2=[$202] ld r1,-X ; decrement pointer and load var+1 to r1 ; ( i ) decrement pointer ~ X = VAR  VAR – 1 ; (ii) load data ~ R1  VAR , R1=[$201] ld r0,-X ; decrement pointer and load var+0 to r0.

Scene 19 (6m 30s)

Data Indirect With displacement – LDD / STD. This functionality on Data Indirect addressing mode only uses register Y and Z.

Scene 20 (6m 49s)

Data Indirect With displacement – LDD / STD. LDI R16, 0x55 STS 0x0230, R16 LDI YH,0x02 LDI YL, 0x20 ;Y=$220 LDD R3, Y + 0x10 ; pointer =Y + 0x10 = $0230 ; R3  DS($0230) ;R3 = 0x55 LDI ZH,0x03 LDI ZL, 0x00 ;Z =$300 STD Z+10, R3 ;[ 310]=$55.

Scene 21 (7m 6s)

Data Indirect: Summary. Table 5: AVR Auto-Increment/Decrement of Pointer Registers for LD Instruction Instruction LD LD LD LD LD LD LDD LD LD LD LDD Rn,x Rn,X+ Rn,-x Rn,Y Rn,Y+ Rn,-Y Rn,Y+q Rn,Z Rn,Z+ Rn,-Z Rn,Z+q Function After loading location pointed to by X, the X stays the same. After loading location pointed to by X, the X is incremented. The X is decremented, then the location pointed to by X is loaded. After loading location pointed to by Y, the Y stays the same. After loading location pointed to by Y, the Y is incremented. The Y is decremented, then the location pointed to by Y is loaded. After loading location pointed to by Y+q, the Y stays the same. After loading location pointed to by Z, the Z stays the same. After loading location pointed to by Z, the Z is incremented. The Z is decremented, then the location pointed to by Z is loaded. After loading location pointed to by Z+q, the Z stays the same..

Scene 22 (7m 51s)

Instruction & Memory Space: Summary.