Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Reading from flash in Assembly

2004-12-04 by Dave VanHorn

>
>         rcall   mpy16u  ;Find offset in CHAR_GEN table
>                         ;of first row results in r18 and r19

Can you sacrifice rom space, to put the addresses on a binary boundary?
Then this part becomes a few ROLs.

>         push    zl      ;push z as this routine happens during ints
>         push    zh

Do your ints not preserve z?  Which spends more time, saving it here, or in 
the ints that need it?

>         clr     zh
>         mov     zl,rownum       ;Load z with row_num
>         add     zl,r18          ;Add offset results
>         adc     zh,r19
>         ldi     r16,low(CHAR_GEN*2)
>         ldi     r17,high(CHAR_GEN*2)


Saving one un-needed clear.

ldi     zl,low(Char_Gen*2)
ldi     zh,high(Char_Gen*2)
add     zl,rownum
adc     zh,zero         ;(optionally clear rownum after using it, and add 
it here.)
                         ;I keep a register called zero zeroed to speed up 
these ops.
add     zl,R18  ;as before.
adc     zh,R19  ;


>         pop     zh      ;restore z
>         pop     zl

Have the ints save Z, and don't save/restore it here.

>As you can see it's a LOT longer that what you have but it has been working
>for many years, if anyone can shorten it I would be grateful :-))

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.