What is assembly language useful for?

I'd say:

If your goal is to just get a deeper understanding of how compilations and processors work, I actually wouldn't recommend trying to learn modern x86 - the list of instructions has grown ludicrously long. So unless you have some specific reason for needing to know x86 assembly, like you're trying to debug something at that level, you're looking at very specific optimizations, etc., I'd suggest looking at a much simpler microcontroller, such as a Microchip 8-bit PIC, or for example the Atmel ATmega328 (now owned by Microchip as well). The latter is the basis of the Arduino Uno, it's got an instruction setPDF that's not too huge.

Modern hardware has grown pretty complex, which is why learning the concepts on a simpler embedded system is IMHO helpful: How a processor stores its instructions, fetches them, executes them, reading and writing from/to RAM to do so, interrupts, various buses, low-level "peripherals" (like UART controllers), and so on. All of these concepts translate (more or less) to modern machines, except that they are much more complex there. But the basic building blocks of how a CPU communicates with the rest of the hardware in the system are the same.

* Note: Many people use the term "assembly" interchangeably with "machine instructions", and in many cases this is true, assembly is often just a textual 1-to-1 representation of the actual binary instructions the processor will directly execute. But to translate that textual representation into a binary format requires a translator program, and often these add a few features that actually mean that the "assembly" is not exactly the same as the machine instructions. But they're close enough that this distinction often doesn't matter.

How could it relate to Perl?

Perl is several steps away from assembly. The perl interpreter, which parses your Perl code into an intermediate representation and executes that, is itself written in C, which of course is compiled to machine instructions. So it's not like Perl code is directly translated to machine code - perl is an interpreter.

From your node here:

If assembly is fundamental, and machine code is the most fundamental, why would I have to download a program to run it? I do not want to download a program to be able to run it. There should be a way to access the processor directly (possibly through terminal) where I could write "000 101 100 ..." and have it output "101 001" (these numbers do not mean anything real)

The reason it's not that simple is that on a modern machine there are tons of of intermediate steps and layers. Take the "Hello, World" examples from this Introduction to UNIX assembly programming or this NASM Tutorial:

It's all these layers that make your question pretty broad and hard to answer better without knowing more about why you're asking - I could suggest you could get a degree in Computer Engineering, then you'd learn about all of the above topics, but perhaps you're looking for something more specific?


In reply to Re: Assembly language by haukex
in thread Assembly language by SkinBlues

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.