Suggestions on reading assembly language

21 views
Skip to first unread message

Herman

unread,
Dec 14, 2009, 4:12:40 PM12/14/09
to golang-nuts
I want to get a better understanding of the implications of my code by
looking at the assembly code. But is seems like the -a switch on 6l
generates a proprietary assembly language that I have never seen
before. (I'm already learning one new language... My cranial capacity
will be exceeded with two new languages.)

Anybody have any suggestions about how to read amd64 code generated
from go code? I'd prefer either be traditional x86 assembly or
something more abstract but more verbose.

Is it worth using gccgo for this?

Herman

Devon H. O'Dell

unread,
Dec 14, 2009, 5:33:30 PM12/14/09
to Herman, golang-nuts
2009/12/14 Herman <herman...@gmail.com>:
The format is AT&T assembler used by Plan 9. Rob Pike's paper on the
Plan 9 assembler can be easily viewed at [0].

--dho

[0] http://doc.cat-v.org/plan_9/4th_edition/papers/asm

Qtvali

unread,
Dec 14, 2009, 11:36:02 PM12/14/09
to golang-nuts
On Dec 15, 12:33 am, "Devon H. O'Dell" <devon.od...@gmail.com> wrote:
> 2009/12/14 Herman <herman.sch...@gmail.com>:
> The format is AT&T assembler used by Plan 9. Rob Pike's paper on the
> Plan 9 assembler can be easily viewed at [0].

But how about the new registers and opcodes? There is a bunch of new
registers this text does not mention.

> --dho

Devon H. O'Dell

unread,
Dec 14, 2009, 11:41:21 PM12/14/09
to Qtvali, golang-nuts
2009/12/14 Qtvali <qtv...@gmail.com>:
That's processor / architecture specific? If you want to know about
the processor, read the processor manuals.

--dho

>> --dho
>

Tambet

unread,
Dec 14, 2009, 11:57:17 PM12/14/09
to Devon H. O'Dell, golang-nuts
2009/12/15 Devon H. O'Dell <devon...@gmail.com>

Yes, but do I use intel/amd opcodes then?

And how are the following numbered - AL, AH, AX, EAX? If EAX is first data register, it's maybe R1, but what about AL?
 
--dho

>> --dho
>

Federico G. Benavento

unread,
Dec 15, 2009, 12:19:28 AM12/15/09
to Tambet, Devon H. O'Dell, golang-nuts
> And how are the following numbered - AL, AH, AX, EAX? If EAX is first data
> register, it's maybe R1, but what about AL?
>

AL == low byte of AX.... you can guess what AH is...

--
Federico G. Benavento

Tambet

unread,
Dec 15, 2009, 12:35:01 AM12/15/09
to Federico G. Benavento, Devon H. O'Dell, golang-nuts
2009/12/15 Federico G. Benavento <bena...@gmail.com>
> And how are the following numbered - AL, AH, AX, EAX? If EAX is first data
> register, it's maybe R1, but what about AL?
>

AL == low byte of AX.... you can guess what AH is...

Ok, I probably missed if there is a way to read registers byte-by-byte and handle those pieces with 1 opcode.

Anyway, searched for word "compressed" - as you seem to know about the text; as this assembler seems simple and coherent, I have some interest and ask in case:
  • Is there a way to use chunks of 4-bit uints stored in MMX/3DNOW! registers for fast array addition?
  • Is there a way to do additions, which give MAXVAL as result of (MAXVAL-4)+(MAXVAL-4), not MAXVAL-8 or error?
It just looks too short to believe that the whole instruction set of a given processor is included :) Or should I use LONG there? (which raises the question about macros) - and why BYTE is not supported, don't any machine today have byte prefix of opcode?

--
Federico G. Benavento

Russ Cox

unread,
Dec 15, 2009, 1:15:35 AM12/15/09
to Tambet, golang-nuts
Another way to answer these questions is to run
6l -a (or 8l -a) to link your 6.out and redirect standard
output (the assembly dump) to a file.

Then fire up gdb on the 6.out and ask it to disassemble
any address you don't understand. That will give you
the gdb syntax, which maybe will be more familiar,
and then you can build up the correspondence.
Compared to what gdb prints, the main difference is
that 6l uses uppercase letters.

Russ

Qtvali

unread,
Dec 15, 2009, 4:55:25 AM12/15/09
to golang-nuts
Thanks. I will check that out.
Reply all
Reply to author
Forward
0 new messages