| ??? 04/18/05 14:08 Read: times |
#91826 - optimum? table driven Responding to: ???'s previous message |
Sq10Bit3: ;input: r0,r1; output: r2,r3,r4; all LSB first
mov DPTR,#Table1
mov a,r0
movc a,@a+dptr
mov r2,a
mov a,r1
jz Sq10Bit3a
add a,r1
add a,#HIGH(Table2-2*256)
mov dph,a
mov a,r0
movc a,@a+dptr
mov r3,a
inc dph
mov a,r0
movc a,@a+dptr
mov r4,a
ret
Sq10Bit3a:
inc dph
mov a,r0
movc a,@a+dptr
mov r3,a
mov r4,#0
ret
Table1: ;256 bytes: (X^2) MOD 256 for X=00h..FFh
;256 bytes: (X^2) DIV 256 for X=00h..FFh
ORG Table1+512
Table2:
;256 bytes: ((X^2) DIV 256) MOD 256 for X=100h..1FFh
;256 bytes: ((X^2) DIV 256) DIV 256 for X=100h..1FFh
;256 bytes: ((X^2) DIV 256) MOD 256 for X=200h..2FFh
;256 bytes: ((X^2) DIV 256) DIV 256 for X=200h..2FFh
;256 bytes: ((X^2) DIV 256) MOD 256 for X=300h..3FFh
;256 bytes: ((X^2) DIV 256) DIV 256 for X=300h..3FFh
end
31 bytes code, exactly 2kB tables, 23 cycles worst case (17 cycles if high byte of input = 0), including ret. Jan Waclawek |
| Topic | Author | Date |
| Fast Square. | 01/01/70 00:00 | |
| Square dancing | 01/01/70 00:00 | |
| table lookup??? | 01/01/70 00:00 | |
| code & algorithm | 01/01/70 00:00 | |
| 16*16 bit is slower than what I want. | 01/01/70 00:00 | |
| How fast? | 01/01/70 00:00 | |
| Re: How Fast | 01/01/70 00:00 | |
| ... probably impossible in 15 cycles | 01/01/70 00:00 | |
| why cycles ? | 01/01/70 00:00 | |
| Re: Microseconds | 01/01/70 00:00 | |
| table lookup | 01/01/70 00:00 | |
| Natsemi appnote or CORDIC | 01/01/70 00:00 | |
| Natsemi link to appnote | 01/01/70 00:00 | |
| (a+b)^2=a^2+2*a*b+b^2 | 01/01/70 00:00 | |
| Thats Slow. | 01/01/70 00:00 | |
| faster need hardware | 01/01/70 00:00 | |
| How fast do you need? | 01/01/70 00:00 | |
| Re: How Fast. | 01/01/70 00:00 | |
| Just? | 01/01/70 00:00 | |
| Incorrect | 01/01/70 00:00 | |
| Correct? | 01/01/70 00:00 | |
| Whooooopa... Sorry. | 01/01/70 00:00 | |
| Thanks | 01/01/70 00:00 | |
| I tried... | 01/01/70 00:00 | |
| optimum? table driven | 01/01/70 00:00 | |
| Jan metod | 01/01/70 00:00 | |
| Hardware? | 01/01/70 00:00 | |
| CPLD? | 01/01/70 00:00 | |
| SILabs f12x does it in hardware | 01/01/70 00:00 | |
| Re: SiLabs F12x | 01/01/70 00:00 | |
| Price | 01/01/70 00:00 | |
| F12x price | 01/01/70 00:00 | |
| F12x MAC | 01/01/70 00:00 | |
| provided in the datasheet | 01/01/70 00:00 | |
| Just out of interest | 01/01/70 00:00 | |
| clarification | 01/01/70 00:00 | |
| CPLD? | 01/01/70 00:00 | |
| too expensive | 01/01/70 00:00 | |
| Absolute rubbish Oleg | 01/01/70 00:00 | |
| explain | 01/01/70 00:00 | |
| your right | 01/01/70 00:00 | |
| especially for those... | 01/01/70 00:00 | |
| I need to say this.... | 01/01/70 00:00 | |
| By the way..... | 01/01/70 00:00 | |
| just a demo | 01/01/70 00:00 | |
| Hang on. | 01/01/70 00:00 | |
| Oh bollocks | 01/01/70 00:00 | |
| Well oleg | 01/01/70 00:00 | |
| Please check my answer. | 01/01/70 00:00 | |
| Here you go | 01/01/70 00:00 | |
| You're having me on. | 01/01/70 00:00 | |
| Pascal? | 01/01/70 00:00 | |
| Pascal? | 01/01/70 00:00 | |
| Why ? | 01/01/70 00:00 | |
| It was changed because,,, | 01/01/70 00:00 | |
| Its because | 01/01/70 00:00 | |
| For Jez | 01/01/70 00:00 | |
| For Michael | 01/01/70 00:00 | |
| simulation | 01/01/70 00:00 | |
| Re: Fast Square | 01/01/70 00:00 | |
| Prahlad, waithing for a conclusion | 01/01/70 00:00 | |
| just an exercise... | 01/01/70 00:00 | |
| Tricky | 01/01/70 00:00 | |
| Jez asked his cat, I asked my sheep | 01/01/70 00:00 | |
| Conclusion. | 01/01/70 00:00 | |
SPI EEPROM | 01/01/70 00:00 |



