There are 2 part of my tasks for the week. The first task is to searching of available Java library that able to read object file format that is either Elf, S-Record or Intel-Hex. This step is very crucial for my entire project. If I couldn’t find any of these library on web, the worst case is I have to translate binary raw file format as the input before passing it to the processor.  Frankly speaking, I have never come across of these file format before, and thus, I do a roughly research on each object file format meanwhile searching for the available Java library.

Here is my short summaries of these 4 object file format.

A) Elf (Executable and Linkable format) — Elf format was originally developed and published by UNIX System Laboratories as part of the Application Binary Interface (ABI). The evolving of ELF standard as a portable object file format that works on 32-bit Intel Architecture environments for a variety of OS and also various popular game systems such as the one in Sony PlayStation systems including the PS1, PS2 and PS3 as well as the Sony PSP.

ELF is a format for storing programs or fragments of programs on disk, created as a result of executing, compiling and linking (here goes the name of ELF). Files that contain the .elf file format are system files that store executable programs, shared libraries and memory dumps. An ELF file is divided into sections. For an executable program, these are the text section for the code, the data section for global variables and the rodata section that usually contains constant strings. The ELF file contains headers that describe how these sections should be stored in memory.

B) S-record— Also know an S19.  It is an ASCII hexadecimal text encoding for binary data and it is initially created for Motorola processor. It has the similarity with Intel-hex format where both format are in text format. Each record contains checksum to detect data that has been corrupted during transmission. the first record (S0) may included arbitrary comments such as program name or version number while the last (termination record-S7, S8, S9) mayb include a starting address.

Following is the S-record format structure.

1) Start code: Represent by one character, an S.

2) Record type: One digit (from 0-9), defining the type of data field.

3) Byte count: Two hex digit, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (in the address, data and checksum fields).

4) Address: Four, six or eight digits as determined by the record type for the memory location of the first data byte. The address byte is arranged in big edian format.

5) Data: A sequence of 2n hex digits, for n bytes of data.

6) Checksum: Last two hex digits (The least significant byte of ones’ complement of the sum of the value represented by the two hex digit pairs for the byte count, address and data fields.

(Example)—–>>>  S1137AF0 0A0A0D0000000000000000000000000061

where: 13+7A+F0+0A+0A+0D+00+00+00+00+00+00+00+00+00+00+00+00+00 = 19E

C) Intel-hex— Also know as X-record format and format is similar to S-record. As mentioned above, Intel-Hex has a very similar structure format as S-record as both also text file format. It’s a file format for conveying binary information for applications. A compiler/assembler converts a program’s source code to machine code and output it into Hex file.  This file is then imported by programmer to “burn” the machine code into a ROM, or is transferred to the target system for loading and execution.

Following is the Intel-hex file format structure:

1) Record marker: One character, an ASCII colon “:”

2)Byte length: Two hex digits, a number of data byte in register.

3) Address: Four hex digits (from 0-65535) , a 16 bits address of the beginning of the memory position for the data. Added when the data should be loaded into chips.

4) Record type: two hex digits, defining the type of the data field. Total there are 6 data type from 00-05.

5) Data Bytes: A sequence of actual data that will burn into EPROM, represented by 2n hex digits.

6) Checksum: Two hex digits. To make sure the sum of all bytes are zero. Also,  to make sure these 2 hex digit is the second compliment of the sum of all proceeding data byte, excluding the checksum byte itself and the colon at the beginning.

(Example) ——–>>> :0300300002337A1E

03+00+30+00+02+33+7A = E2 ,  2’s complement is 1E. 

D) Binary— Both S-record and Intel hex are text formats. However, in this format the memory is written byte by byte which means text format can be interpreted as characters representing human-readable text while binary file which contains data that, if interpreted as characters, yields non-printable character. The binary digits (bits) of binary file are grouped in eights. It may contain any type of data (text/images, sounds, compressed version of other files etc ) encoded in binary form for computer storage and processing purposes. Binary files typically contained bytes that are intended to be interpreted as something other than text characters.

*************************************************************************************************************I was informed by supervisor I could select the Java library either from Sun/Oracle or from a 3rd person party. Unfortunately i couldn’t found any Java library that reads object file format from the official Sun/Oracle website but rather some elf file and Intel-hex file parser written in Java from a 3rd person party. I was informed by supervisor to check out their license which is very important to prevent piracy act. Besides that, I also need to check whether the code provided by these parser library is functional. After discussed with supervisor, we both agree to use the simplest code that we found and it has been tested working perfectly without any bug when loading an example hex file. Done for the first task of the week which is file loader.

Next task is to create a simple <t3ras> class which will represent my processor. This class will have 4 main variables; e.g: memory with 64 kb (65536 bytes) , MSR (2x 32 bits), program counter (2 x 32 bits), and Register (2x (32 bits x 32 bits )). I was informed not to access these variables directly,  instead write a few functions to call and invoke them. The function that should be include are get&set for each variables, reset counter and save & restore function. Each functions have its own details to be taken care of and this class is separate with the application class which will be implement in web interface in my future task list. Not to forget each important changes that I have make is committed in git so that I can trace my working tree in future easily.