??? 03/27/06 21:47 Modified: 03/27/06 21:49 Read: times |
#113263 - lookup/jumptable Responding to: ???'s previous message |
Erik Malund said:
what about instead using r4 as a shift register from 1 thru 0x80? That might be too slow. A lookup table is appropriate here. mov r4,#6 call setb_ind ... setb_ind: xch a,r4 push acc add a,#setb_ind_T-setb_ind_X movc a,@a+pc setb_ind_X: orl a,r4 mov r4,a pop acc xch a,r4 ret setb_ind_T: db 1,2,4,8,16,32,64,128 Hmmmm... Does not seem too fast either :-) Maybe a smartly devised algo would do... mov r4,#6 call setb_ind ... setb_ind: push b mov b,r4 jb b.2,setb_in_1xx jb b.1,setb_in_01x jb b.0,setb_in_001 orl a,#1 pop b ret setb_in_001: orl a,#2 pop b ret setb_in_01x: jb b.0,setb_in_011 orl a,#4 pop b ret setb_in_011: orl a,#8 pop b ret ... etc.etc. Or a jumptable. Code memory/FLASH is cheap today. You can even have toggle indirect (or call it XOR if you want). Jan Waclawek [edit]Oh, @#$%^, now I realized what did you mean by counter... and shift register... yep, that's the smartest way; do the hard way only if r4 can be an arbitrary value, of course...[/edit] |
Topic | Author | Date |
setb command | 01/01/70 00:00 | |
You mean? | 01/01/70 00:00 | |
Not quite. | 01/01/70 00:00 | |
what about | 01/01/70 00:00 | |
what about | 01/01/70 00:00 | |
what about | 01/01/70 00:00 | |
lookup/jumptable | 01/01/70 00:00 | |
what I thought | 01/01/70 00:00 | |
Shift register. | 01/01/70 00:00 | |
chapter 2 | 01/01/70 00:00 | |
Indirect bit referencing | 01/01/70 00:00 | |
OK | 01/01/70 00:00 | |
Not Necessarily ... | 01/01/70 00:00 | |
well, you got one, now for the rest | 01/01/70 00:00 | |
using bits indirect | 01/01/70 00:00 | |
indirect bits![]() | 01/01/70 00:00 |