3 ms·
I did some self modifying code just 10 years back on an firmware for a chip with an 8-bit CPU and a custom sequencer for data transfers. The sequencer was flexi
by pkaye 10y ago
I did some self modifying code just 10 years back on an firmware for a chip with an 8-bit CPU and a custom sequencer for data transfers. The sequencer was flexible but somewhat inefficient so it was incurring 30% overhead on some opcodes. A lot of the times when the sequencer was doing its job, the CPU would just poll for the sequencer completion. So what I did is split the sequencer code and moved some of the work to the CPU. To synchronize the two programs, I had the sequencer do its work and then jump on a register. Initially the register was set to jump back to PC causing it to pause. The CPU would do its bit then set the register to cause the sequencer to jump to then bit of microcode to execute. So the sequencer had efficient little subroutines while the CPU would make the decision to switch between them. End result the whole thing ran 30% faster and I was able to convert a bunch of assembly code into C which was easy to read. After that I spent my time pushing the chip designer to make a proper sequencer and CPU design.