Program layout

Asmutils HOWTO
Prev |  | Next

# 2. Program layout

There are three macros that make section definition as simple as possible: `CODESEG`, `DATASEG` and `UDATASEG` (similar to tasm ideal mode syntax). `END` macro marks end of file.

A program should have at least `CODESEG` (.text) section and `END` macro, other sections are optional. `CODESEG` is read-only, `DATASEG` and `UDATASEG` are read-write; i.e. you can place data in `CODESEG` as long as you do not change it. You can also define your own sections if you want, but there's very rare need to do so. Each section (even if it is empty) enlarges your executable.

`START` macro tells linker the entry point, and must be present (if you are not making a library).

Thus, a program's skeleton should look like:

    %include "system.inc"

    CODESEG

    START:			;entry point

    			;code

    DATASEG

    			;data

    UDATASEG

    			;bss

    END

Prev | Home | Next
Asmutils HOWTO |  | Include files description