HANOI 2021: Hanoi University of Science and Technology

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF ELECTRICAL ENGINEERING

-----o0o-----

REPORT
SOFTWARE TO DISPLAY “.HEX” FILES

Course name: PROGRAMMING TECHNIQUES


Course code: EE3490E
Class code: 123135
Instructor: Nguyen Hong Quang
Student’s name (code): LE DINH HOC - 20186106
Class: Automotive Engineering – Elitech K63

HANOI 2021
Contents
I.Introduction............................................................................................................3

II.Flowchart..............................................................................................................4

III. The important point that decides the program performance.................5

IV.Result.................................................................................................................5

V.Conclusion.......................................................................................................10
I. Introduction
The program HexDisplay.exe is required to complete these tasks: The program will open a file and find
out if the file is a hex file or not? Then the program will read each line of the file and finally display the
file it's on the screen following this format:

a. First field is address of data


b. Second field is data in hex
c. Last field is data in ASCII

After each iteration of 25 lines printed, the program ask user if she wants to print next 25 lines.

What is Intel Hex File?


According to Wikipedia:

Intel hexadecimal object file format, Intel hex format or Intellec Hex is a file format that conveys binary
information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and
other types of programmable logic devices.

What is it record structure?


A record (line of text) consists of six fields (parts) that appear in order from left to right:

1. Start code, one character, an ASCII colon ':'.


2. Byte count, two hex digits (one hex digit pair), indicating the number of bytes (hex digit pairs) in
the data field. The maximum byte count is 255 (0xFF). 16 (0x10) and 32 (0x20) are commonly
used byte counts.
3. Address, four hex digits, representing the 16-bit beginning memory address offset of the data.
The physical address of the data is computed by adding this offset to a previously established
base address, thus allowing memory addressing beyond the 64 kilobyte limit of 16-bit addresses.
The base address, which defaults to zero, can be changed by various types of records. Base
addresses and address offsets are always expressed as big endian values.
4. Record type (see record types below), two hex digits, 00 to 05, defining the meaning of the data
field.
5. Data, a sequence of n bytes of data, represented by 2n hex digits. Some records omit this field (n
equals zero). The meaning and interpretation of data bytes depends on the application.
6. Checksum, two hex digits, a computed value that can be used to verify the record has no errors.
II. Flowchart

Figure 1. Flowchart of the program

1. The program opens the file and check if it is opened? If not, the program stops.
2. A buffer to store data is created.
3. Recursively take input data from file, check its validity and store in the buffer until the end of files.
4. Print data and end the program.
III. The important point that decides the
program performance.
The program runs efficiently or not depending on the performance of the functions in its source code.
The most often used function is the function to convert string to integer. The most important function is
the function that stores the data into the buffer and the most intricate function is the function used to
print data.

IV. Results

Figure 2. Start of the program


Figure 3. End of the program

Figure 4. If the program cannot open the file


Figure 5. When the program have invalid checksum

Figure 6. When the program has an invalid start code


6. Conclusion
Although facing a lot of obstacles, the program is finally done with my endless efforts in 2 weeks. The
hex file is finally processed by the program and the data is displayed on the screen.

You might also like