What hoops must one jump through to write position-independent code for an x86 processor! Stupid stack tricks to figure out "where we are"; messing with segment registers; using SI or DI or a 32-bit register as an index pointer. It was so fucking easy on the PDP-11, everything was PC-relative unless specified otherwise. CALLs and JMPs are PC-relative on x86, why does data have to be absolute?

It wouldn't matter if colorForth was to be booted only directly from a floppy, but Chuck Moore's was designed to be also run as a .COM file from MS-DOS. If I want to have the same capability I've got to add a lot of stuff to my code. And now I'm thinking I should set DS or ES to be offset from 0x9400, or whatever the load address ends up being, to avoid any changes to high-level code. But there's only one or two as it is, maybe better not mess with it... and I've already added most of the necessary offsets in the assembly code. Ah well, one thing at a time.

Back to blog or home page

last updated 2013-01-10 20:51:42. served from tektonic