pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pgubook-readers] Special mov Syntax of Linux Assembly with "as"


From: Mark Schmid
Subject: Re: [Pgubook-readers] Special mov Syntax of Linux Assembly with "as"
Date: Fri, 21 Sep 2007 20:07:53 +0200

Hi Herbert,

Nice to see some life here!!!
:-)

> Differing syntax has never been a problem for me. I was raised to scan 
> the manual for new languages before programming in them. gas is a 
> different language than nasm, then asm or even as.

Good for you!
Being either the single-minded CPU-brain I am, or
the noob I am (I guess I'm both), differing syntaxes
is a HUGE problem for me when I try to learn something
and I am NOT AWARE that there ARE differing syntaxes.
(Notice the difference between KNOWING and NOT knowing!
;-)
Because then (NOT knowing) I must assume I've failed to 
understand even the MOST BASIC fundamental things about a 
new language. [Teach a first grade kid that 1+1=3 and you'll
essentially get the same effect, even if that's not
just a different syntax.]
It's not advisable when teaching someone something new.
;-)
I'm not one of those "raised by the man(page)ual", thus
I buy books as a replacement and hope to learn form those.
- Which doesn't mean I won't pick up confusing snips of
information elsewhere which could cause havoc with what
I've learned so far. ;-)


> assemblers written for a single processor would, in all likelyhood, use 
> the syntax specified by the manufacturer. 

Perhaps. But obviously this is not congruent with today's 
usage of said assemblers any more. I'm programming on an 
Intel processor, yet I am not using "Intel syntax" with "as".
So it seems an assembler can use any syntax it wants today,
as long as it translates that into object code which
suits the processor it assembles for. Obviously either
AT&T or Intel style assemblers switch Source and Destination
of the source code before translating it into machine code
which a processor (in this case Intel) wants.

If you don't know this as a beginner, you'll have a pretty
damn hard time coming to grips with such a basic command
as "mov" or "movl" (seems like an important one...) 
WHEN you see BOTH versions posted here and there without 
the much needed proper explanation.
- Which I did due to a break in reading caused by my
"lcomm" bug.
So I disagree. I think it should be mentioned in the
otherwise great book somewhere in the beginning VERY loud
and clear! - Even just as a mention to other styles of
programming / assemblers / books etc. Computers are one world!
Let's share it! ;-)

Otherwise I can't "compete" with you Herbert,
I learned my first steps in programming as a teenager 
on the Sinclair ZX-81 that had 2 or 4 KB of RAM
(I forget which) and a memory extension as
big as a pack of cigarettes, which added a 
whooping 16KB!! :-) - That was clearly a microcomputer
by what you talk about. ;-)
Cooling was a problem though. Programming more
than 2-3 hours at a time would cause overheating.
So to work fast, you needed a freezer to cool
of the thing every 2-3 hours... 
:-)

Regards,
Mark

PS: I'm not criticizing the book, I'm trying
to "add" to it! :-)



-------- Original-Nachricht --------
> Datum: Fri, 21 Sep 2007 07:11:15 -0700
> Von: "Herbert R. Coburn" <address@hidden>
> An: address@hidden
> Betreff: Re: [Pgubook-readers] Special mov Syntax of Linux Assembly with "as"

