Web 51 - html2db.pl
The html2db.pl script converts html pages and several other formats (such as JPEG or GIF images) to assembler source. Resulting source code contains appropriate headers for the Web 51 filesystem.
For example, by converting config.html, the following code fragment results:
.section cpu_dir, #alloc .word 'c'+'o'+'n'+'f'+'i'+'g'+'.'+'h'+'t'+'m'+'l' .byte 1 ;text/html .byte 0 ;reserved .word begin0 .word end0 .section cpu_files, #alloc begin0: .ascii "...
Header contents may be modified by command-line parameters when the script is started. It is possible to change segment name for file contents and segment name for directory items. Switches -cpurom, -cpueeprom and -eeprom change segment names to defaults.
switch directory file -cpurom cpu_dir cpu_files -cpueeprom ee_dir ee_files -eeprom i2c_dir i2c_files
Segment names can be stated explicitly:
switch parameter -dir segment name -body segment name
Other switches affect the contents of the second directory item - file type. Default file type is derived from source file name. Other options are:
switch type note -html 1 #text/html -plain 2 #text/plain -jpeg 3 #image/jpeg -gif 4 #image/gif -png 5 #image/png -app 6 #application/octet-stream -noheader 0 #without header
File type also affects the actual conversion. html2db supports two conversion modes:
Text - searches for cgi scripts in the source and allows for conversion of their parameters.
No conversion (Binary) - converts the file directly into a sequence of byte definitions - e.g. DB 047h, 049h, ... Conversion can be turned off by the -noconverthtml switch
Besides segment names, switches -cpurom, -cpueeprom and -eeprom also set default offsets that are added to addresses in the header. This offset comes from the "strange" linking of a hex file for AT89C8252. In the hex file, the EEPROM starts at 2000h, but is actually addressed from 0h. This correction can be explicitly turned on with -offset.
Last switch of this category is -index. It causes the directory item generated by default to be duplicated. Given index value is used as the hash value in the header. Practical usage is primarily to generate a link to the root page of the www server, where the parameter is 0. Such a "duplicated" page can be referenced without a name, just by specifying the address of the www server. Resulting code with -index 0 specified is shown below.
.section cpu_dir, #alloc .word 'c'+'o'+'n'+'f'+'i'+'g'+'.'+'h'+'t'+'m'+'l' .byte 1 ;text/html .byte 0 ;reserved .word begin0 .word end0 .word 0 ;specified by -index .byte 1 ;text/html .byte 0 ;reserved .word begin0 .word end0 .section cpu_files, #alloc begin0: .ascii "...
The -binutils switch affects code generation with respect to target assembler. If specified, resulting code uses the syntax of mcs51-as, assembler from the binutils package. Otherwise, Intel/Keil compliant code is generated.
Switches -version and -help print out version number and simple help:
usage: html2db.pl [-cpurom] [-cpueeprom ] [-eeprom] [-html] [-plain] [-jpeg] [-gif] [-png] [-app] [-noheader] [-index VALUE] [-dir DIR_SEGMENT] [-body BODY_SEGMENT] [-offset VALUE] [-noconverthtml] [-appendlf] [-version] [-help] file
Unless suppressed by -noconverthtml, any cgi parameters in source html files are converted. There are three ways of specifying cgi parameters:
- As an ASCII constant: 'xyz.cgi?'7''. Single-character constant is surrounded by apostrophes.
- As a variable:'xyz.cgi?flash_my_ip'.
- As a constant: 'xyz.cgi?0x13'.
(Constant is specified as required by the given assembler,
for Intel, Keil,... use: 'xyz.cgi?13h'.)
When specifying a parameter as a variable, some compilers (Intel, Keil,...) require that the variable is declared before it is used.
html2db does not use any automatic method for declaring variables. Assembler or linker decides whether the variables are declared correctly.
Compiler from the binutils package, mcs51-as, does not require variables to be declared, but declares used variables automatically.
html2db itself extends the format of the html source code by special lines with declarations or other data that control the compilation from html to assembly.
Declaration lines begin with #:, followed by one-letter command code and a parameter in parentheses. The following commands are possible: #:C(xyz) declares external CODE variable, equal to extrn CODE(xyz) in assembly
#:D(xyz) declares external DATA variable, equal to extrn DATA(xyz) in assembly
#:X(xyz) declares external XDATA variable, equal to extrn XDATA(xyz) in assembly
#:Y(xyz) declares external IDATA variable, equal to extrn IDATA(xyz) in assembly
#:N(xyz) declares external NUMBER variable, equal to extrn NUMBER(xyz) in assembly
#:H(xyz) defines name of segment with filesystem directory, corresponds to -dir xyz
#:B(xyz) defines name of segment with filesystem data, corresponds to -body xyz
#:I(xyz) duplicates directory item name and assigns it a hash value of xyz; corresponds to -index xyz
|Web51 description||News||FAQ||ORDER FORM||DOWNLOAD||Links|
|(c)Copyright 2000 - 2002, HW server & Radek Benedikt