1
votes

I've started going through Randall Hyde's "The Art of Assembly" to start whetting my palate. I downloaded and installed HLA 1.38 (which I need for 64-bit support) from here , and wrote the Hello, World program as described in both the documentation listed there and in the book above.

program helloWorld;
#include ("stdlib.hhf");
begin helloWorld;
    stdout.put("Hello, World!", nl);
end helloWorld;

when I run hla helloWorld.hla, I get the following error message: helloWorld.asm:66: Error: ambiguous operand size or operands invalid for 'push'

The Assembly line in question reads:

pushd   0       ;/* No Dynamic Link. */

As I am as green as can be with assembly language, I have no idea how to make this work. I'm assuming that there's a discrepancy between my version of gas and HLA 1.38. So the question remains: what now?

Edit: I tried compiling just the 'program', 'begin', and 'end' directives (removing the possibility of it being something with the stdlib), and get the same result with a program that does effectively nothing.

I am on 64-bit CrunchBang Linux.

2

2 Answers

3
votes

If you want to learn assembler, I would really advise dropping HLA and this badly named book. Usually, you want to use assembler so that you have total control over the generated code. HLA takes it away. And if you want a more high-level language to not bother with register allocation and pushes and pops, there are much better choices available.

As for your question, it seems the asm generated by HLA is not of valid syntax for GAS. Since it's mainly targeting Windows, it would seem Linux is not very well tested. You could try either adding ".intel_syntax noprefix" at the top of the file, or adding $ to all immediate value (such as 0), but I suspect there won't be a trivial fix.

3
votes

Just in case anybody else trying to break into Assembly stumbles upon this thread: HLA is a fantastic middle step for people who are familiar with higher level languages and would like to step closer to the machine without swan diving on day 1.

It, however, is NOT a replacement for actual Assembly language, as Tom stated. i.e once you get comfortable with HLA and a few of the commands of Assembly, THEN move to real Assembly Language. It will be far less daunting (personal experience)