You don't necessarily have to resort to assembly language to improve performance. For example, if you use absolute indexes instead of variable indexes then getting a byte from the array takes only one cycle (a simple "movf" instruction will be generated by the compiler)... Another example, if I may? Get rid of the OR gates and connect your output to RB7. Use PORTB as a variable, that is, write the data byte from the array to PORTB and then simply add PORTB to PORTB to sequentially send all eight bits out on RB7. And so instead of spending 7 or more cycles to shift each bit out, as you're doing in your program now, you spend only two cycles per bit;Just to confirm my suspicions, that ASM could do close to double res -- how many asm instructions required to do theseC instructions in assembly?Rich (BB code):PORTB = cache[0][segmentColumn] & 128;
Bit mask / compare a bit to a byte and write to port.
Rich (BB code):
//
// send cache[line 0][byte 0..4]
//
portb = cache[0][0]; // line 0, byte 0 (2 cycles)
portb += portb; // send pixel 01 (2 cycles)
portb += portb; // send pixel 02 (2 cycles)
portb += portb; // send pixel 03 (2 cycles)
portb += portb; // send pixel 04 (2 cycles)
portb += portb; // send pixel 05 (2 cycles)
portb += portb; // send pixel 06 (2 cycles)
portb += portb; // send pixel 07 (2 cycles)
portb = cache[0][1]; // line 0, byte 1 (2 cycles)
portb += portb; // send pixel 09 (2 cycles)
~~~~
Cheerful regards, Mike
Last edited: