HLA: The High Level Assembly Programming Language

by Paul Panks

At the eastern edge of US-60, between University Avenue and the Box Springs Mountain Park, sits the bustling University of California-Riverside (UCR) campus. A modern university, encompassing everything from botany to computer science, UCR employs some of the finest professors in the entire southwestern United States. UCR was established as a campus of the University of California in 1954. Today, it boasts an enrollment of over 17,000 students.

The High Level Assembly (HLA) programming language began at UCR in 1996 as a project of computer science professor Randall Hyde. Hyde began his project envisioning a programming language that everyone would love. He writes:

When I began writing HLA in the fall of 1996, I had visions of creating one of those "universally accepted" language projects that everyone would love. I'd get big "pats on the back" and people would talk about how great I was. [But] as the design for HLA began to solidify, and I had to make some hard decisions about compromises in the language, those visions of glory faded quickly."

Hyde released the first prototype of HLA in September 1999, designated Version 1.0. As he expected, some people voiced complaints about the new programming language. As Hyde admits:

I fully expected some people to voice rigorous complaints about the language itself. I was not disappointed. One thing, however, that I should have forseen and prepared for is the fact that a large number of people would voice complaints about HLA in total ignorance. That is, I didn't anticipate some individuals looking at some sample code and making assumptions about the language without first looking to see if those complaints were valid.

HLA was developed initially as a tool to teach assembly language programming. As Hyde notes:

The principle goal of HLA was to leverage students' existing programming knowledge. For example, good Pascal programmers can get their first C/C++ program operational in a few minutes. In HLA, I wanted to create a language with high level control structures and declarations that made it possible for someone familiar with an imperative language like Pascal or C/C++ to get their first HLA programming running in a matter of minutes (or, at worst, a matter of hours). Of course, to achieve this goal, I needed to add high-level data declarations and high-level control constructs to the HLA language.

But how does HLA differ from other High Level Assembly languages? According to Hyde, the differences are fairly complex. He notes:

HLA/86 probably falls in the high-level-to-very-high-level range because it provides high level data types and data structuring abilities, high level and very high level control structures, extensive parameter passing facilities (more than most high level languages), a very extensive compile time language, a very extensive standard library, built-in parsing facilities for language extension, and many other features.

The average programmer starting out on HLA no doubt will be reading the HLA Standard Reference Manual for quite awhile before he or she begins to write the first HLA program. I myself spent over two hours simply reading and taking notes on how assembly differed from BASIC, C/C++ and Pascal, other languages I had tried previously. The learning curve was indeed steep, but the rewards were worth it. As I noted on my project page for my game HLA Adventure, "HLA stands for High Level Assembly, and it's a great way for people to learn assembly without being submerged off the bat in offsets, memory locations and MOV instructions."

HLA Adventure is one of many HLA-related projects now being developed by programmers around the world. For example, Sevag Krikorian is developing HIDE, an integrated development environment for use in coding, debugging and compiling HLA programs. HIDE even was written in HLA.

For those interested in learning more about HLA and the Art of Assembly Language programming, Yahoo Groups offers aoaprogramming, which, as the Web site states, is a "forum for those interested in learning and working with Randall Hyde's HLA assembler." At the time of this writing, aoaprogramming had over 1,089 members.

HLA currently is available for both Windows and Linux. First introduced by Hyde in March of 2002, the Linux version of HLA eventually incorporated console-mode functions usable in both Windows and Linux. This change allowed console programs relying on specific console mode functions to be compiled successfully under both Windows and Linux. As Hyde notes, "The VT100 terminals emulation that Linux supports has only a subset of the capabilities of the original HLA Console library, so many things are not implemented from the old library."

A simple HLA program, called test.hla and using standard console-mode functions, might contain the following code:

>

