|GBDK libraries documentation|
|Prev||Chapter 4. Assembly language||Next|
The use of segments for code, data and variables is more noticeable in assembler. lcc defines a number of default segments - _CODE, _DATA and _BSS for storing code, static data and variables in respectively. Two extra segments _HEADER and _HEAP exist for the GB header and malloc heap respectively. The order these segments are linked together is determined by crt0.s and is currently _CODE then _DATA in ROM and _BSS then _HEAP in RAM. _HEAP is placed after _BSS so that all spare memory is available for the malloc routines. To place code in other than the first two banks, use the segments _CODE_x where x is the 16kB bank number.
As the _BSS segment occurs outside the ROM area you can only use .ds to reserve space in it.
While you don't have to use the _CODE and _DATA distinctions in assembler it is recommended for consistancys sake.
|Variables and registers||Up||Libraries|