The .DU directive is mainly used for defining RAM memory locations.
There only the location is important while defining Labels in RAM area.
Version 3 of the SB-Assembler has a more elegant way of defining RAM locations, the .SM directive.
In Version 3 of the SB-Assembler this directive will perform a boundary sync.
Code generated after the .DU directive is simply discarded. No code is saved to the target file what so ever. For the rest nothing has changed in the assembly process. Labels are assigned and addresses are counted as if the code really was saved.
Warning: Use the .DU directive with extreme caution. Wrong use of the .DU directive can create a program that will never work. The SB-Assembler won't warn you if you use the .DU directive in the wrong way.
The dummy block that is started by the .DU directive ends at the next .ED directive, or when a new dummy block is started. Also the .OR directive will end the current dummy block. However the .NO directive will not end the dummy block!
Everything on the source line following the .DU directive will be treated as comments.
Please note that the target address after .ED will be exactly the same as the target address at the time the .DU directive was given.
Even though the current program counter has increased.
Therefore the program counter and target address won't be in sync anymore.
This means that a new .OR directive should follow the .ED directive under most circumstances, at least if you intend to create a working program.
The dummy mode can span across multiple include files.
As from software version 2.07 you may also specify the starting address of the dummy block by using the optional expression.
Effectively this combines a line with the .OR directive and a line with the .DU directive.
The expression may not contain any forward referenced labels.
.OR $8000 Start defining RAM area .DU But don't save the code anywhere COUNTER .BS 2 Define a 2 byte location POINTER .BS 2 Define another 2 byte location FLAG .BS 1 Define a single byte location BUFFER .BS 10 Define a 10 byte long buffer VALUE .BS 2 Define a 2 byte location .ED End of RAM definition .OR $0000 The real program starts here
As from software version 2.07 this example may also be written as:
.DU $8000 Start defining RAM area COUNTER .BS 2 Define a 2 byte location POINTER .BS 2 Define another 2 byte location FLAG .BS 1 Define a single byte location BUFFER .BS 10 Define a 10 byte long buffer VALUE .BS 2 Define a 2 byte location .ED End of RAM definition .OR $0000 The real program starts here
Version 3 of the SB-Assembler has a more sophisticated way of performing RAM declarations, using the .SM directive.
Therefore I recommend to use the .SM directive instead of the error prone .DU directive.
The .DU directive will still work though, for compatibility reasons.
Please note that the .DU directive will only work in Code memory, not in RAM or EEPROM memory.