
Linux Assembly How-to - rspivak
http://www.tldp.org/HOWTO/Assembly-HOWTO/index.html
======
TomMasz
I was quite adept at 6800 and 68000 assembler but I can't imagine getting to
that level with modern x86. Maybe some glue routines, but beyond that give me
any of the current compilers.

~~~
ndesaulniers
[https://nickdesaulniers.github.io/blog/2014/04/18/lets-
write...](https://nickdesaulniers.github.io/blog/2014/04/18/lets-write-
some-x86-64/)

~~~
csense
It looked promising right up until the first code, and then I saw you're
writing in AT&T syntax. AT&T syntax is such an abomination against nature and
the gods of computing that every time I see it I want to gouge my eyes out.

AT&T syntax is this weird awful syntax only used by GNU as. The syntax is some
leftover from an assembler from the early UNIX days which was clearly written
by a very lazy person. Whoever came up with it apparently thought to
themselves, "If we make source files put a % character in front of registers
and a $ character in front of constants, then I don't have to think too hard
about how to write a parser. If we make source files specify their width in a
suffix, then we don't have to think too hard about how to get this information
out of the register name. And let's put our operands in (source, destination)
order instead of (destination, source) order just to be evil and confuse
people!"

Aaagggghh. If gas wasn't used as the backend of gcc, I guarantee exactly zero
people would use it, because AT&T syntax is so awful.

You should consider posting an update using NASM / YASM (or if you feel you
must use GAS, use its directive for Intel syntax). Your readers will thank
you.

~~~
ndesaulniers
You should do it on your blog.

------
heinrichhartman
From [http://www.tldp.org/HOWTO/Assembly-
HOWTO/external.html](http://www.tldp.org/HOWTO/Assembly-HOWTO/external.html):

About m4 macro-processor: "However, its disfunctional quoting and unquoting
semantics force you to use explicit continuation-passing tail-recursive macro
style if you want to do advanced macro programming (which is remindful of TeX
-- BTW, has anyone tried to use TeX as a macroprocessor for anything else than
typesetting ?)."

This is a great point! The TeX Macro language is so much better than M4
quoting syntax. I'd love to have it available for e.g. writing blog-posts in
HTML or coding.

It seems that the tex macroprocessor can not be used independently of latex,
which is a pitty. There are m4 clones with TeX-like syntax (e.g.
[http://www.nongnu.org/t4/](http://www.nongnu.org/t4/)) - but none of those
seems to be used much.

To see what's possible with just assembly and macros see Tannenbaums paper:
[https://www.computer.org/csdl/trans/ts/1976/02/01702350.pdf](https://www.computer.org/csdl/trans/ts/1976/02/01702350.pdf)

~~~
groovy2shoes
I'm a fan of TeX2page[1] for converting (La)TeX to HTML. There are also
similar TeX/Scribe-inspired markup processors. Scribble[2] comes to mind, and
Chibi Scheme[3] even comes with a very lightweight, very configurable
"Scribble" processor in the form of `chibi-doc`. Chibi's flavor is a little
more similar to TeX (using '\' as the leader rather than '@', for example), if
that's important to you.

[1]:
[https://ds26gte.github.io/tex2page/index.html](https://ds26gte.github.io/tex2page/index.html)

[2]: [https://docs.racket-lang.org/scribble/index.html](https://docs.racket-
lang.org/scribble/index.html)

[3]: [http://synthcode.com/wiki/chibi-scheme](http://synthcode.com/wiki/chibi-
scheme)

And here's Chibi's own manual written in it: [https://github.com/ashinn/chibi-
scheme/blob/master/doc/chibi...](https://github.com/ashinn/chibi-
scheme/blob/master/doc/chibi.scrbl)

I think it would be freakishly easy to adapt chibi-doc into a general text
preprocessor rather than an HTML generator, and honestly I've thought about it
before. I may just do it yet :)

~~~
heinrichhartman
Wow, tex2page looks really great. I'll might setup a JEKYLL workflow for using
it to write blog posts. LaTeX doc semantics are so much better than Markdown /
HTML.

Also I can see a LISP style macro processor being super awesome. Let me know
if you are going to adapt chibi-doc that way.

------
AdmiralAsshat
Trying to read through "Programming From the Ground Up" (a GNU book on
Assembly), and having some trouble keeping track of what I've thrown into what
register.

Does anyone have a recommendation for an IDE or debugger that can let me
inspect my registers at a given step of the program?

~~~
briansteffens
gdb is magic once you get the hang of it, I'd definitely recommend spending
some time getting comfortable with it.

~~~
AdmiralAsshat
I know my way around GDB, but only as a C debugger. Haven't really used it for
Assembly.

~~~
sigjuice

      (gdb) help si
      Step one instruction exactly.
    
      (gdb) help ni
      Step one instruction, but proceed through subroutine calls.
    
      (gdb) help info registers
      List of integer registers and their contents, for selected stack frame.
      Register name as argument means describe only that register.
    
      (gdb) layout reg # to enable view of registers in split screen
    

Also, you can use register names in expressions. e.g. p $r11

All of this is applicable when debugging a C program as well.

~~~
AdmiralAsshat
`layout reg` Did exactly what I wanted. Thank-you so much!

------
znpy
It would be nice to see this document updates, pages like
[http://www.tldp.org/HOWTO/Assembly-
HOWTO/gcc.html](http://www.tldp.org/HOWTO/Assembly-HOWTO/gcc.html) still
references gcc 2.7 and older.

