High Level Assembly
   HOME

TheInfoList



OR:

High Level Assembly (HLA) is a
language Language is a structured system of communication. The structure of a language is its grammar and the free components are its vocabulary. Languages are the primary means by which humans communicate, and may be conveyed through a variety of met ...
developed by Randall Hyde that allows the use of higher-level language constructs to aid both beginners and advanced assembly developers. It fully supports advanced
data type In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
s and
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of pr ...
. It uses a syntax loosely based on several
high-level programming language In computer science, a high-level programming language is a programming language with strong Abstraction (computer science), abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language ...
s (HLLs), such as
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, Fren ...
,
Ada Ada may refer to: Places Africa * Ada Foah, a town in Ghana * Ada (Ghana parliament constituency) * Ada, Osun, a town in Nigeria Asia * Ada, Urmia, a village in West Azerbaijan Province, Iran * Ada, Karaman, a village in Karaman Province, ...
,
Modula-2 Modula-2 is a structured, procedural programming language developed between 1977 and 1985/8 by Niklaus Wirth at ETH Zurich. It was created as the language for the operating system and application software of the Lilith personal workstation. It w ...
, and
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
, to allow creating readable assembly language programs, and to allow HLL programmers to learn HLA as fast as possible.


Origins and goals

HLA was originally conceived as a tool to teach assembly language programming at the college-university level. The goal is to leverage students' existing programming knowledge when learning assembly language to get them up to speed as fast as possible. Most students taking an assembly language programming course have already been introduced to high-level
control flow In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an ''imper ...
structures, such as IF, WHILE, FOR, etc. HLA allows students to immediately apply that programming knowledge to assembly language coding early in their course, allowing them to master other prerequisite subjects in assembly before learning how to code low-level forms of these control structures. The book ''The Art of Assembly Language Programming'' by Randall Hyde uses HLA for this purpose.


High vs. low-level assembler

The HLA v2.x assembler supports the same low-level machine instructions as a regular low-level assembler, while high-end assemblers also support high-level-language-like statements, such as IF, WHILE, and so on, and fancier data declaration directives, such as
structures A structure is an arrangement and organization of interrelated elements in a material object or system, or the object or system so organized. Material structures include man-made objects such as buildings and machines and natural objects such as ...
-
records A record, recording or records may refer to: An item or collection of data Computing * Record (computer science), a data structure ** Record, or row (database), a set of fields in a database related to one entity ** Boot sector or boot record, ...
, unions, and even classes. Some examples of high-end assemblers are HLA,
Microsoft Macro Assembler The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for MS-DOS and Microsoft Windows. Beginning with MASM 8.0, there are two versions of the assembler: One for 16-bit & 32-bit assembly sources, and another (ML64) fo ...
(MASM), and the
Turbo Assembler Turbo Assembler (sometimes shortened to the name of the executable, TASM) is an assembler for software development published by Borland in 1989. It runs on and produces code for 16- or 32-bit x86 MS-DOS and compatible on Microsoft Windows. It ...
(TASM) on the Intel
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel based on the Intel 8086 microprocessor and its 8088 variant. The 8086 was introd ...
processor family, Unlike most other assembler tools, the HLA compiler includes a ''Standard Library'' with thousands of functions, procedures, and macros that can be used to create full applications with the ease of a high-level language. While assembly language
libraries A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
are not new, a language that includes a large standardized library encourages programmers to use the library code rather than simply writing their own library functions. HLA supports all the same low-level machine instructions as other x86 assemblers. Furthermore, HLA's high-level control structures are based on the ones found in MASM and TASM, which HLL-like features predated the arrival of HLA by several years. In HLA, low-level assembly code can be written as easily as with any other assembler by simply ignoring the HLL-control constructs. In contrast to HLLs like Pascal and C(++), HLA doesn't require inline asm statements. In HLA, HLL-like features appear to provide a learning aid for beginning assembly programmers by smoothing the learning curve, with the assumption that they will discontinue the use of those statements once they master the low-level instruction set. In practice, many experienced programmers continue to use HLL-like statements in HLA, MASM, and TASM, long after mastering the low-level instruction set, but this is usually done to improve readability. It is also possible to write ''high-level'' programs using HLA, avoiding much of the tedium of low-level assembly language programming. Some assembly language programmers reject HLA out of hand, because it allows programmers to do this. However, supporting both high-level and low-level programming gives any language an expanded range of applicability.


Distinguishing features

Two HLA features set it apart from other x86 assemblers: its powerful macro system (compile-time language) and the HLA Standard Library.


Macro system

HLA's compile-time language allows extending the language with ease, even creating small
domain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging f ...
s to help easily solve common programming problems. The macro stdout.put is a good example of a sophisticated macro that can simplify programming. Consider the following invocation of that macro: stdout.put( "I=", i, " s=", s, " u=", u, " r=", r:10:2, nl ); The stdout.put macro processes each of the arguments to determine the argument's type and then calls an appropriate procedure in the HLA Standard library to handle the output of each of these operands. Most assemblers provide some sort of macro ability: the advantage that HLA offers over other assemblers is that it can process macro arguments like r:10:2 using HLA's extensive compile-time string functions, and HLA's macro facilities can infer the types of variables and use that information to direct macro expansion. HLA's macro language provides a special ''Context-Free'' macro facility. This feature allows easily writing macros that span other sections of code via a ''starting'' and ''terminating'' macro pair (along with optional ''intermediate'' macro invocations that are only available between the start–terminate macros). For example, one can write a fully recursive-nestable SWITCH–CASE–DEFAULT–ENDSWITCH statement using this macro facility. Because of the HLA macro facilities context-free design, these switch..case..default..endswitch statements can be nested, and the nested statements' emitted code will not conflict with the outside statements.


Compile-Time Language

The HLA macro system is actually a subset of a larger feature known as the HLA ''Compile-Time Language'' (CTL). The HLA CTL is an interpreted language that is available in an HLA program source file. An interpreter executes HLA CTL statements during the compiling of an HLA source file; hence the name ''compile-time language''. The HLA CTL includes many control statements such as #IF, #WHILE, #FOR, #PRINT, an
assignment statement In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. In most imperative programming languages, the assi ...
and so on. One can also create compile-time variables and constants (including structured data types such as records and unions). The HLA CTL also provides hundreds of built-in functions (including a very rich set of string and pattern-matching functions). The HLA CTL allows programmers to create CTL ''programs'' that scan and parse strings, allowing those programmers to create ''embedded
domain specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
s'' (EDSLs, also termed ''
mini-language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
s''). The stdout.put macro appearing earlier is an example of such an EDSL. The put macro (in the stdout namespace, hence the name ''stdout''.put) parses its macro parameter list and emits the code that will print its operands.


Standard library

The HLA Standard Library is an extensive set of pre-made routines and macros (like the stdout.put macro described above) that make life easier for programmers, saving them from starting from scratch every time they write a new application. Perhaps just as important, the HLA Standard Library allows programmers to write portable applications that run under Windows or Linux with nothing more than recompiling the
source code In computing, source code, or simply code, is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the wo ...
. Like the
C standard library The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard.ISO/IEC (2018). '' ISO/IEC 9899:2018(E): Programming Languages - C §7'' Starting from the original ANSI C standard, it wa ...
for the programming language C, the HLA Standard Library allows users to abstract away low-level
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
(OS) calls, so the same set of OS
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how t ...
s (APIs) can serve for all operating systems that HLA supports. While an assembly language allows making any needed OS calls, where programs use the HLA Standard Library API set, writing OS-portable programs is easy. The HLA Standard Library provides thousands of functions, procedures, and macros. While the list changes over time, as of mid-2010 for HLA v2.12, it included functions in these categories: * Command-line argument processing * Array (dynamic) declaration and manipulation * Bit manipulation * Blob (binary large object) manipulation * Character manipulation * Conversions * Character set manipulation * Date and time functions * Object-oriented file I/O * Standard file I/O * File system manipulation functions, e.g., delete, rename, change directory * HLA-related declarations and functions * The HLA Object Windows Library: object-oriented framework for Win32 programming * Linked list manipulation * Mathematical functions * Memory allocation and management * FreeBSD-specific APIs * Linux-specific APIs * MacOS-specific APIs * Win32-specific APIs * Text console functions * Coroutine support * Environment variable support * Exception handling support * Memory-mapped file support * Sockets and client–server object support * Thread and synchronization support * Timer functions * Pattern matching support for regular expressions and context-free languages * Random number generators * Remote procedure call support * Standard error output functions * Standard output functions * Standard input functions * String functions * Table (associative) support * Zero-terminated string functions


Design

The HLA v2.x language system is a command-line driven tool that consists of several components, including a ''shell'' program (e.g., hla.exe under Windows), the HLA language compiler (e.g., hlaparse.exe), a low-level translator (e.g., the HLABE, or HLA Back Engine), a
linker Linker or linkers may refer to: Computing * Linker (computing), a computer program that takes one or more object files generated by a compiler or generated by an assembler and links them with libraries, generating an executable program or shar ...
(link.exe under Windows, ld under Linux), and other tools such as a resource compiler for Windows. Versions before 2.0 relied on an external assembler back end; versions 2.x and later of HLA use the built-in HLABE as the back-end object code formatter. The HLA ''shell'' application processes command line parameters and routes appropriate files to each of the programs that make up the HLA system. It accepts as input .hla files (HLA source files), .asm files (source files for MASM, TASM, FASM, NASM, or Gas assemblers), .obj files for input to the linker, and .rc files (for use by a resource compiler).


