Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.


10.8.2 Static memory

Assembly programs reserve static memory for things like strings using DC mnemonics. However, these aren't real mnemonics. They are, in fact, compiler directives and they can vary from compiler to compiler. The E versions are LONG, INT and CHAR (the type names), which take a list of values, reserve the appropriate amount of static memory and fill in this memory with the supplied values. The CHAR form also allows a list of characters to be supplied more easily as a string. In this case, the string will automatically be aligned to an even memory location, although you are responsible for null-terminating it. You can also include a whole file as static data using INCBIN (and the file named using this statement must exist when the program is compiled). To get at the data you mark it with a label.

This next example is a bit contrived, but illustrates some static data:

PROC main()
  DEF x:PTR TO CHAR
  LEA datatable(PC), A0
  MOVE.L A0, x
  WriteF(x)
ENDPROC

datatable:
  CHAR 'Hello world\n', 0
moredata:
  LONG 1,5,-999,0;    INT -1,222
  INCBIN 'file.data'; CHAR 0,7,-8

The Assembly stuff to get the label address is not really necessary, so the example could have been just:

PROC main()
  WriteF({datatable})
ENDPROC

datatable:
  CHAR 'Hello world\n', 0


Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.