How did Turbo Pascal overlays work?
Asked Answered
S

1

7

I'm implementing an assemblinker for the 16-bit DCPU from the game 0x10c.

One technique that somebody suggested to me was using "overlays, like in Turbo Pascal back in the day" in order to swap code around at run time.

I get the basic idea (link overlayed symbols to same memory, swap before ref), but what was their implementation?

Was it a function that the compiler inserted before references? Was it a trap? Was the data for the overlay stored at the location of the overlay, or in a big table somewhere? Did it work well, or did it break often? Was there an interface for assembly to link with overlayed Pascal (and vice versa), or was it incompatible?

Google is giving me basically no information (other than it being a no-on on modern Pascal compilers). And, I'm just, like, five years too young to have ever needed them when they were current.

Sostenuto answered 14/4, 2012 at 15:56 Comment(2)
Link 0x10c.com is not reachable (permanent timeout). Is there a replacement?Azerbaijani
This file is archived at web.archive.org/web/20120919220416/http://0x10c.com/doc/…Darondarooge
D
7

A jump table per unit whose elements point to a trap (int 3F) when not loaded. But that is for older Turbo Pascal/Borland Pascal versions (5/6), newer ones also support (286) protected mode, and they might employ yet another scheme.

This scheme means that when an overlay is loaded, no trap overhead happens anymore.

I found this link in my references: The Slithy Tove. There are other nice details there, like how call chains are handled that span multiple overlays.

Devlen answered 14/4, 2012 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.