Web 51 - html2db.pl

LIBW  software.html  mac2hex.pl, ip2hex.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  "...

html2db - command line parameters

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.

switchdirectoryfile
-cpuromcpu_dircpu_files
-cpueepromee_diree_files
-eepromi2c_diri2c_files

Segment names can be stated explicitly:

switchparameter
-dirsegment name
-bodysegment 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:

switchtypenote
-html1#text/html
-plain2#text/plain
-jpeg3#image/jpeg
-gif4#image/gif
-png5#image/png
-app6#application/octet-stream
-noheader0#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  "...

JavaScript The -appendlf switch affects conversion of html files only. Resulting html code will have line delimiters intact (except MS-DOS delimiters <CR><LF> which are replaced by <LF>). Default behavior is to remove all end-of-line characters; however, this also removes corresponding whitespace, assuming there is a html tag at the end of line or at the beginning of next line that separates both lines. Unless you need to shrink the html code as much as possible, it is recommended to specify -appendlf to preserve line delimiters. In addition, it is recommended to preserve line delimiters whenever JavaScript is used, since it does not like "missing" whitespaces.

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

html2db - Conversion of cgi parameters

Unless suppressed by -noconverthtml, any cgi parameters in source html files are converted. There are three ways of specifying cgi parameters:

  1. As an ASCII constant: 'xyz.cgi?'7''. Single-character constant is surrounded by apostrophes.
  2. As a variable:'xyz.cgi?flash_my_ip'.
  3. As a constant: 'xyz.cgi?0x13'.

  4. (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 - Variable declarations

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





Sponzored by LPhard Ltd. Graphics by GIMP Created by EasyPad

(c)Copyright 2000 - 2002, HW server & Radek Benedikt
Web51@HW.cz, Web51.HW.cz
LIBW  Obsah  mac2hex.pl, ip2hex.pl