Forum > Other
Problems when cross-compiling for 16-bit DOS
thelastpsion:
Hi!
I'm pretty new to Free Pascal. I used Delphi briefly about 20 years ago and I remember really enjoying it. I was recently looking for a language/compiler that could target modern OSes and DOS, but I didn't want to use C/C++. Object Pascal and Free Pascal felt like the perfect choice.
I'm writing a replacement for a preprocessor that forms part of an old Psion SDK. I want it to be a drop-in replacement for the original, but also run on modern Linux/Windows/macOS/etc. The source for the project is here: https://github.com/PocketNerdIO/ctran
However, after adding uses Classes; to get TStringList, it stopped compiling for DOS. I get one or more errors when linking, complaining that various code segments are too large for a 64K block. It doesn't matter which memory model I use, I always get errors.
Small Memory Model:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Error: Code segment "_TEXT" too large (exceeds 64k by 79732 bytes)
Medium Memory Model:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Error: Code segment "CLASSES_TEXT" too large (exceeds 64k by 8976 bytes)
Large Memory Model:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Error: Code segment "CLASSES_TEXT" too large (exceeds 64k by 36388 bytes)Error: Code segment "SYSTEM_TEXT" too large (exceeds 64k by 207 bytes)
Compact Memory Model:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Error: Code segment "_TEXT" too large (exceeds 64k by 135480 bytes)
I've also attached a screenshot of the terminal output.
It compiles fine with ppcx64.
Am I doing something wrong? Do I need to add some more switches to ppcross8086 to get it to work?
Just so you know, I'm not using Lazarus for this - it's all command line, with NeoVim and an (incomplete) LSP.
Hope someone can point me in the right direction!
Alex
louis:
Have you tried this switch?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$HUGECODE on}
See:
https://wiki.freepascal.org/DOS#Supported_memory_models
thelastpsion:
Thanks for the quick reply!
I hadn't tried that. I've just added it to the code, both in the main app and the unit. I get exactly the same errors. With -WmSmall, ppcross8086 also says that it's ignoring the switch.
Also tried the huge memory model, just in case:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Error: Code segment "CLASSES_TEXT" too large (exceeds 64k by 39635 bytes)Error: Code segment "SYSTEM_TEXT" too large (exceeds 64k by 2669 bytes)
Thaddy:
I think using classes - or sysutils for that matter, but maybe there is a stripped down version for DOS - do not fit in 64k.
Alternative is using objects, not classes, and FreeVision (FV) as framework.
(also comes with lists etc, but with a different syntax.)
That also reflects the DOS days a bit better :D
thelastpsion:
That's what I was worried about. That's a shame.
I'm planning on removing the need for TStringList anyway, so I might be able to get away without Classes for now. I'll do some experimentation.
I haven't played with objects yet, and I hadn't looked at Free Vision. I'll look at both of those.
Would it be worth trying the 32-bit DOS compiler? I think it's very unlikely that this project will ever run on anything but DOSBox.
Navigation
[0] Message Index
[#] Next page