[cmds] Speed up Paint code drawing on slow 8088 systems by ghaerr · Pull Request #2277 · ghaerr/elks (original) (raw)

Speeds up drawing in Paint program considerably, discussed in #2269 (comment).

This turned out to be an interesting exercise, and an ia16-elf-gcc compiler bug was found in the process of trying to get it to not translate (x << 6) + (x << 4) to (x * 80) and emit a MUL instruction. On the 8088, MUL instructions are very slow and using left shifts will be much faster.

What was found with regards to ia16-elf-gcc is:

After playing way too long trying to get GCC to work without potentially putting each graphics function in a separate file, it was finally decided that translating the entire C86 ASM language vga-4pp.s fast draw routines from AS86 format to GCC AS format was the way to go, and it now works very well.

As a result of conversations with @Vutshi and @dbalsom in #2269, the following changes were made to greatly increase the speed of paint on 8088. This has been tested with QEMU slowing it down considerably by adding -singlestep -icount 8,align to the QEMU command line. Soon I hope to get MartyPC running on my macOS laptop for cycle-accurate 8088 emulation.