Amiga Hunk
Encyclopedia
Hunk is the executable
Executable
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions," as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU...

 file format
File format
A file format is a particular way that information is encoded for storage in a computer file.Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice-versa. There are different kinds of formats for...

 of tools and programs of the Amiga Operating System
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 based on Motorola
Motorola
Motorola, Inc. was an American multinational telecommunications company based in Schaumburg, Illinois, which was eventually divided into two independent public companies, Motorola Mobility and Motorola Solutions on January 4, 2011, after losing $4.3 billion from 2007 to 2009...

 68000 CPU and other processors of the same family.
This kind of executable got its name from the fact that the software programmed on Amiga is divided in its internal structure into many pieces called hunks, in which every portion could contain either code or data.

Hunk structure

The hunks in an Amiga executable file could exist in various types. There are 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

 hunks, 16-bit
16-bit
-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...

 hunks, and even some 8-bit
8-bit
The first widely adopted 8-bit microprocessor was the Intel 8080, being used in many hobbyist computers of the late 1970s and early 1980s, often running the CP/M operating system. The Zilog Z80 and the Motorola 6800 were also used in similar computers...

 hunks.

Types of hunks were standardized in AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

, and well documented in The AmigaDOS Manual edited by Commodore
Commodore International
Commodore is the commonly used name for Commodore Business Machines , the U.S.-based home computer manufacturer and electronics manufacturer headquartered in West Chester, Pennsylvania, which also housed Commodore's corporate parent company, Commodore International Limited...

 to explain to programmers how to code on the Amiga, during the years in which Commodore manufactured Amiga computers. Their structure was officially codified and could be changed only by a Commodore committee, which then communicated the modifications to the developers for new releases of the Amiga operating system.

The structure of an Amiga hunk is very simple: There is a header at the beginning of the hunk indicating that that kind of "portion of code" is a known and valid Amiga hunk type, then follows an ID which indicates the length of the hunk itself, and at the bottom is the segment of the hunk which contains the real code or data.

Features of Amiga executable files

Amiga executable files can be launched either from the graphical shell of the Amiga, the Workbench
Workbench (AmigaOS)
-Overview:Commodore named their Amiga computer's first operating system Workbench 1.0 and continued with the Workbench name until version 3.1, when it was changed to AmigaOS, prompted by Apple renaming their propriety OS from "System" to "MacOS"...

, from the Amiga's command line interpreter (called CLI, later AmigaShell), or even from a file manager
File manager
A file manager or file browser is a computer program that provides a user interface to work with file systems. The most common operations performed on files or groups of files are: create, open, edit, view, print, play, rename, move, copy, delete, search/find, and modify file attributes, properties...

 tool.

No particular filename extension is required for Amiga executable files. For example, the calculator applet "Calculator" can be renamed to "Calculator.com", "Calculator.exe", "Calculator.bin", or even "Calculator.jpeg". These are all valid names for programs or tools, because AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 does not differentiate between file extensions.

Some operating systems, such as MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

 or Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

, need filename extensions to recognize that a file is an executable. Usually, this extension is a three-character acronym separated from the real filename by a period ".".

AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 adopted another method to recognize it is dealing with a valid executable. There is a particular sequence of bytes in the file header, yielding the hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

 value $000003f3. This sequence, which signifies an executable file and lets it be self-running, is called a magic cookie (from the magic cookies in Alice's Adventures in Wonderland
Alice's Adventures in Wonderland
Alice's Adventures in Wonderland is an 1865 novel written by English author Charles Lutwidge Dodgson under the pseudonym Lewis Carroll. It tells of a girl named Alice who falls down a rabbit hole into a fantasy world populated by peculiar, anthropomorphic creatures...

 by Lewis Carroll
Lewis Carroll
Charles Lutwidge Dodgson , better known by the pseudonym Lewis Carroll , was an English author, mathematician, logician, Anglican deacon and photographer. His most famous writings are Alice's Adventures in Wonderland and its sequel Through the Looking-Glass, as well as the poems "The Hunting of the...

).

This kind of solution to identify executables on the Amiga was taken from similar solutions which were adopted by UNIX
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

/Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 operating systems, where magic cookies are called magic numbers.

In Unix, a file attribute
File attribute
A file attribute is metadata that describes or is associated with a computer file. For example, an operating system often keeps track of the date a file was created and last modified, as well as the file's size and extension . File permissions are also kept track of...

 bit "x" (for eXecutable) must also be set, only in this case the operating system will check the magic number. If there is a correct magic number in the beginning of the file it is considered a binary executable. If a file starts with characters "#!" then it is considered to be a script instead.

Structure of an Amiga executable file

The internal structure of an Amiga executable file is very simple. In the beginning of the file there is the magic cookie, then is declared the total number of hunks in the executable, and just after this is the progressive numbers of hunks starting from "0" (zero).

The first hunk is always numbered zero, so if the executable is (for example) subdivided into three hunks, they will be numbered "0" for the first one, "1" the second and "2" the third hunk, and so on.

Just before the real hunks start is a table containing information about the length of any hunks present in the executable, and in the last part of the file are positioned the real hunks, each one described by its type name: HUNK_CODE, HUNK_DATA, et cetera.

Representation of the structure:
Magic Cookie Total number of hunks Progressive number of hunks Table of length Various Hunks (Hunk_Code, Hunk_Data, etc)

Hunk Types

Known hunk types for the Amiga are:
Name Value (decimal) Value (hex)
HUNK_UNIT 999 3E7
HUNK_NAME 1000 3E8
HUNK_CODE 1001 3E9
HUNK_DATA 1002 3EA
HUNK_BSS 1003 3EB
HUNK_RELOC32 1004 3EC
HUNK_RELOC16 1005 3ED
HUNK_RELOC8 1006 3EE
HUNK_EXT 1007 3EF
HUNK_SYMBOL 1008 3F0
HUNK_DEBUG 1009 3F1
HUNK_END 1010 3F2
HUNK_HEADER 1011 3F3
HUNK_OVERLAY 1013 3F5
HUNK_BREAK 1014 3F6
HUNK_DREL32 1015 3F7
HUNK_DREL16 1016 3F8
HUNK_DREL8 1017 3F9
HUNK_LIB 1018 3FA
HUNK_INDEX 1019 3FB
HUNK_RELOC32SHORT 1020 3FC
HUNK_RELRELOC32 1021 3FD
HUNK_ABSRELOC16 1022 3FE
HUNK_PPC_CODE 1257 4E9
HUNK_RELRELOC26 1260 4EC

Metadata

Amiga could save metadata into hunks, as the hunk structure could be easily adapted to support this feature, but the hunk format of executables was abandoned in favour of ELF
Executable and Linkable Format
In computing, the Executable and Linkable Format is a common standard file format for executables, object code, shared libraries, and core dumps. First published in the System V Application Binary Interface specification, and later in the Tool Interface Standard, it was quickly accepted among...

 and there is no central authority (as the dismissed Commodore) which could implement this feature as one of the Amiga standards.

Amiga saves some metadata into sidecar file
Sidecar file
Sidecar files, also known as buddy files or connected files, are files which store data which is not supported by the source file format.For each source file one or more sidecar files can be created...

s known as ".info" (so called from the name of their extension suffix).

".info" files are created any time a project (datafile) is saved on disk. Example: When user saves a file called "MyProject" there will be created two files on disk called "MyProject" and MyProject.info".

Into the "MyProject" file are saved real data of the project file, while in "MyProject.info" file there will be stored the icon, and the information regarding the software which originated the file, so any time the project icon is invoked by clicking on it with mouse, there will be opened the parent software (users can change any time this information, allowing other programs to believe they created the project file rather than the original software which physically created it).

Into AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 does not exist Application Binding as in other systems like MacOS.

Into the ".info" file are stored also some particular characteristics of the project file and the user comments.

".info" files do not appear on the Workbench Screen (Workbench is the default Amiga Desktop GUI). On the desktop screen it appears only the icon of the project file taken out of the "info file". In fact the icon is the virtual medium that connects the project itself and the metadata stored into ".info".

When the user clicks on the icon with left button of the mouse, the project ".info" calls the program which originated it. When the user clicks on the icon with the right button, then a dialog box will appear, allowing the user to interact with metadata contained into ".info file".

The ".info" files are copied or moved together with their associated project file, by moving the icon with the mouse, and can be viewed as standalone file through command line interfaces of Amiga such as AmigaShell, or using third party filemanagers or directory listers like Directory Opus
Directory Opus
Directory Opus is a popular file manager program, originally written for the Amiga computer system in the early to mid 1990s...

 or DiskMaster.

If the ".info" file represents an executable program, then into the ".info" are stored information about the stack of RAM buffers that could be reserved to the executable file (exp: 4096 or 8192 or 16384 or more bytes of RAM) and even the arguments that could be invoked by using a command line interface. For example into Amiga it is usual that a program could open its own graphic user interface screen independent from the desktop sceeen. By invoking arguments such as "Screen=800x600" and "Depth=8" into the info file dialog box, the user can save these informations into the associated ".info file" and then AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 will open any time the productivity software into its own screen sized 800×600 with 8 bytes of colour depth (equal to 256 colors).

The same behaviour is obtained by invoking the productivity software into a command line interface by typing "nameofproductivitysoftware /screen800x600 /depth8".

This method of storing arguments associated with software into preference informations contained in ".info" files allows the Amiga users to use either command line interfaces or GUI graphical interfaces at the same time obtaining same results.

The user has also the choice of deleting ".info" files, but then he will renounce the benefits of having an icon representing the project file on the desktop, and will renounce to all the metadata contained into it.

Icons

A brief view of the bitmap icons contained into ".info" metadata files:

The icons are RAW bitmap data contained into ".info" files and are not standard Amiga IFF
Interchange File Format
Interchange File Format , is a generic container file format originally introduced by the Electronic Arts company in 1985 in order to ease transfer of data between software produced by different companies....

/LBM
ILBM
ILBM is a subtype of the Interchange File Format used for storing picture data. ILBM stands for InterLeaved BitMap which refers to the way the pictures are stored. The image data is stored as a varying number of bitplanes, each storing one bit of data for each pixel in the image...

 files. The users can deal with icons by using the AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 standard program "IconEdit", present into O.S. since its early versions. Starting from AmigaOS 2.0 version IconEdit could import and save normal IFF/LBM files that are standard into Amiga.

Some Amiga programs like Personal Paint from Cloanto are capable to view, load and save bitmap data as normal Amiga Icons or into Amiga ".info" files already existing.

Legacy Amiga Icons can have two-state icons, using two different bitmap images. The first bitmap contains data of "quiet" icon, also known as "quiet state" of the icon. The second bitmap image contains data for the "selected" state of the icon. When user clicks on an icon and activates it, then the quiet icon bitmap data is suddenly replaced by selected icon bitmap data. Such a behaviour gives the Amiga icons an effect of moving cartoons.
In case this second bitmap does not exist in the ".info" file (it is not mandatory to create both bitmaps), then an inverse color effect is used when the icon is selected.

Third-party icon "engines" exist, which tries to keep the look of AmigaOS up to date to modern standards of other Operating Systems. These programs patches the OS routines dedicated to icon handling, replacing them with custom ones.
One of such attempts, NewIcons
NewIcons
NewIcons is a third-party extension to the icon handling system for AmigaOS 2 and newer. NewIcons was first invented and developed by the Italian programmer Nicola Salmoria. Subsequent development was done by Eric Sauvageau.-History:...

, has become almost the new de-facto standard for AmigaOS 3.x. It was so popular that the new icon system used in AmigaOS 3.5 and above, GlowIcons, is based on its icon file format.

