Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Kragen Javier Sitaker Newsgroups: alt.folklore.computers,alt.sys.pdp8 Subject: position-independent code (was Re: CMS, Self-hosting and the 6502) Date: Fri, 11 Sep 2026 09:42:23 -0300 Organization: Primarily biological and memetic Lines: 63 Message-ID: <87ld98c634.fsf_-_@debian> References: <10qehuo$2nu4m$1@dont-email.me> <87h5pqwd5j.fsf@localhost> <10qs7og$129km$4@dont-email.me> <10qt6h6$19mab$1@dont-email.me> <10qucqd$cs9$2@gal.iecc.com> <10qv31u$1l5fk$3@paganini.bofh.team> <10qv7t7$1re07$2@dont-email.me> <10qvlrb$1uf62$2@dont-email.me> <10r0g2r$25l0l$1@dont-email.me> <875x64ugxl.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 11 Sep 2026 12:44:43 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3052864"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UYSaNLAhQU0Kt6GWKRGZl"; posting-host="5e8b773666f2baa1b3e9fe7abeba1530" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:cAcJxuoSVs2ahd7mD5fs9odpzv0= sha1:3E7jX4As/5G7XvxLjA7bY6GBNbE= sha256:GpmieZghfYqKLR17/zUShkaIotTtWaqomwmRJrBNp2k= sha1:qGpkjpRIxesaBGmy6Yp/kl7KJu0= sha256:Tg6YpRweHl/r9vet5Umr2ZJsCiiFxSrPAuXK8YKt6QI= Xref: csiph.com alt.folklore.computers:235573 alt.sys.pdp8:2887 Lynn Wheeler writes: > W/o location independence and requiring executable image to be otherwise > preloaded to have address constants to be modified to their executing > position ... would have required every executing program image to have > unique address across the whole system I’ve never programmed the PDP-8, but, as I understand it, its 7-bit address field in the 12-bit instruction format effectively divides the 4096-word address space into 128-word “pages”. An 8th bit specifies which page the address field is interpreted relative to: either a 6502-like zero page, or the current page. So, in effect, you have two 5-bit “base registers”: one hardwired to 00000, and the other one that’s the high 5 bits of the program counter. (Later PDP-8s extended the address bus to the left and needed additional registers to select which 12-bit memory space you were running in.) To reference words in other pages (again, as I understand it), you would store their absolute 12-bit address in a word in either the zero page or your current page, and set the indirection bit in your instructions to use that address as a pointer. But often you would receive that pointer at run time, for example as a return address or an argument. Mark Smotherman’s PDP-8 background/reference, for afc: It occurred to me that a subroutine or set of related subroutines that fit into a single 128-word page could be “position-independent” merely by containing no absolute 12-bit addresses when loaded. This would not require a PC-relative addressing mode, which would have required an expensive addition operation before the memory access. On a machine with a larger word size, you might be able to fit a whole library on such a “page”, which would act more like a segment. On such a machine, a loader could load libraries onto whatever page it felt like, without requiring any of load-time relocations, globally unique addresses, or PC-relative addressing. Of course, the PDP-8 wasn’t available as an example to follow when the IBM 360 was being designed, and I don’t know of any pre-360 machines that offered such a mechanism. The LINC, in particular, had 12-bit instruction words and 10-bit addresses, and the address field in the three Full Address Class instructions (STC, ADD, and JUMP) was 10 bits, according to . The Data General Nova, IIRC, expanded the PDP-8’s global/current page bit to a two-bit fields which selected which of four base registers you used as the base address. Smalltalk, originally written on Xerox’s “Alto” clone of the Nova, has a very similar structure in its bytecode — there are bytecodes for fetching constants, local variables, global variables, and instance variables of the current object, and corresponding bytecodes for storing (except for the constants). John Cowan’s 32-bit extension of the PDP-8, the PDP-8/X , has pages of 2048 words instead of 128 words, as well as a BASE register to relocate the zero page to wherever you like and a STACK register so that the standard subroutine call mechanism can become reentrant. You might be able to do some variant of this randomly-placed-page mechanism on a PDP-8/X, but the potential program linkage table (for one page of code to find another) would be huge. Kragen