.SM code | ram | eeprom
Version 3 of the SB-Assembler allows you to split memory into 3 major segments.
Per default you are using CODE memory, just like version 2 would have known it.
However now you can also select RAM or EEPROM memory.
Both CODE and EEPROM memory can have a target file open simultaneously. This allows you to write a piece of code to CODE memory, switch to EEPROM memory and declare some pre-set values there, and switch back to CODE memory to continue there with your program. You can switch back and forth between CODE, EEPROM and RAM memory as often as you want during an assembly run. In the end you will have two target files, one containing the CODE memory and another one with EEPROM memory data in it.
The RAM memory segment can't save any data. It is only intended to assign memory locations in a convenient way, without the need of the error prone .DU mode.
In Version 3 of the SB-Assembler this directive will perform a boundary sync.
A total of 3 different memory segments are supported as of version 3 of the SB-Assembler.
Each of the 3 memory segments has its own address space. This means that you can setup 3 different .OR addresses, one for each memory segment. Now you can switch back and forth between these three memory segments as often as you want. Declare some RAM, write some code, declare some more RAM, save some pre-set values to EEPROM memory, write some more code, declare some memory space to EEPROM memory, etc, etc.
A line containing the .SM directive must have an empty label field. An error is reported if the label field is not empty.
Please note that you can not write CODE memory and EEPROM memory to the same target file. If you use CODE and EEPROM segments you will always have to use (at least) 2 different target files.
The following piece of code demonstrates the use of memory segments.
First a piece of RAM memory is defined.
RAM starts at $8000 here and 2 labels are defined in RAM space, the first one spanning 2 bytes, the second one only one byte.
You don't have to, or better yet, you can't open a target file while in the RAM memory segment.
Then we switch to EEPROM memory. A new target file is opened and the starting address and the target address of the EEPROM memory is defined. Then some values are saved to the EEPROM target file.
Code memory is next in line. A new target file is opened, while the EEPROM target file is still open but not accessible at this moment. And a new starting address for CODE memory is defined. Then we start our code, which is written to the CODE target file.
Then we switch back to the EEPROM memory segment, which makes the EEPROM address space and the EEPROM target file active again. Some more data bytes are written to the EEPROM target file, a block of memory is declared without writing data to it, and some more data is written.
After that the RAM memory segment is selected again, using RAM address space and no target files now. A few more bytes are assigned in RAM space here.
And finally we switch to CODE memory again. From here we use the CODE memory address space and target file again.
You can switch back and forth between the different segments as often as you want. And each time the appropriate address space and target file is automatically selected.
.SM RAM .OR $8000 POINTER .BS 2 Declare a 2 byte pointer in RAM COUNTER .BS 1 Declare a 1 byte counter in RAM .SM EEPROM .TF EEPROMFILE.HEX,INT Write EEPROM data here .OR $1000 Begin of EEPROM memory .TA $0000 Write data from address $0000 IP_ADDR .DA #192,#168,#1,#200 Set default IP address IP_MASK .DA #255,#255,#255,#0 Set default net mask .SM CODE .TF CODEFILE.HEX,INT Write Code data here .OR $0000 Begin of Code memory RESET JMP INIT Get the system started NMI JMP DO_NMI Handle non maskable interrupts : : : RET End of some code .SM EEPROM Write some more data to EEPROM SERVER .AZ /www.sbprojects.net/ NV_BUF .BS 40 Reserve a 40 byte block of memory URL .AZ \www.sbprojects.net/sbasm\ .SM RAM Define some more RAM bytes BUFFER .BS 40 Reserve a 40 byte block of memory BUFPNTR .BS 1 Reserve 1 byte buffer pointer .SM CODE Continue code memory INIT NOP Get the system started : : RET End of some code