Memory

The DOS operating system is not a protected mode operating system, and therefore is limited to 1 Megabyte of total memory (not including extensions like EMS or XMS).  Because the CPU runs in what is called "Real Mode", it can only access memory in 64 Kb chunks (DOS is a 16-bit operating system, and 65,535 is the largest value that can be stored in a 16-bit Word) called segments.

The 32-bit Windows operating system, on the other hand, runs in protected mode, which allows it to access memory in 32-bit chunks.  The largest value that can be stored in 32-bits is 4,294,967,295, or 4 Gigabytes.  The operating system itself reserves half of that for itself, which leaves two Gigabytes for applications such as yours to store code, arrays, strings, etc.

Because Windows 95/98/ME and NT/2000/XP are all 32-bit operating systems, a 32-bit CPU register can store an entire 32-bit address, so segments are no longer needed or used.  Therefore, functions like CODESEG, STRSEG, and VARSEG are no longer needed.  CODEPTR, STRPTR, and VARPTR all return a complete 32-bit address.  Additionally, when writing assembler code, you should never EVER change the values of the "segment" registers (CS, ES, DS, and SS).  Otherwise, you can virtually guarantee an application crash or General Protection Fault (GPF).

 

See Also

Upgrading To PBCC

Using Sequential Files

The Inline Assembler

Flat memory model

Protected mode programming