Web51 Memory Model
Let's start with the organization of the program memory. The segments are shown in the figure, together with typical locations in source files.
Segment vectors circumvents the limitation of the GNU assembler/linker, which does not support absolute segments. This segment is expected to start at address 0. The entire project may contain this segment at a single location only and the segment must contain all interrupt vectors.
Segment reset_begin is executed after microcontroller reset. It clears the micro's internal memory, sets basic timing of I/O operations and sets up timer0 to generate 1ms interrupts.
Segment reset_device is chopped into pieces contained in individual library modules. Ensures basic initialization of modules.
Segment reset_network is similar to the reset_device segment and allows to specify three levels of the order in which individual module initializations will be performed.
Segment reset_end ends the reset section and starts the micro's interrupt system.
Segment one_times allows execution of code that should run only once and needs the system fully initialized.
Segment fast_begin is the first part of the main program loop. It ensures basic handling of serial line handshake and starts the processing of received Ethernet packets. If there is nothing to process and at least 1ms has elapsed since the last pass through the loop, control is passed to the next segment; otherwise, the program stays in this segment.
Segment fast contains the actual user code, executed with the period of about 1 ms. This segment contains for instance LED control, etc. Use of this segment is detailed e.g. in the example applications in the www8051.asm file. The LED3 example is recommended for a quick introduction.
Segment fast_end contains a counter that checks whether 50 calls (or as set by slowtiming) have occured. If true, the processing of "slow" sections begins. Otherwise, the program jumps back to the fast_begin section.
Segment slow_begin resets the stateSyn bits that prevent web51 from responding to TCP connection requests more often than once in about 50 ms. Then, the program continues with the slow segment.
Segment slow contains the actual user code, executed once every 50 ms. This segment controls e.g. buttons, etc. In the examples, this segment is found in the www8051.asm file.
Segment slow_end ends the main "slow" program loop and the program jumps back to the beginning of the fast_begin section.
Segment cpu_rom mainly contains library modules that must be located below the 8kByte boundary due to 13-bit P-code function addressing.
Segment .text is the standard code segment. It contains custom subroutines, etc.
Segment cpu_dir_begin belongs to the filesystem segments. It contains the filesystem header. The filesystem in ROM is enabled at compile time by defining the ROMfilesystem condition. The header and footer of the filesystem are defined in the filecpu.asm library module, no user intervention is needed.
Segment cpu_dir contains the filesystem directory. Usually, it is generated by the html2db.pl script for each file that is added to the directory.
Segment cpu_dir_end contains the filesystem footer. It is included in the filecpu.asm library module.
Segment cpu_files contains filesystem data, converted for compiling by the html2db.pl script from individual source formats (html, jpeg, ...).
Segment cpu_top is a standard code segment. It contains custom user subroutines, etc.
The data memory used by the Web51 system can be divided, according to the processor used (89S8252 or 89C51RD2), into 5 to 6 sections. The programmer is responsible for correct usage of variables in individual segments. The assembler is only able to correctly allocate space for individual variables and to watch for segment overfills. However, it is unable to check for usage of variables defined in a different segment than enabled by the appropriate control register.
Regarding the linker, only the data EEPROM portion needs to be mentioned. Its structure resembles program memory.
 The linker itself can't assign unused address space in the 0x00 to 0x1F (or rather 0x08 to 0x1F) range, unless defined by the .rdata segment or the .rcomm command. If necessary, it is a good idea to move some variables here, as shown in several example applications in the www8051.asm module.
|Web51 description||News||FAQ||ORDER FORM||DOWNLOAD||Links|
|(c)Copyright 2000 - 2002, HW server & Radek Benedikt