Get the latest tech news

Speed-coding for the 6502 – a simple example


A real-life example showing how to scale an image in either 10 seconds, or 0.2 seconds, using 6502 assembly.

Taking an average of 37 cycles, we can now scale our image in a bit less than two seconds, a ten-fold improvement over the first algorithm. It often comes trading size for speed: in this case, we’ll need a table of 256 values containing pre-calculated results of X*3/4. So, instead of providing a dedicated, calculated at build time table, I will just generate it before starting scaling, applying the formula only once for every possible value in the 0-255 range:

Get the Android app

Or read this on Hacker News

Read more on:

Photo of simple example

simple example