Dear Roman Black, Roman Black on 2001-05-30 12:13:27 PM asked, ... >a 12-core PIC, you can only put calls and >computed gotos on the bottom 256byte blocks. Those >are all full of other tables. I need a sane way >of adding a small table in another area (a high >block where tables are not possible). I can do it >with the 4:1 system I showed but that is very >unpolished. Surely someone has done this before? >:o) >-Roman Hm, interesting challenge. How about something like ; warning, untested code by david cary UDATA i res 1 ... CODE ; somewhere in the bottom of a 256 byte block lookup: ; just 1 instruction needed in LO memory goto real_table_start ... call lookup ; w = table[i]. ; now table[i] is in w, or if i was out of range, the default value is in w. ... ; OK to put in HI memory. (Also OK to put in LO memory, but then, what's the point ?) real_table_start: tstf i skpnz retlw Z ; for 0 == i decf i skpnz retlw A ; for 1 == i decf i skpnz retlw B ; for 2 == i decf i skpnz retlw C ; for 3 == i retlw default_value ; catches all other values of i. I count 15 instructions / 5 values = 3 instructions/value. This looks easy to extend to 256 values. Here's something a little more compact, but it is limited to 9 possible values, and the indexing is a little odd: ; warning: untested code by david cary real_table_start: btfsc i,7 retlw A ; for 0x80 <= i <= 0xFF btfsc i,6 retlw B ; for 0x40 <= i < 0x80 btfsc i,5 retlw C ; for 0x20 <= i < 0x40 btfsc i,4 retlw D ; for 0x10 <= i < 0x20 btfsc i,3 retlw E ; for 8 <= i < 0x10 btfsc i,2 retlw F ; for 4 <= i < 8 btfsc i,1 retlw G ; for 2 <= i < 4 btfsc i,0 retlw H ; for 1 == i retlw J ; for 0 == i. If some of your large tables are "smooth", you might be able to compress them, then (at runtime) use interpolation to approximate the missing values. This is a classic time/space tradoff. It's generally easier to find some way to compress a big block of data than to try to individually compress little pieces one at a time. -- David Cary -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body