Source code translation

Originally, the HLA v1.x tool compiled its source code into an intermediate source file that a ''back-end'' assembler such as MASM, TASM, flat assembler (
FASM FASM (''flat assembler'') is an assembler for x86 processors. It supports Intel-style assembly language on the IA-32 and x86-64 computer architectures. It claims high speed, size optimizations, operating system (OS) portability, and macro abil ...
),
Netwide Assembler The Netwide Assembler (NASM) is an assembler and disassembler for the Intel x86 architecture. It can be used to write 16-bit, 32-bit (IA-32) and 64-bit (x86-64) programs. It is considered one of the most popular assemblers for Linux. It was ori ...
(NASM), or
GNU Assembler The GNU Assembler, commonly known as gas or as, is the assembler developed by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part of ...
(Gas) would translate into the low-level object code file. As of HLA v2.0, HLA included its own ''HLA Back Engine'' (HLABE) that provided the low-level object code translation. However, via various command-line parameters, HLA v2.x still has the ability to translate an HLA source file into a source file that is compatible with one of these other assemblers.


HLA Back Engine

The HLA Back Engine (HLABE) is a compiler back end that translates an internal intermediate language into low-level
Portable Executable The Portable Executable (PE) format is a file format for executables, object code, DLLs and others used in 32-bit and 64-bit versions of Windows operating systems. The PE format is a data structure that encapsulates the information necessary fo ...
(PE), Common Object File Format (
COFF The Common Object File Format (COFF) is a format for executable, object code, and shared library computer files used on Unix systems. It was introduced in Unix System V, replaced the previously used a.out format, and formed the basis for exte ...
),
Executable and Linkable Format In computing, the Executable and Linkable FormatTool Interface Standard (TIS) Portable Formats SpecificationVersion 1.1'' (October 1993) (ELF, formerly named Extensible Linking Format), is a common standard file format for executable files, obj ...
(ELF), or
Mach-O Mach-O, short for Mach object file format, is a file format for executables, object code, shared libraries, dynamically-loaded code, and core dumps. It was developed to replace the a.out format. Mach-O is used by some systems based on the M ...
object code. An HLABE ''program'' mostly consists of data (byte) emission statements, 32-bit relocatable address statements, x86 control-transfer instructions, and various directives. In addition to translating the byte and relocatable address statements into the low-level object code format, HLABE also handles branch-displacement optimization (picking the shortest possible form of a branch instruction). Although the HLABE is incorporated into the HLA v2.x compiler, it is actually a separate product. It is public domain and open source (hosted on
SourceForge.net SourceForge is a web service that offers software consumers a centralized online location to control and manage open-source software projects and research business software. It provides source code repository hosting, bug tracking, mirroring ...
).


See also

*
Comparison of assemblers This is an incomplete list of assemblers: computer programs that translate assembly language source code into binary programs. Some assemblers are components of a compiler system for a high level language and may have limited or no usable functio ...


Notes


References

* Richard Blum, ''Professional assembly language'', Wiley, 2005, , p. 42 * Randall Hyde, ''Write Great Code: Understanding the machine'',
No Starch Press No Starch Press is an American publishing company, specializing in technical literature often geared towards the geek, hacker, and DIY subcultures. Popular titles include '' Hacking: The Art of Exploitation'', Andrew Huang's ''Hacking the Xbox' ...
, 2004, , pp. 14–15 and used throughout the book * Randall Hyde, ''The Art of Assembly Language, 2nd Edition'',
No Starch Press No Starch Press is an American publishing company, specializing in technical literature often geared towards the geek, hacker, and DIY subcultures. Popular titles include '' Hacking: The Art of Exploitation'', Andrew Huang's ''Hacking the Xbox' ...
, 2010, , used throughout the book


Further reading

* Paul Panks (June 29, 2005),
HLA: The High Level Assembly Programming Language
',
Linux Journal ''Linux Journal'' (''LJ'') is an American monthly technology magazine originally published by Specialized System Consultants, Inc. (SSC) in Seattle, Washington since 1994. In December 2006 the publisher changed to Belltown Media, Inc. in Houston ...


External links

*
Downloads for Windows, macOS, and Linux
{{X86 assembly topics Assemblers Assembly languages Public-domain software High-level programming languages