At 06:32 PM 12/3/2004, John Samperi wrote: >At 10:54 AM 3/12/04 -0000, you wrote: > > > >Ok, and the final soloution is ;- > > > >mov r30, step > >ldi r31, high(array<<1) > >add r31, num > >lpm r18, z > >out portd, r18 > > > >As I'm only using Bytes not Words, I didn't need to left shift the ZL (r30) > >value. > >But DOES IT WORK? :-) The flash is in 2 byte lots (16 bit) that is the reason >you need to multiply by 2 to get to the address. Doesn't look entirely sane to me.. >mov r30, step >ldi r31, high(array<<1) Not sure what step is, but we are now pointing at high(Array*2)+Step >add r31, num Ok, adding offset, but this assumes that Step + num will never be > 255. >lpm r18, z >out portd, r18 Conventional.. What I would do, is this: ldi zl,low(Array*2) ;Point at the array ldi zh,high(Array*2) clr TEMP2 ;or any suitable register add zl,step ;16 bit op adc zh,TEMP2 add zl,num ;16 bit op adc zh,TEMP2 lpm r18,z out portd,r18 But I'm not sure how step is used here, so the first 16 bit add might not really be the right thing.
Message
Re: [AVR-Chat] Reading from flash in Assembly
2004-12-03 by Dave VanHorn
Attachments
- No local attachments were found for this message.