Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This assembler is awful. I thought that AT&T had a monopoly on ghastly assembly language syntax -- but this article causes me to question that assumption:

  MOVL BX,autotmp_0000+-4(SP)    ; from the article -- terrible!
  MOV EBX,[ESP+autotmp_0000-4]   ; Intel -- comprehensible!
This assembler has an imaginary register called FP.

WTF is up with the center dot?

A programming language should not require Unicode to write -- especially assembly language!

I don't know what's worse: That this assembler exists, or that a project chose to use it after better alternatives had been created!



It's amusing that the first line is considered "terrible" but the latter is "comprehensible". For someone versed in modern languages they both look like gibberish.


Here's an explanation suitable for someone only familiar with high-level languages:

MOV x,y translates to the assignment operator "x = y" in a high level language [1].

Your program only has access to one giant array called "memory" [2] [3]. So MOV EAX,EBX means "EAX = EBX" in high-level terms; MOV EAX,[EBX] means "EAX = memory[EBX]" in high-level terms ("memory[EBX]" has the same meaning here as in C-family languages like C, Java, Javascript and Python). This choice of operator notation is intuitive, because it's very similar with the use of brackets in other popular languages.

The insane syntax uses parentheses instead of brackets. Which is confusing, since it's not related to the standard meaning of parentheses, grouping for order of operations or function call. So you would say "MOV EAX,(EBX)" in weird-syntax land.

But the insanity doesn't end there.

In the sane Intel syntax, if you want to load the value at memory location 148 + -4 + ESP into EBX, you can probably figure out how you would say it:

  MOV EBX,[148 + -4 + ESP]
The C/Java/JavaScript/Python translation is:

  EBX = memory[148 + -4 + ESP]
In weird-land, the syntax for this operation is:

  MOVL BX,148 + -4 (SP)
To me, it looks like this instruction says:

  Let t = 148
  Let u = The contents of memory pointed to by SP
  Let v = -4*u
  Let BX = t+v
Clearly, there are only two possible explanations for this: The person who came up with this syntax was drunk at the time, or the person who came up with this syntax was high at the time.

[1] In a HLL, "x = y" allows arbitrarily long expressions for x and y, but in assembly language only a few different forms of x and y are allowed. In a high-level language, in the expression "x = y", x needs to be an lvalue, while y can be a more general rvalue. "a = 5+6" is legal; "5+6 = a" is not. Both the left- and right-hand side can be arbitrarily long and complicated, for example the LHS could be "a.b.c.d.e.f.g.h" and the RHS could be "m+n+o+p+q+r+s+t", assuming the appropriate variables exist and have the appropriate types.

[2] Unless you use multiple segments. But you generally don't do that.

[3] Or paging. But you usually let the OS take care of that.


How does it require unicode?


The article talks about making a label whose name begins with a middle dot.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: