CoderDoc

RAM organization.

Variables

Depending of the scope of the variable, we put them in different places, for space optimisation and different tradeoffs.

Ultra-temporary variables.

This is for very short lived variables obeying one rule:
* No routine in another module must be called while the variable is in use.
Thanks to that rule, variable can be placed anywhere in 9e00-9eff, no conflict will occur.
Typically used when you are short on registers.
If you're not sure, use the next kind.

Temporary variables.

Those are temporary variable for far reaching routines.
They reside in &9000-&99ff. See memmap.o for free spots.

Persistent variables.

Those are the variables that should remains after a crash/reset (e.g. cursor position in the editor).
They resides in main bank (&ff). See memmap.o for free spots.

Buffer / Data.

For temporary buffer, same discussion than for variables.
For all that is persistent and likely to grow (source, symbol table, …), we use the following scheme:

Linked list of &100 - chunks.

The first chunk resides in main bank at a known possible.
Each one has a fixed header.

+0 Bank of next chunk (00 if last chunk).
+1 MSB  of next chunk (00 if last chunk).
+2 Last used LSB in chunk.
+3 Checksum
TODO: wait I have to complete this.

See prelude.o for routines to creates, delete, walk through chunks, and manipulate them.
The format after the header is free, but you'd better reuse routines for inserting thing inside chunk for instance, which will automatically insert a new chunk if the targeted chunk is full.

General Guidelines.

  • Thou shalt not connect banks.
      • Memory management should be hidden to you.
  • Thou shalt not use register I.
      • Use internally.
  • Thou shalt remain firmware friendly (e.g. no EXX or EX af,af')
      • Exception: Z80 emulation.
  • Thou shalt follow usual firmware convention (e.g. Carry for success).
  • Thou shalt not write helper routine before having checked whether it already exists.

All modules expect monogams:

  • Thou can use IX and IY.
Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License