I wanted to know how you need to handle assembly programs that are larger than 64k when you're doing 16-bit (assembly)programming in real segmented mode for DOS. In the book that I'm following("Assembly Language Step by Step" by Jeff Duntemann) the author mentions something about using more than one code segment(but unfortunately doesn't go into the details). I just wanted to know how to do this. I know this memory model is obsolete now, but I just, out of curiosity, wanted to know how you would accomplish this.
views:
51answers:
3Well, you just write upper word of your working address to DS, and you can use it via DS:DI. This way you can use more up to 300-500kb of ram.
Using more than 64kb memory isn't, by itself, terribly complicated (except if you need to deal with data structures crossing segment boundaries - that can be "fun"). If all you need is dynamic memory, simply use the 16:16 (seg:ofs) FAR pointers.
You can keep DS pointed to your main data segment and use ES (or, if executing on a 80386 or newer, even in real mode) FS or GS data segments to hold the segment part of your far pointers. You can use whatever general-purpose register you want for the offset part, DS:SI and ES:DI are special only when dealing with the string instructions (lods/movs/stos). Also, keep in mind that BP and SP default to SS segment if you don't use an explicit segment override!
If you need more than 64kb of static program data (wow!), you need an assembler with segment/section support, and you'll most likely also need to assemble to an object format and before linking to .exe. How to handle the static data far pointers is going to depend on your assembler of choice, but there will likely be some keyword for referencing the segment part of a variable.
That's easy. You have several code segments, probably spread among several overlay files (typically .OVL .OVR or .BIN). You load the overlay(s) you need, and jump to them with a far jump/call, which modifies CS:IP.