User:Alex farlie/16 Bit compilers

From ReactOS Wiki
Jump to: navigation, search

Per Borland C 4.5

16 BIT DOS Models

Tiny (I.E .COM model) :

  • Single _TEXT, _ DATA and _BSS of up to 64K (all code into single _TEXT if it fits.
  • DS=SS=CS
  • HEAP grows upward from top of _BSS
  • STACK grows downward from top of segment (up to 64K)
  • Initial SP is top of DS=SS=CS

Small:

  • Single _TEXT (64K) , single _ DATA and BSS of up to 64K
  • DS=SS
  • Local HEAP grows upward from top (+1) of BSS
  • STACK grows downward from top of DS=SS segement (up to 64K)
  • Far HEAP grows upward beyond from the top of DS (+1)

Medium:

  • Multiple _TEXT (one per source/object file), single _DATA and _BSS
  • DS=SS
  • Local HEAP grows upward from top (+1) of BSS
  • STACK grows downward from top of DS=SS segement (up to 64K)
  • Far HEAP grows upward beyond top of DS (+1)

Compact:

  • Single _TEXT, single DATA and _BSS
  • DS!=SS
  • HEAP is "far" above STACK
  • STACK grows downward from top of SS ( base of SS is uninitialised)
  • HEAP grows upwards from beyond the stack.

Large:

  • Multiple _TEXT (one for each source file), single DATA and _BSS
  • DS!=SS
  • HEAP is "far" above STACK
  • STACK grows doward from top of SS ( base of SS is uninitialised)
  • HEAP grows upwards from beyond the stack.

Huge:

  • Multiple _TEXT (one for each source file), multiple _DATA (No _BSS noted).
  • DS!=SS
  • HEAP is "far" above STACK
  • STACK grows downward from top of SS (base of SS is unitialised).
  • HEAP grows upward from beyond the stack.

In the larger models do NOT assume any "data" stored in CS is valid.

Functions should use something like this if FAR

.prolog push bp 
        mov bp,sp 
        pusha
        sub sp, <local stack needed>       
        (module code)
.epilog
                    /add sp, <amount>  - At this point the local stack's either beewn unwound already or will need adjusting
       popa
       move sp,bp
       pop  bp 
       RETF <x>  / x is depndent on calling convention but should match sizeof(args),


Windows 16 bit is different..


See also : https://github.com/tkchia/gcc-ia16