Technical support e-mail : mktmk<at>narod.ru.

Home page                       : http://mktmk.narod.ru.

 

 

                     Converter *.exe files

                          Users guide

                             v1.00

 

                            Summary

 

  This document describe converter from DOS-exe (MZ format) files to *.rom

format, suitable for loading to absolute addresses. For this conversion all

segment information from relocation table of *.exe file correct according to

the address of loading. Output *.rom file should be written to ROM. Also little

additional information may be write to *.rom file.

  This program can be used for create BIOS, BIOS extenders for I/O card

and another software for x86 platform based embedded systems.

  This program can use for big length *.exe files (length is more, than 64K).

 

                            Contents

 

1. General description

2. The purpose of program

3. Conditions of application

4. The problem description

5. Structure of the project

6. The input data

7. The output data

 

                            1. General description

 

  The program have command line interface. The program is tested by BC++ 5.02.

Library istream of BC++ 5.02 provide correct work with hex number "0x".

 

                            2. The purpose of program

 

  The program is intended for conversion from DOS-exe format to *.rom format,

suitable for loading to absolute addresses.

 

                            3. Conditions of application

 

  The program run under Windows like Win-console application.

For use under another platform it is necessary to correct some types:

 

typedef unsigned int       exe2rom_32;

typedef unsigned short int exe2rom_16;

typedef unsigned char      exe2rom_8;

 

From file exe2rom.h and rebuild project.

 

                            4. The problem description

 

  It is necessary to provide conversion from DOS-exe format to *.rom format,

suitable for loading to absolute addresses. For this conversion all segment

information from relocation table of *.exe file correct according to the

address of loading.

  Also it is possible collect some statistics about *.exe file (like tdump.exe)

and write to *.rom file some additional information (check sum of file,

length of file, values of SS:SP and CS:IP).

 

                            5. Structure of the project

 

   Project structure:

  

   1.  exe2rom.exe  - executed file

   2.  exe2rom.cpp  - functions - members of a class exe2rom_convert.

   3.  exe2rom1.cpp - main and functions - members of a class exe2rom_err.

   4.  exe2rom.h    - header file of the project.

   5.  comline.cpp  - functions for work with command line switch.

   6.  comline.h    - header file for comline.cpp.

   7.  alfserv.h    - declaration of structure of additional information.

   8.  clerr.h      - declaration of class for error service

   9.  readrus.txt  - this document in Russian

   10. readeng.txt  - this document in English

 

                            6. The input data

 

  The input data are set in command line. Format of command line:

 

exe2rom [-sw1 -sw2 ... -swn] input_filename output_filename report_filename

 

Usage:

exe2rom         - name of program

sw1...swn       - switch of program

input_filename  - name of input DOS-exe file

output_filename - name of output rom-file

report_filename - name of output report file

 

Hexadecimal number in switch must have leading "0x", like C-style.

 

All number in switch must be in hex format with leading "0x".

 

Switch of the program are:

 

-s0xXXXXX - start absolute address (only five hex digit). From this address the

program will be load. All segment references from relocation table of input

*.exe file correct according to this address. Address 0xXXXXX must be in hex

format with leading "0x". Last hex digit must be zero.

 

-l0xXXXXX - length of output *.rom file (five hex digit).

If output file less than the specified value, output file increase by filling.

If output file more than the specified value, output file do not increase.

If the key is not specified, output file do not increase.

 

-a0xXX - value for filling output file. By default XX=0x00.

 

-t - if this key present, additional information write to the end of

output file.

 

Format of additional information:

 

template < class T32, class T16, class T8 > struct alfserv {

T32 loadadr;

T32 lenfile;

T16 ss;

T16 sp;

T16 ip;

T16 cs;

T16 reserved;

T8 csum;

T8 lastbyte;

};

 

  The structure alfserv write to file after binary image. If switch -l0xXXXXX

present, the structure alfserv write to file before filling.

 

  Meaning of fields of structure alfserv:

 

loadadr  - start address from switch -s0xXXXXX (32 bit)

 

lenfile  - length of file with length of structure alfserv and without length

           of filling (32 bit)

 

ss       - value of segment stack from register DOS-exe file (16 bit)

 

sp       - value of stack pointer from register DOS-exe file (16 bit)

 

ip       - value of instruction pointer register from DOS-exe file (16 bit)

 

cs       - value of segment code register from DOS-exe file (16 bit)

 

reserved - reserve field (16 bit, it is equal 0x0001)

 

csum     - control sum of file (8 bit). All bytes of file are summarized.

           The fillings bytes are not summarized. Structures alfserv is

           summarized, if switch -t or -f present. Start value of csum is 1.

 

lastbyte - last byte of structure alfserv. By default is 1. May be change

           by -b switch.

 

-bXX     - last byte of structures alfserv.

 

Example:

 

exe2rom -s0x40000 example.exe example.rom

 

In this example create file example.rom from example.exe. File example.rom

should be load from physical address 0x40000.

 

-f - if this key present, additional information write to the beginning of

output file.

 

If both switch (-t and -f) present, the switch -f is valid.

 

                             7. The output data

 

   The output data are displayed to screen and write to file of report

if it is given. The program does not analyze format DOS-exe file and does not

check it. Therefore if input file have not DOS-exe format undefined behavior

is occur.