Install High Level Assembly (HLA) language compiler on Arch Linux x86_64
Sunday, Jun 16, 2013
Useful things first
I am using Arch Linux x86_64 as my workstation operating system, which provides a lot of “bleeding edge” and up-to-date software. It has a HLA package from AUR so I don’t have to go to the source code and do a lot of compilation. AUR is quite amazing because it provides most of the software you may need as a student, developer or even a professional computer hacker.
To install the package, simply run
aurget –Syu hla, and it will just automatically download and install it for you. However, after typing the first “Hello World” code, I encountered few problems when I was trying to compile the code.
Just before the compile errors, you can download a VIM syntax file here so that you get basic syntax for the hla file. It does not work really well but it is a good starting point for you to create your own syntax file.
ERROR! Could not locate the hlalib.a file. Have you set the 'hlalib' environment variable properly? ERROR! Could not locate the HLA INCLUDE directory. Have you set the HLAINC environment variable properly?
What’s wrong and Solution:
This is because the library files which are used to compile the file cannot be found. To solve the problem, you have to set the environment variables hlalib and hlainc. Those two folders can be
/usr/hla/include in most of the systems if you are using the source code combilation. In Arch Linux however, it is in
/usr/include. Therefore, the solution is pretty simple:
export hlalib=/usr/lib #put these two lines in .bashrc export hlainc=/usr/include
Just run the commands above and everything should work file now. You may find the
hlalib.a file in the
/usr/lib folder, which tells you that the
hlalib virable should point to the folder where the
hlalib.a file locates. It may help you if you are using some systems that you cannot get it to work using either
/usr/lib. After fix the library issues, there is a new error when I was trying to compile:
ld: i386 architecture of input file `hw.o' is incompatible with i386:x86-64 output ld: i386 architecture of input file `/usr/lib/hlalib.a(ex_hwExcept.o)' is incompatible with i386:x86-64 output ld: i386 architecture of input file `/usr/lib/hlalib.a(ex_Raise.o)' is incompatible with i386:x86-64 output (tens of lines here)... Error returned by ld = 256
What’s wrong and Solution:
The error comes from the wrong linking libraries between 32-bit application and 64-bit library. In one word, you cannot use 64-bit library to link 32-bit application. After knowing what is wrong, the fixes are even simpler:
hla -lmelf_i386 hw.hla #hw.hla is the name of the source code
This tells the hla program to use 32-bit library to link the application, which will immediately fix the problem. By the way, you may need to enable and install the multilib repository to allow 32-bit libraries to be installed in your system.
Recently I found that doing web apps is definitely not a way out in my career. I am not saying that creating web applications is something no worth doing, but I think it is not something that I want to spend the rest of my life to do. Meanwhile, I am taking a course at Monash University with specification of Network and Software Engineering, which motivates me to dig more in to computer science and computer architecture.
I think HLA is definitely something worth learning, because it helps you understand how computer works in a really low level. In order to learn this language, I chose the book The Art of Assembly Language Programming (AoA) by Randy Hyde. The first step is to install the HLA compiler.
Okay, here is the end of this post. Hope this can help you out with the errors you find in your compilation process. Thanks for reading and wish you happy coding.