HLA isn't quite yet a polished commercial application. Most of the development of HLA has gone into the development of the language and compiler itself, rather than ancillary tools. One area where this is painfull obvious is the installation of HLA. Correcting this deficiency has not been a high priority simply because installation is something you only have to fight with once (and installing updates to HLA is trivial once you install it the first time). The following information describes how to manually install and run HLA on a typical Windows system.
Most of this document involves installing HLA manually. For those who prefer painless installation, there is an HLA installer program available that automatically installs HLA and initializes the registry entries as required by HLA. This is probably the best solution for first time users of HLA under Windows. 95% of all installation problems occur because a first-time user decides to install HLA manually. Manual installation is not recommended if you've never before installed HLA; manual installation is intended for those who are upgrading HLA or those advanced users that want to understand every change made to their system. The decision to install manually should not be taken lightly. It's considerable more work and much more prone to error.
Note that automatic installation is available only to Windows users. Linux users, alas, will need to install HLA manually. If you're a Linux user, please check out the appropriate sections later in this document.
To install the Windows version of HLA, go to the HLA download page (at the web address: http://webster.cs.ucr.edu/AsmTools/HLA/dnld.html). If you're a first time user who is learning assembly language programming using The Art of Assembly Language, you'll probably want to grab the HLA v1.99 version of the software; if you're an experienced HLA programmer, you'll probably want to grab the latest version of the software that includes a newer version of the HLA standard library (which is slightly incompatible with The Art of Assembly Language). Click on the "hlasetup.exe" link. This downloads a self-extracting version of the HLA installation program and other useful tools and documentation.
Note: make sure you download the "HLASETUP.EXE" file, not the "HLA Executables for Windows" module under "HLA Upgrade for Windows". This latter file is for those who want to upgrade an existing HLA installation. If you are a first time user, you want to use the setup program.
After downloading the HLASETUP.EXE program, simply execute it. You'll be asked a few simple questions about where you want to place the HLA files. Although it's possible to install HLA on any drive or within any subdirectory, most documentation and examples assume you've installed HLA on the C:\ drive in the root directory (that is, the files wind up in the C:\HLA subdirectory). If something goes wrong during installation, it's much easier to get help if you put HLA in your C:\ root subdirectory. The first time you install HLA, it's wise to put HLA in the C:\ root directory; after a successful installation, it's easy enough to move HLA, if you prefer to have it somewhere else.
Here's what the typical programmer does when they first decide to learn assembly programming with HLA:
1. The programmer eagerly downloads the HLA executables.
2. The programmer "unzips" the various packages they've downloaded.
3. The programmer double-clicks on the "HLA.EXE" icon.
4. The programmer sends me an email complaining that the program flashed up a console window briefly and then quit. They want to know why the environment didn't start up.
The answer I always send in reply to "where's the environment" is that there is none. HLA is an "old-fashioned" compiler that requires the use of a separate text editor to create HLA source files. Once you create an HLA source file, you've got to run the compiler from a command window (also known as a "shell" or "DOS box"). Momentarily, we'll discuss exactly how you do this. By now, you're probably thinking "How dumb! Why doesn't HLA provide an IDE like all decent languages?" Well, it does. There are actually several IDEs that work fine with HLA. The HIDE (HLA IDE) and RadASM enviroments are examples of two such programs. However, the use of these IDEs is optional and interested individuals should visit the associated web sites for those programs. This document will assume that you're using the command line tools, as HLA doesn't require the use of an IDE.
Okay, with the running commentary out of the way, let's go through the installation process and then figure out how to run this thing (one more time!).
Note: the following paragraphs describe the manual installation of HLA. If you've installed HLA using the HLASETUP.EXE installation program, you can skip over the following material. Also note that manual installation is available only for the latest version of the HLA system. This means that if you're a beginner who is learning assembly language programming using The Art of Assembly Language, then manual installation is not for you. You should be installing HLA v1.99, a frozen version, that is compatible with The Art of Assembly Language's examples. Manual installation is intended for advanced HLA programmers who already understand the HLA environment.
Let's begin by discussing the files you'll need to grab in order to install HLA. The first step is to go to the HLA download page (at http://webster.cs.ucr.edu/AsmTools/HLA/dnld.html; go to http://webster.cs.ucr.edu and find HLA from Webster's main page if this link is broken).
As this was being written, you're given links to download the following HLA modules:
Strictly speaking, the only downloads you absolutely need are the HLA executables. Presumably, you're dead-set on doing a manual installation, so the HLA installation program is of no use to you. The rest of the material is more or less optional; the following paragraphs describe the optional downloads.
The HLA Library Source module contains the source code to all the routines in the HLA Standard Library. This source code serves two purposes: (1) if you find a defect in one of the library modules and you need the problem corrected pronto, you've got the source code available, and (2) the HLA Standard Library provides a lot of sample HLA code for you to look at (around 50,000 lines of HLA code!). There are actually two versions of the HLA standard library on the downloads page: HLA stdlib v1.x and the latest version. V1.x of the library is no longer being actively supported. It is included on the downloads page for those who have to maintain older code that uses the older library module. For all 'real' work, you should download the latest version of the stdlib (v3.0 or later) source code.
The HLA Compiler Source Code module provides the Flex, Bison, C, and HLA source code for the compiler. This module also includes a few tools (like Flex and Bison) that you'll need to compile the program. Note that the HLA compiler source code is not for the feint of heart. It contains over 100,000 lines of code; this is not something you're going to learn over some weekend so you can hack in some feature you'd like. Still, the source code is available for those who are interested.
The Example code is a bunch of HLA examples I've written over the years in reponse to questions on various assembly newsgroups as well as some personal projects I've written. Most of this code will compile and run only under Windows, which is why this module isn't available for Linux users. Much of the code compiles under the HLA stdlib v1.x; this code is (slowly) being ported to the latest versions of the HLA standard library (as well as to other operating systems). Please be patient.
The AoA Examples modules contains all the sample code from the "Art of Assembly" textbook. Again, there is a lot of useful sample code here, though you should read this code concurrently with reading AoA. Currently, this code is only guaranteed to compile and run properly under HLA stdlib v1.x. A future project is to port this source code to compile and run under the latest version of the standard library.
The HLA documentation is available in three formats: PDF, HTML, and RTF. PDF is, by far, the better of the three formats from a readability point of view. However, I'm currently phasing out PDF documentation in favor of user-editable RTF files for HLA documentation. All of the new HLA standard library documentation, for example, exists solely in RTF and HTML form (no PDF). This is being done because the HLA system is slowly moving towards a community-based development model and RTF is a much more common file format than the Framemaker (used to create the PDFs) format that the existing documentation was written in.
To unzip the HLA packages, you'll need a decompressor program like WinZip or PKunzip. The use of such programs is beyond the scope of this document; however, such tools are sufficiently ubiquitous that I can probably assume safely that you can deal with decompressing the HLA modules. Decompress the HLA executable module to the "c:\hla" subdirectory (this should be the default). If you absolutely, positively, have to put the HLA code somewhere else, I'll have to assume that you know what you're doing and will make all the appropriate adjustments to the directions that follow. If you're not absolutely confident that you can make all these adjustments, don't install HLA somewhere else.
When you decompress the HLA executables package, the "c:\hla" subdirectory (that's probably created by the decompression of the HLA executables) should contain the following:
After decompressing the HLA executable module, double check that the files are were they belong in the "c:\hla" subdirectory. The remainder of the HLA installation and execution process will fail if this is not the case.
The HLA.EXE executable program is actually a "shell" program that runs the HLA compiler (HLAPARSE.EXE), a linker program (e.g., POLINK.EXE), and, possibly, some other programs.
The next step is to tell the system where it can find all these files. This is done using the PATH, HLAINC, and HLALIB environment variables. You can set up these environment variables each time you open a command window (i.e., a "DOS" window), but this is a royal pain in the rear. Best to set up these environment variables just once. Unfortunately, the directions for doing so depend upon which version of Windows you're using. For people still using Windows 95 and 98 (and possibly Windows 2000 Me, I'm not sure since I've never used Me) generally require that you specify global environment variable settings in your "autoexec.bat" file (typically found in the root directory of your C: drive). Edit this file with a text editor (not a word processor) and add the following two lines to the file:
set hlalib=c:\hla\hlalib\hlalib.lib
Next, search for a line in the autoexec.bat file that contains something like "path= <<some text>>" (with a bunch of pathnames in place of '<<some text>>'). Edit this line of text so that it now reads:
where '<<some text>>' represents the text that originally followed the "path=" statement. After making these changes, save the file back to disk. Warning: make sure you have a backup of the autoexec.bat file before you edit it. The correct operation of the system depends upon the consistency of this file. If you break something, you want to be able to replace the broken autoexec.bat file with the original file.
Finally, search for a line of text that takes the following form:
Modify this line so that it reads as follows:
set lib=c:\hla\hlalib; <<some text>>
Where '<<some text>>' represents the text originally on the line.
If you're using Windows NT, 2000 Pro (or server), Windows XP, or Vista, you set up the environment variables differently. On these operating systems you go to the system control panel (select "control panels" from the Start menu and then select "system" from the control panel list or window) and select the "advanced" tab. At this point, click on the "Environment Variables" button. In one of the window panes that appears, you'll find the "PATH" environment variable. Edit it and add the "c:\hla;" prefix to the value, as was done for the autoexec.bat file above. Do the same for the "LIB" variable (supplying the library pathname). Once you save the "PATH" and "LIB" environment variables back (and verify the changes), add the two environment variables "hlainc" and "hlalib". For their values, specify "c:\hla\include" and "c:\hla\hlalib\hlalib.lib", respectively. Warning: be careful when editing environment variables. It's possible for you to mess up the system if you inadvertently change something you're not supposed to change.
In order to test the above, it's a good idea to reboot the system at this point (this is a mandatory step if you're using Win95/98 and had to edit the autoexec.bat file). Once the system has rebooted, start up a command prompt window. Microsoft excels at hiding the command prompt Window in various versions of Windows. If you can find it in the Start menu, the Start->Programs menu, or in the Start->Programs->Accessories menu, try selecting Start->Run and typing "cmd" as the name of the program to run (on really old OSes like Win95 and possibly 98, you may have to run the "command" program). This should bring up a window with a "C:>" prompt. Type "SET" followed by the enter key. In the text that scrolls by, ensure that the "PATH=..." line has the "c:\hla;" prefix and that the "hlalib" and "hlainc" variables appear with the appropriate paths to their subdirectories. If this is not the case, then check the changes you've made and try again. If trying again doesn't work, try asking for help on comp.lang.asm.x86 or alt.lang.asm (sorry, I can only personally help you if you're running the same OS I am; as I'm writing this, that's Win2K Pro and Windows XP).
If it turns out that the directions above don't work for you, please read the section "Installing HLA Under Windows" in the HLA Reference manual. It describes this same exact process, but a little differently; hopefully the different perspective will help you figure out what's wrong.
At this point you should be ready to write, compile, and run your first HLA program, but first...
Before describing how to write, compile, and run your very first HLA program, it's probably worthwhile to take a quick step back and carefully consider what we've accomplished in the previous section so it's easier to troubleshoot problems that may come up. This section describes how the steps you went through in the previous section affect the execution of HLA.
Note: This section is of interest to all HLA users; whether you've installed HLA via the HLASETUP.EXE program, or you've manually installed HLA.
In order to execute HLA.EXE, HLAPARSE.EXE, and various other programs needed to compile and run an HLA program, the operating system needs to be able to find all the executable files that HLA needs. In theory, the executable files that HLA needs could be spread out all over your system as long as you tell the OS where to find each and every file. In practice, however, this makes troubleshooting the setup a lot more difficult if something goes wrong. So it's best to put all the necessary executables in the same directory.
Note that Windows doesn't know anything at all about the "C:\HLA" subdirectory; it's not going to automatically look for the HLA executables in this subdirectory, you have to tell Windows about this directory. This is done using the "PATH" environment variable. Whenever you tell Windows to run a program from a command prompt window, the OS first looks for a program with the given name in the current directory. If it finds the program (with a ".EXE", ".COM", or ".BAT" suffix), it will run that program from the current directory. If it does not find a program with an allowable suffix in the current directory, then the OS will use the PATH environment variable to determine which subdirectories to search through in order to find the executable program. The PATH environment variable is a (possibly empty) string that takes the following form:
pathToDirectory; pathToDirectory; pathToDirectory;...
Each pathToDirectory item in the list above generally represents a full path to some directory in the system. Examples include "c:\hla", "c:\windows", and "c:\bin"; these are always paths to directories, not to individual files. A PATH environment string may contain zero or more such paths; if there are two or more paths, each subdirectory path is separated from the others by a semicolon (the ellipses ["..."] above signify that you may have additional paths in the string, you don't actually place three periods at the end of the list).
When Windows fails to find an executable program you specify on the command line in the current directory, it tries searching for the executable file in each of the directory paths found in the PATH environment variable. Windows searches for the executable file in the subdirectories in the order that they appear in the environment string. That is, it searches for the executable in the first directory path first; if it doesn't find the executable in that directory, it tries the second path in the environment string; then the third, then the fourth, etc. If Windows exhausts the list of directory paths withoutt finding the executable file, it displays an error message. For example, suppose your PATH environment variable contains the following:
If you type the command "xyz file1" at the command line prompt, Windows will first search for program "xyz.exe", "xyz.com", or "xyz.bat" in the current directory. Failing to find the program there, Windows will search for "xyz" in the "C:\HLA" subdirectory. If it's not there, then Windows tries the "C:\WINDOWS" subdirectory. If this still fails, Windows tries the "C:\BIN" subdirectory. If that fails, then Windows prints an error message and returns control to the command line prompt. If Windows finds the "xyz" program somewhere along the way, then Windows runs the program and the process stops at the first subdirectory containing the "xyz" program.
The search order through the PATH environment string is very important. Windows will execute the first program whose name matches the command you supply on the command line prompt. This is why the previous section had you put "c:\hla;" at the beginning of the environment string; this causes Windows to run programs like HLA.EXE, HLAPARSE.EXE, and POLINK.EXE from the "C:\HLA" subdirectory rather than some other directory. This is very important! .
By specifying the PATH environment variable, you tell Windows where it can find the executable files that HLA needs in order to compile your HLA programs. However, HLA and LINK also need to be able to find certain files. You may specify the location of these files explicitly when you compile a program, but this is a lot of work. Fortunately, both HLA.EXE and POLINK.EXE also look at some environment variable strings in order to find their files, so you can specify these paths just once and not have to reenter them every time you run HLA.
Most HLA programs are not stand-alone projects. Generally, an HLA program will make use of routines found in the HLA Standard Library. The HLA Standard Library contains lots of conversion routines, input/output routines, string functions, and so on. Calling HLA Standard Library routines saves a considerable amount of effort when writing assembly language code. However, the HLA compiler isn't automatically aware of all the routines you can call in the HLA Standard Library. You have to explicitly tell the compiler to make these routines available to your programs by including one or more header files during the compilation process. This is accomplished using the HLA #include and #includeonce directives. For example, the following statement tells the HLA compiler to include all the definitions found in the "stdlib.hhf" header file (and all the header files that "stdlib.hhf" includes):
When HLA encounters a #include or #includeonce directive in the source file, it substitutes the content of the specified file in place of the #include or #includeonce . The question is "where does this file come from?" If the string you specify is a full pathname, HLA will attempt to include the file from the location you specify; if it cannot find the file in the specified directory, the HLA will report an error. E.g.,
#include( "c:\myproject\myheader.hhf" )
In this example, HLA will look for the file "myheader.hhf" in the "c:\myproject" directory. If HLA fails to find the file, it will generate an error during compilation.
If you specify a plain filename as the #include or #includeonce argument, then HLA will first attempt to find the file in the current directory (the one you're in when you issued the HLA command at the command line prompt). If HLA finds the file, it substitutes the file's contents for the include directive and compilation continues. If HLA does not find the file, then it checks out the "HLAINC" environment variable, whose definition takes the following form:
Unlike the PATH environment variable, the HLAINC environment variable allows only a single directory path as an operand. This is the path to the HLA include files directory which is "c:\hla\include" (assuming you've followed the directions in the previous section). Since HLA header files usually come in two varieties: headers associated with library routines and header files associated with the current project, the fact that HLA only provides one include path is not much of a limitation. You should keep all project-releated header files in the same directory as your other source files for the project; the HLA library header files (and header files for any generic library modules you write) belong in the "C:\HLA\INCLUDE" directory. Note that if you want to place header files in some directory other than the current directory or the directory that the HLAINC environment variable specifies, you will have to specify the path to the include file in the #include or #includeonce statement.
If HLA cannot find the specified header file in the current directory or in the directory specified by the HLAINC environment variable, then you'll get an error to the effect that HLA cannot find the specified include file. Needless to say, most assemblies will fail spectacularly if HLA cannot find the appropriate header files.
Since most HLA programs will use one or more of the HLA Standard Library header files, chances are pretty good that the assembly won't be successful if the HLAINC environment string is not set up properly. Conversely, if HLAINC does contain the appropriate string, then HLA will be able to successfully compile your code to produce an object file. The last step, converting the object file to an executable, introduces another possible source of problems. The POLINK program combines the object file associated with your code with HLA Standard Library and Windows library modules. Even the most trivial HLA program will need to link with (at least) one or more Windows modules (the most trivial HLA program is probably the one that immediately returns to the OS; such a program needs to call the Windows ExitProcess API in order to return to the OS, so at the very least you'll need to link with the Windows' kernel32.lib module to be able to call ExitProcess). Once again, however, the library modules that your program needs could be anywhere on the disk. You'll have to use some environment variables to tell HLA and the linker where it can find the library modules. You accomplish this using two environment variables: one for HLA and one for the linker. We'll discuss the HLALIB environment variable first, since it's the easiest to understand.
The HLA Standard Library contains hundreds of small little routines that have been combined into a single file: "hlalib.lib". Whenever you call a particular standard library routine, the linker extracts the specific routine you call from the "hlalib.lib" library module and links combines this code with your program2. Once again, the linker program (and HLA) don't know where to find this file, you have to tell them where to find it. This is done using the HLALIB environment variable; this environment variable contains a single pathname, the full path to the HLALIB.LIB file. I.e.,
set hlalib=c:\hla\hlalib\hlalib.lib
The important thing to note in this example is that the path is the full pathname of the HLALIB.LIB file including the filename at the end of the path. This is in direct contrast to the PATH and HLAINC environment objects where you specify only the subdirectory containing the desired files.
In addition to the "hlalib.lib" library file, you'll also need to link your HLA programs against various Windows library modules. Basic HLA programs will need to link against the Windows' kernel32.lib, user32.lib, and gdi32.lib library modules. You'll need to tell the POLINK.EXE program where it can find these files, this is done with the LIB environment variable. The LIB environment variable's syntax is very similar to that for the PATH environment variable. You get to specify a list of directories in the LIB environment string and POLINK.EXE will automatically search for missing library files in each of the paths you specify, in the order you specify, until it finds a matching filename. By prepending "c:\hla\hlalib;" to this environment string, you tell POLINK.EXE to search for library modules like KERNEL32.LIB, USER32.LIB, and GDI32.LIB in the "C:\hla\hlalib" subdirectory if it doesn't find them in the current subdirectory3.
Okay, with this explanation out of the way, it's time to write, compile, and run, our first HLA program!
A long running convention is to write a "Hello World" programs as the very first program program in any language. This document will continue that cherished convention.
The first step is to enter the program into a text editor. HLA is not an "integrated development environment" (IDE) so you don't run HLA and enter the program into the editor that HLA provides; because HLA doesn't provide one. Instead, you use a separate text editing program (not a word processor) to create your HLA programs. You can generally use your favorite text editor you use for writing programs in other languages. For example, if you've got Microsoft's Visual Studio system (Visual C++, Visual BASIC, etc.) you can use that text editor to create HLA programs. The HIDE and RadASM integrated development environments for HLA also provide nice text editors. You may also use the "QEdit" program that comes with MASM32 to create HLA programs. In a pinch, you can even use the "Notepad" program that comes with Windows to create HLA programs. Whatever you decide, the only rules is that your program must create ASCII-only text files since this is what HLA expects (word processors like Microsoft Word inject non-ASCII binary data into the output file, this is what makes them inappropriate for creating HLA programs). The use of one of these text editors is beyond the scope of this document. However, most computer users are familiar enough with text editors (e.g., Notepad) that this topic doesn't warrant any further discussion, anyway.
When writing HLA programs, the best approach is to create a single directory for each project you write. I'd suggest creating a subdirectory "c:\hla\projects" and then create a new subdirectory inside "c:\hla\projects" for each HLA project you write. For the example in this section, you might create the directory "c:\hla\projects\hw" (for "Hello World").
There are many different ways to create project directories. The most common way to do this under Windows is in the Windows Explorer (right click on a window and select "New->Folder"). However, since HLA is a command-line based tool, it's probably best to describe how to do this from the command line just to introduce some (possibly) new command line commands.
The first step is to bring up a command prompt window. Generally, this is done by selecting "Start->Programs->Accessories->Command Prompt"4 from the Windows Start menu. You may also select "Start->Run" and type "cmd" (or "command" in Win95) to bring up a command prompt shell. If you wind up righting a lot of HLA code, you'll want a faster and easier way to run the command prompt, so I recommend creating a shortcut to the command prompt program on your desktop. To do this, click on Start (and release the mouse button), then move the mouse cursor to select "Programs->Accessories->Command Prompt". Now right-click on the "Command Prompt" menu item and drag it onto your desktop. Select "Create Shortcut(s) Here" from the resulting pop-up menu. You should now have a shortcut to the command prompt shell program on your desktop and you can easily run the shell by double-clicking on its icon.
If you've created a shortcut, there are a couple of additional things you should do to make HLA development a little easier for you. Right click on the shortcut you've just created and select properties. In the window that pops up, you'll probably want to change the "Start In:" string to "c:\hla\projects". This tells the command prompt program to make the specified path the current directory whenever you run the command prompt program by double clicking on this icon. By starting off inside the c:\hla\projects" subdirectory, you'll find that you save some typing (assuming, of course, you wind up putting most of your projects in the "c:\hla\projects" directory; use a different path here if this is not the case). Next, select the "layout" tab in the Command Prompt Properties window. Under "Screen Buffer Size" you'll probably want to make the value larger (the default is 300 on my system). I've found that 3000 is a fairly good number here. This number specifies the number of lines of text that the system will save when data scrolls off the top of the screen. This lets you view up to 3,000 lines of text from program execution (including your program's output, HLA error messages, etc.). If you've got a large monitor, you might also want to change the Window Size values as well. The default 80 colums is probably fine, though you may want to expand the Height to 50 lines (or whatever your monitor allows). Once you've set up the command window properties, double-click on the command prompt icon to start it running.
The first step, before doing anything else, is to verify that you've properly set up the environment variables. To check out their values, simply type "set" followed by ENTER. The "set" command without any parameters tells the command shell to dump the current values of all the environment variables active in the command prompt window. Scan through this list (scrolling back using the scroll bar if there are too many definitions to all fit in the window at one time) and search for the PATH, LIB, HLAINC, and HLALIB environment variables. Verify that they are present and have the correct values (that you've entered in the previous sections). If they're not present or the values are incorrect, HLA will not execute properly and you need to fix this problem first (Win95/98 users, did you remember to reboot after changing the autoexec.bat file?). If the environment variables are present and correct, then you're ready to try writing and running your first HLA program.
Switch to the "C:\HLA" subdirectory by using the following DOS (command line prompt) command5:
"cd" stands for "Change Directory". This command expects a single command line parameter which is the path of the directory that you want to make the "current directory." If you ever want to know what the current directory is, simply type "cd" without any parameters and the Command Shell will display the current directory6
If you haven't done so already, it's time to create the "projects" directory where you will place the HLA projects you create. Do this with the following command:
"mkdir" stands for "make directory" and this command requires a single argument - the name of the directory you want to create. If you do no specify a full pathname (as is the case in this example), the command shell creates the directory within the current directory. Verify that you've properly created the "projects" subdirectory by issuing the following DOS command:
"dir" stands for "directory" and tells the command shell to display all the files in the current directory. This should list the projects directory you just created (plus all the other files and directories in the "c:\hla" directory). Note that you can also use the Windows Explorer to create directories and view the contents of directories. However, since HLA is a command prompt based application, it's useful to learn a few DOS commands that will prove useful.
Now, switch to the projects subdirectory by using the following DOS command:
At this point, it's a good idea to create a new subdirectory for the "Hello World" project. Do this by using the following DOS command:
CD into this directory once you've created it. Now you're ready to begin work on the "Hello World" program.
Leaving the command prompt Window open for the time being, run the editor of your choice (e.g., QEditor.exe that comes with the MASM32 package or NOTEPAD.EXE, if you don't have any other preferences). Enter the following HLA program into the editor:
stdout.put( "Hello, World of Assembly Language", nl );
Scan over the program you've entered and verify that you've entered it exactly as written above. Save the file from your editor as hw.hla in the c:\hla\projects\hw subdirectory (generally using the File>Save or File>Save As menu item in the editor). Switch over the the command prompt window and verify that the file is present by issuing a "DIR" command; this should list the hw.hla file. If it's not present, try saving the file again and be sure to browse to the "c:\hla\projects\hw" before actually saving the file.
WARNING: NOTEPAD.EXE has a habit of tacking a ".txt" to the end of filenames you save to disk. Default installations of Windows do not display file suffixes of known file types (and ".txt" is a known type). Therefore, a directory window may show a program name like "hw.hla" when, in fact, the filename is "hw.hla.txt". Probably the number one problem people have when testing out their HLA installation is that the compiler claims it cannot find the file "hw.hla" when the user first attempts to compile the file. This is because it's really named "hla.hw.txt". You must change the filename to "hw.hla" before HLA will accept it. This is the number one HLA installation problem. Watch out for this!
Once you've properly saved the file as c:\hla\projects\hw\hw.hla, it's time to run the HLA compiler on this file. Switch to the command prompt window (I'm assuming here that c:\hla\projects\hw is still the current directory, if not, switch to that directory using the CD command). In the command prompt window, enter the following command:
This command instructs Windows to run the HLA.EXE program in order to compile the hw.hla source file. Note that specifying the ".hla" suffix is optional. If you specify a filename argument to the hla command that does not have a (recognized) suffix, HLA automatically appends ".hla" to the filename prior to attempting to compile it. I.e., the above command is completely equivalent to
If all goes well, HLA should do its job without reporting any errors (note: POLINK generally issues a warning about a non-existent BSS segment; this is a bug in POLINK and the warning is meaningless -- just ignore it). If HLA reports some sort of problem with the source file, switch back to the editor program and correct the mistake (HLA generally lists the line number in the file near the cause of the problem). If there doesn't seem to be a problem with the source file, go to the next section (troubleshooting) and follow the directions there.
If you've followed and verified all the steps up to this point, you should be able to execute the HLA command above without incident. You can verify proper operation by typing the "DIR" command at the command prompt; you'll see a whole bunch of new files in the directory, these files include:
The hw.exe file is the one we're most interested in at this point. This is the actual executable program that HLA produced from the hw.hla source file. To execute this program, simply type "hw" from the command line prompt; hopefully, you see the text "Hello, World of Assembly Language" appear on the line following the execution of the hw command. If you've gotten this far, congratualations; you've successfully installed HLA and compiled and run your first HLA program. You can, therefore, skip the next section on troubleshooting.
Although I've written the preceding sections on HLA installation and operation as simply as I can imagine, there's always the possibility that I forgot something or you've gotten off-track somewhere along the way. In this section I'll try to point out some of the more common installation problems I've encountered over the years.
Before describing common installation problems, I do want to point out some HLA features you may find handy when troubleshooting an HLA installation and I want to point out some resources you can use to resolve your problems. First, if you've gone through the above steps and HLA is still not running properly, but it is, at least, running, you can get more information about the cause of the problem by using the HLA "-v" (for verbose) option. I.e., run HLA as follows:
This will produce output that is similar to the following (though version and build numbers may be different):
HLA (High Level Assembler)
Use '-license' to see licensing information.
Version Version 1.99 build 12955 (prototype)
Win32 COFF output
OBJ output using internal FASM back-end
-test active
HLA Lib Path: c:\hla\hlalib\hlalib.lib
HLA include path: c:\hla\include
HLA temp path:
Linker Lib Path: C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\lib;c:\hla\hlalib
Files:
1: hw.hla
Compiling 'hw.hla' to 'hw.obj'
using command line:
[hlaparse -level=high -v -sf -ccoff -test "hw.hla"]
----------------------
HLA (High Level Assembler) Parser
use '-license' to view license information
Version Version 1.98 build 12913 (prototype)
-t active
File: hw.hla
Output Path: ""
Language Level: high
Compiling "hw.hla" to "hw.obj"
Compilation complete, 7552 lines, 0.052 seconds, 145231 lines/second
Using flat assembler version C1.66
3 passes, 940 bytes.
----------------------
Linking via [polink @"hw.link._.link"]
POLINK: warning: /SECTION:.bss ignored; section is missing.
Most of this information is of little use to you, but the important thing is that this verbose output will help you figure out where there error occurs (during HLA compilation or during linking). Most errors due to installation problems occur during compilation (between the messages <<Compiling "hw.hla" to "obj">> and <<Compilation Complete">> in the output above) or during linking (after the <<Linking via [polink @"hw.link._.link"]>> statement above). This provides an important clue to the source of your difficulties.
As noted earlier, the message
POLINK: warning: /SECTION:.bss ignored; section is missing.
can be safely ignored. This is a minor issue with the POLINK linker and it does not affect the correctness of your program at all.
If you cannot even run HLA, that is, if the OS complains that it cannot find the hla.exe program, this generally indicates that the PATH environment variable is not properly set up (either you haven't added the "c:\hla;" path to the environment string or the path you supplied is incorrect), you've somehow deleted the hla.exe file, or you've not installed the HLA executables to the "c:\hla" directory. It could also mean that you've installed HLA properly and set the PATH environment variable in your autoexec.bat file (Win95/98) but you forgot to reboot afterwards. Verify that the "C:\hla" subdirectory contains all the HLA and POLINK files noted earlier and verify that the PATH environment variable contains "C:\HLA" as the first entry in the path (use the DOS "set" command to display the current environment variables' values). You might also try switcing to the "C:\hla" directory in a command shell window and try executing HLA directly from that directory (remember, Windows searches the current directory for an executable prior to trying the PATH). If you can execute HLA from within the "c:\hla" directory, but not outside it, you've definitely got a path-related problem. WinNT/2K/XP/Vista users should note that setting the PATH in an autoexec.bat file does not work. You must set the PATH environment variable using the System control panel applet. Please see the earlier section for details.
Probably the most common installation error is that HLA runs properly, but complains about being unable to find the stdlib.hhf header file when you compile the "Hello World" program. In every instance I've seen, this is due to not having properly set up the HLAINC environment variable. If you're getting this error while attempting to compile hw.hla, immediately type the following DOS command and then retry the HLA compilation:
Chances are pretty good that if you've not set up the HLAINC environment variable properly, you've most likely failed to set up the HLALIB environment variable, too. That means that you'll get some different errors if you recompile hw.hla after executing the set command above, but you shouldn't be getting the complaint about the stdlib.hhf file anymore. Note that type this set command at the command line prompt is only a temporary solution to verify that HLAINC was not set properly. This setting only lasts until you close the command prompt window. Since you probably don't want to have to enter this command (among others) every time you open a command line window, you should follow the previous directions and add this set command to the autoexec.bat file (Win95/98) or properly set up the path in the Control Panel System applet under other versions of Windows. If you've already done this, go back and check your work - there's probably a typo in there somewhere.
Generally, if someone has messed up the HLAINC environment variable, the HLALIB environment variable is toast as well. So it's a good idea to check the HLALIB environment variable at the same time you making corrections to the HLAINC item. If you attempt to compile an HLA source file and HLAINC is properly set up but HLALIB is not, then the linker will probably complain about being unable to openn the input file "hlalib.lib". This is your indication that the HLALIB environment variable needs correction. To verify that this is, indeed, the problem, enter the following DOS command and then retry the compilation:
set hlalib=c:\hla\hlalib\hlalib.lib
If, after you enter the command above, the compilation succeeds, don't forget that you've got to go change the HLALIB environment variable setting in the autoexec.bat (Win95/98 users) or in the Control Panel System Applet (WinNT/2K/XP/Vista) to make the correction permanent. Of course, you should check to verify that the hlalib.lib file actually is present in the c:\hla\hlalib subdirectory. Generally, it's difficult to get to this point in the installation process and not have the file present, but you never know...
If HLA complains that it cannot find or execute POLINK.EXE during compilation, this probably means that POLINK.EXE was deleted from the c:\hla subdirectory. Correct this problem and retry the assembly.
If you've tried everything up to this point and you still can't get HLA to run properly, here's my recommendations:
1) Read the HLA Reference manual. There's a lot of good information on installing HLA present there. Well over half the installation problems I've encountered were due to the fact that the HLA user simply tried to install HLA without reading the instructions first. Although much of the HLA installation information was duplicated in this document, it does provide another perspective and going through that process force you to do something you accidentally missed while following the directions in this documentation.
2) Check the HLA page on Webster (http://webster.cs.ucr.edu) to see if there are any installation issues you need to be aware of.
3) Try installing HLA using the HLAsetup.exe program rather than installing it manually.
4) Post a question to one of the assembly newsgroups (either comp.lang.asm.x86 or alt.lang.asm). I frequent these newsgroups all the time, and I prefer to answer your questions publicly rather than in private email so others may benefit from my replies. Furthermore, installation issues often are OS version specific and I don't have and don't use every version of Windows; so it could be that someone else has the answer that I simply can't provide.
5) If you do not have newsgroup access (hard to believe, but many people don't), you can send me an email at rhyde@cs.ucr.edu. Note that all such emails become my property and by sending me emails requesting help you are implicitly providing me permission to use that email any way I see fit (including posting its contents to a newsgroup or on Webster). Because of the volume of SPAM I get each day, most messages get lost in the noise. If you really want me to read your email, prepend "WEBSTER:" on the subject line of your message.
HLA is under constant revision. At some point or another you're probably going to want to update your copy of HLA to the latest and greatest version. You might want to do this because you've encountered some defects in HLA and you want a corrected version, or it could be that you want to use some new features found in later versions of HLA. Fortunately, the update process is nowhere near as complex as your first installation.
Most of the time, all you'll really need to do when updating HLA is download the executables file and unzip it. Assuming (as this documentation does) that you've put HLA in the default c:\hla directory, unzipping the executables files will automatically replace the old HLA versions with the new ones. At the bare minimum, that's all you need to do to update HLA. Not much, eh?
To be on the safe side, it's probably a good idea to first make a copy of your c:\hla subdirectory before applying the update (by unzipping the executables file). Sometimes new HLA versions have radical changes that cause it to no longer compile older source files (usually, the changes needed to correct the source file are minor, but you may not have the time to make such changes if you're in crisis mode). Sometimes changes to HLA introduce new defects and your existing source code may break as a result of those defects. Having a back up of the old executables laying around can help you to back out of such a disaster.
Note that the HLA download page contains descriptions of the corrected defects and the new features on a version by version basis. So you can always go to the HLA downloads page on Webster to determine if the latest version of HLA contains features you want or need; in a similar vein, those descriptions will also warn you if changes to HLA are likely to break old source code (that is, whether source code that compiles under older versions of HLA may need minor changes in the syntax to compile under the new version). This actually doesn't happen all that often, but it does occur on occasion. This is useful information when you're deciding whether you want to upgrade to the latest version8.
You probably don't have to download new HLA documentation with each upgrade unless there are a lot of new features you want to use in the upgrade. The documentation generally doesn't change that much between versions unless there are a lot of new features. If you're not going to use the new features, downloading the new documentation is probably a waste of time. Unless you're in the habit of recompiling the HLA Standard Library on a regular basis, you probably don't need to download any source code, either. Likewise, the example code doesn't change all that frequently, so you probably don't need to download that, either.
Once you get HLA up and running, maintaining it (by downloading and unzipping new versions) is a relatively trivial matter. Indeed, it's even easier than running a typical "professional" installation program. Someday, HLA may support a full installation program, but until then, I hope that this documentation provides everything you need to install, use, and update HLA.
If, for some reason, you decide you don't want HLA on your C: drive, or that you want HLA installed in a different subdirectory than C:\HLA, there are only two steps needed to move HLA elsewhere. First, physically copy all the files in the C:\HLA subdirectory (or wherever you've put HLA) to the new destination directory. Once this is accomplished, simply modify your system's PATH, HLALIB, HLAINC, and LIB environment variables. The environment variables are most easily set (or changed) in your system control panel. Just select "Settings>Control Panel" from the START menu in Windows. Then run the "System" control panel object and press the "Advanced" tab. Hit the "Environment Variables" button and modify the "lib", "path", "hlainc", and "hlalib" environment variables appearing in the two window panes that appear.
1. On the other hand, if you are using software that needs the incompatible linker, this may create problems with that other software. Fortunately, the incompatible linkers are generally quite old, so this isn't usually a problem unless you're also writing 16-bit code on your system.
2. Note that the linker does not combine the entire hlalib.lib module with your code; it only combines the routines you directly or indirectly call.
3. It's important to leave all the other paths in place in the LIB environment string since many other languages use this environment variable as well.
4. The "Command Prompt" program might appear at a different location depending on the version of Windows that you're using.
5. "DOS command" is short for "command line prompt command". This isn't really DOS, but DOS is easier to write and easier to say, so the normal convention is to call these things "DOS commands". Since these commands all originated in MS-DOS a couple of decades ago, this term isn't entirely misleading.
6. Actually, by default the command shell will display the current directory as part of the prompt, so using the CD command to determine the current directory is rarely needed unless you've explicitly changed the prompt that the command shell uses.
7. On some versions of Windows you may find the "Command Prompt" menu item elsewhere in the Start menus, adjust this description as appropriate.
8. On the other hand, you don't want to avoid updating your version of HLA just because it's going to force you to change some of your code. After all, sooner or later you'll probably have to upgrade, and the sooner you do it, the less code you're going to write in the old version and the less code you'll have to change when you finally do upgrade.