// Player vs. Dragon demo. An example of HLA code.
// ------------------------------------------------------
// Sample game introduction of "Player vs. Dragon".
// ------------------------------------------------------
program west;
// ------------------------------------------------------
// Include files "console.hhf" and "stdlib.hhf" into
// the program.
// ------------------------------------------------------
#include("console.hhf");
#include("stdlib.hhf");
// ------------------------------------------------------
// Begin program "west".
// ------------------------------------------------------
begin west;
// ------------------------------------------------------
// Set console foreground color to white, background
// to blue.
// ------------------------------------------------------
console.setAttrs( console.white, console.blue );
// ------------------------------------------------------
// Clear the console screen.
// ------------------------------------------------------
console.cls();
// ------------------------------------------------------
// Start the main loop of the program, designated
// "mainlp".
// ------------------------------------------------------
mainlp:
// ------------------------------------------------------
// Change foreground color to green, background to blue.
// ------------------------------------------------------
console.setAttrs( console.green, console.blue );
// ------------------------------------------------------
// Use "stdout.puts" to display text on the console
// mode screen. "nl" means "next line".
// ------------------------------------------------------
stdout.puts("A green dragon approaches, spreading her wings high" nl);
stdout.puts("across the landscape, plunging it into darkness! The" nl);
stdout.puts("dragon looks at you and says:");
// ------------------------------------------------------
// Change foreground color to yellow, background to blue.
// ------------------------------------------------------
console.setAttrs( console.yellow, console.blue );
// ------------------------------------------------------
// Use "stdout.puts" to display more text.
// ------------------------------------------------------
stdout.puts(" 'I am the last of my kind." nl);
stdout.puts("Here you are, a human, come here to slay me?! I breathe" nl);
stdout.puts("fire upon trees, rustling the bad kami out of the forests" nl);
stdout.puts("and valleys of this forgotten world. I keep my peace inside" nl);
stdout.puts("these caves, only to be disturbed by your species which" nl);
stdout.puts("pollute this landscape! I was once happy in my silence" nl);
stdout.puts("here, yet you come to make me miserable! I won't allow" nl);
stdout.puts("it, knave! Prepare to feel my wrath!!!'" nl);
// ------------------------------------------------------
// Change foreground color to cyan, background to blue.
// ------------------------------------------------------
console.setAttrs( console.cyan, console.blue );
// ------------------------------------------------------
// Use "stdout.puts" to display a brief message.
// ------------------------------------------------------
stdout.puts("The dragon moves about angrily, stomping the floor!" nl);
// ------------------------------------------------------
// Change foreground color to white, background to blue.
// ------------------------------------------------------
console.setAttrs( console.white, console.blue );
// ------------------------------------------------------
// Use "stdout.puts" to display another message.
// ------------------------------------------------------
stdout.puts("What now, adventurer?" nl);
// ------------------------------------------------------
// End the program. Total lines: 75. Bytes: 3,895.
// ------------------------------------------------------
end west;

What this program does is change the background color of the screen to blue, setting various other color registers to green, yellow, cyan and white. It then outputs text to the screen via the command stdout.puts, which is similar to how C++ handles string output. Also, notice the use of nl at the end of some lines. This stands for next line, moving the cursor one line down, like a carriage return.

This simple example shows a limited subset of the entire HLA Standard Library, which incorporates everything from file I/O to popping the stack, switching register values and other traditional assembly language commands. With a larger understanding of HLA, it is possible to write almost anything in HLA, including versions of HLA itself.

HLA also can use a variety of freeware and shareware assemblers, such as MASM, FASM and Gas. For those curious, assemblers are tools that help create binary files, which then can run independent of HLA. The best part about HLA is it is a constantly evolving programming language. In fact, HLA will soon reach version 2.0. This version is reported to be significantly faster than current versions. For now, version 1.76 of HLA is available freely from Hyde's Web site. HLA can be installed under Linux after reading the HLA Installation Guide.

HLA is a robust, complete programming language. As Hyde has written:

The HLA (High Level Assembly) language was developed as a tool to help teach assembly language programming and machine organization to University students at the University of California, Riverside. The basic idea was to teach students assembly language programming by leveraging their knowledge of high level languages like C/C++ and Pascal /Delphi. At the same time, HLA was designed to allow advanced assembly language programmers write more readable and more powerful assembly language code.

For Linux users, HLA is a strong programming tool that allows them to create powerful programs on a variety of different levels. As HLA becomes more feature-rich, additional applications will be written using HLA under Linux. With HLA and Linux, programmers can develop new and exciting applications anyone can use.

Load Disqus comments

Firstwave Cloud