All modern Amiga-like operating systems (AmigaOS 4
AmigaOS 4
AmigaOS 4, , is a line of Amiga operating systems which runs on PowerPC microprocessors. It is mainly based on AmigaOS 3.1 source code, and partially on version 3.9 developed by Haage & Partner...

, MorphOS
MorphOS
MorphOS is an Amiga-compatible computer operating system. It is a mixed proprietary and open source OS produced for the Pegasos PowerPC processor based computer, PowerUP accelerator equipped Amiga computers, and a series of Freescale development boards that use the Genesi firmware, including the...

 and AROS
Aros
Aros may refer to:*Aros , a river in J. R. R. Tolkien's Middle-earth legendarium*AROS Research Operating System, a free software implementation of AmigaOS* Aros, the original Viking name of Aarhus, the second largest city in Denmark...

) could associate either RAW bitmap data, IFF/LBM files or also PNG files as standard internal bitmap image of any icon.

Overlayed executables

The HUNK_OVERLAY type was intended to reduce the amount of RAM needed to run a program. Executables with an overlay structure have a root node which is in memory at all times, and the rest of the program is split into smaller modules which are loaded and unloaded automatically when needed.

The Overlay format works by adding little stubs to code so that when they branch into a sub-module, it calls an overlay manager, which loads the requisite module. Commodore defined a standard overlay manager so that C code could automatically have these stubs inserted, and also generate an overlay table, which the standard overlay manager knew how to read.

However, the Overlay format was rarely used, especially in the way it was intended. It was more commonly used with a custom overlay manager. A popular use of overlay format was with the Titanics Cruncher, which compressed executables. Instead of loading the entire compressed executable into memory before unpacking, the Titanics Cruncher used an overlay, so only a tiny decruncher was loaded into memory, then it read and decompressed data as it went.

Other executable file formats used on Amiga

With third party add-ons AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 up to 3.9 recognizes various kinds of executable files other than Hunk format created for Motorola 68000.

ELF

Phase5
Phase5
Phase5 Digital Products was a computer hardware manufacturer that made boards for the Amiga computer. Their best known products were accelerator boards which replaced the CPU with a faster model...

 implemented ELF excutables for its PowerUP accelerator boards. It was found cumbersome due to its dynamic linking. This format was then adopted as standard by AmigaOS 4.0, MorphOS
MorphOS
MorphOS is an Amiga-compatible computer operating system. It is a mixed proprietary and open source OS produced for the Pegasos PowerPC processor based computer, PowerUP accelerator equipped Amiga computers, and a series of Freescale development boards that use the Genesi firmware, including the...

 and AROS
Aros
Aros may refer to:*Aros , a river in J. R. R. Tolkien's Middle-earth legendarium*AROS Research Operating System, a free software implementation of AmigaOS* Aros, the original Viking name of Aarhus, the second largest city in Denmark...

. ELF support was added to WarpUp by 3rd party developers and Hyperion Entertainment released number of WarpUp games in ELF format only.

Extended Hunk format

In 1997 Haage & Partner developer WarpUp PowerPC kernel for PowerUP accelerator boards. Instead of ELF binary format they had chosen to expand existing hunk format. Problem with ELF binary format was that users had to patch their system to load ELF executables and mixing PPC/68k code was not possible. Extended Hunk Format developed by Haage & Partner allowed mixing PPC and 68k code to single executable without modifying the existing system if PowerPC accelerator was not installed.
.

AmigaOS 4.0 and MorphOS

AmigaOS 4.0 and MorphOS
MorphOS
MorphOS is an Amiga-compatible computer operating system. It is a mixed proprietary and open source OS produced for the Pegasos PowerPC processor based computer, PowerUP accelerator equipped Amiga computers, and a series of Freescale development boards that use the Genesi firmware, including the...

 can run ELF natively, but as these systems were designed to run on PowerPC processor-based machines, the developers added also compatibility for WarpUP software, used in AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 3.9. In addition MorphOS implements PowerUp software compatibility as implemented by Phase5 for PowerUP accelerator cards.

Both new operating systems could also run Amiga Hunk format because they implemented internally the old Amiga API environment based on AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

 3.1, and can run 68000 code through emulators equipped with internal JITM (Just In Time Machine) which maps all instruction sets of the 680X0 family, much enhancing the emulation speed. The JIT machine of AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

is called Petunia. The one running on MorphOS is called Trance.
  • Notes:

  1. See also pages regarding history of the PPC processor on Amiga at Amiga.History site.
  2. EHF specifications on Haage&Partners site.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK