On Tue, May 20, 2008 at 02:03:57PM +0100, Thomas Harte wrote:
> I'm about to finish my lunch break, sorry if I sound slightly short...
> 
> 1) is there any pattern or logic to the values placed on the bus
> during interrupts? I guess an equivalent question is: what realistic
> options do I have on the Sam for catching and processing interrupts?

I don't think the bus value is ever constructed in a useful way.

The usual strategies are to use mode 1, or to use mode 2 with a 257-byte table 
all 
containing the same byte.

> 2) are there any non-obvious tricks for fast access to a table
> containing 16bit words, indexed by an 11bit (signed) integer? At the
> minute I'm essentially doing:
> 
> [stuff to work out offset into table in hl]
> ld bc, <address of middle of table - which is aligned to a two-byte boundary>
> add hl, hl
> add hl, bc
> ld e, (hl)
> inc l
> ld d, (hl)

If you can align your table onto a 256 byte boundary, you can save a few cycles 
by adding 
only the top byte of the table offset. You can also double a number more 
quickly if you 
have an excuse to put some of it in the A register:

ld a,h         4
sla h          8
rla            4
add table/256  8
ld h,a         4
               = 28
instead of

ld bc, <table> 12
add hl, hl     16
add hl, bc     16
               = 44

HTH,
Andrew

-- 
 ---       Andrew Collier         ----
  ---- http://www.intensity.org.uk/ ---
                                      --
r<2+ T<4* cSEL dMS hEn/CB<BL A4 S+*<++ C$++L/mP W- a-- Vh+seT+ (Cantab) 1.1.4

Reply via email to