> Mark Schmid wrote:
> > Hi all,
> > 
> > O.K., it seems this list still is working after all.
> > Sorry for the test email.
> > 
> > Here's something which got me very nervous today:
> > I'm in chapter 5 right now and I'm stuck because
> > of a failing hard disk, so I started reading another
> > book about assembly programming and guess what:
> > 
> > In almost ALL OTHER references to assembly programming,
> > it says when you want to move a value from one place
> > to the other with "mov" or "movl", you FIRST state
> > the DESTINATION and THEN the SOURCE!
> > 
> > Like this: mov eax, $1
> > 
> > That's the EXACT opposite of what we've been learning!
> > (movl $1, %eax)
> > 
> > Here's why: It seems Programming from the Ground up is
> > specific to the Linux assembler (G)AS, which uses the
> > AT&T syntax or convention of "mov". Other than that,
> > most other assemblers seem to follow the Intel syntax
> > or convention, which is the exact OPPOSITE of AT&T's
> > in regards to the mov command!
> > 
> > Here's more about it:
> > http://www.faqs.org/docs/Linux-HOWTO/Assembly-HOWTO.html
> > Scroll or jump down to:
> > 3.2.2. What is this AT&T syntax
> > 
> > I think this is a MUST-MENTION in the BEGINNING of Programming
> > form the ground up, because one of the first things anyone
> > learning from this book will do, is to check out other
> > sources about assembly... And BOY will he be confused!
> > 
> > Regards and greetings,
> > Mark
> > 
> Differing syntax has never been a problem for me. I was raised to scan 
> the manual for new languages before programming in them. gas is a 
> different language than nasm, then asm or even as.
> 
> gas (GNU as) is not Linux-specific. It is a GNU assembler. Per the 
> manual, the syntax was inspired by the 4.2 BSD assembler syntax. 4.2 BSD 
> is the Unix designed by UC, Berkeley students. It appears they kept the 
> syntax used by AT&T's assembler.
> 
> gas can assemble code for several processors, each having its own 
> specific syntax (gas stays with AT&T regardless of the processor). He 
> who designs the processor gets to design the processor's syntax. I think 
> the syntax is specific to the wiring (God, I'm old). So Motorola uses 
> source, destination in their manuals and Intel uses the reverse, because 
> of hardware designs.
> 
> assemblers written for a single processor would, in all likelyhood, use 
> the syntax specified by the manufacturer. When AT&T wrote their 
> assembler, they used destination, source. I would guess because either 
> the PDP assembler was written that way, or the assembler on the 
> mainframe being used to work on MULTICS was written that way. Not being 
> there, and having never been that curious as to why, I don't really know.
> 
> All of this was a few years before Intel's first processor, the 4004, 
> and their choice of laying down traces determining their syntax. It was 
> a decade or more before Unix was ported to the 8086-series of processors 
> and an Intel-specific assembler was used by Microsoft in Zenix.
> 
> GNU was not designed with Zenix in mind. It was, and is, meant to run on 
> big-iron. That is not to say that today's PC is not much more powerful 
> than the big iron of 1984. Nobody in 1984 even dreamed of a desktop with 
> 4G and more or memory and a 2GHz multi-core processor. And, at the time, 
> laptops were just a dream. So GNU as was written using the same syntax 
> as AT&T's for the most part. After all, GNU as was a drop-in replacement 
> for the proprietary as that came with Unix, just better.
> 
> Other assemblers, like nasm, were written to run on CP\M or other 
> 8080-specific OS's. As the processor grew up, so did they, retaining the 
> Intel-syntax.
> 
> Should pgu-book warn us about differing syntaxes? It's been my 
> experience that what one learns by getting caught in the mud is better 
> understood. Probably because I'm still struggling to get out and I need 
> some company. So I think that merely stating that pgu-book uses the 
> syntax used in GNU as or whichever assembler the author was using when 
> he wrote the book is sufficient. Caveat Emptor!
> 
> Disclaimer: This was all off the top of my head which is well-worn. My 
> memory is faulty this morning, so research my meandering before quoting. 
> My facts may be all wrong.
> 
> /herbc whose first computer ever used 9-track magnetic tape for storage, 
> had a full 16K core memory, and took up an entire basement. His 
> supervisor first worked with a computer that had 2K vacuum-tube memory 
> and used magnetic drums for storage. The memory took up an entire 
> basement. The loader (BIOS), operating system, applications and data 
> being worked on had to fit within the memory. Those were the days when 
> students competed on who could write the shortest EBCDIC to ASCII or 
> digit to character translators. I remember one translator routine that 
> was less than 72bits. Shorter than most instructions, nowadays. Ah, the 
> days when we actually studied clock-cycles within an instruction.
> 
> 
> 
> _______________________________________________
> Pgubook-readers mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/pgubook-readers

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser




reply via email to

[Prev in Thread] Current Thread [Next in Thread]