Where to start with assembly?

Hey, I can program in C, a bit in Python and Pascal, and I really want to learn assembly. I am 18 years old and I am finishing high school, programming is my hobby because school work is not a problem.

I uploaded several books in the Assembly: "Assembly Art, Assembly for Beginners, Assembly for Beginners, and the Wrox Professional Assembly Language." I also downloaded the FASM, MASM, and HLA compiler.

Now a few questions.

  • Examples in the assembly for beginners for beginners for MASM, if I run them in the emulator, someone told me that I can damage my computer if I do not use it, and if so, which emulator should I use?

  • Also, how do developers make their assembler code portable? The only information I found on this topic is to write viruses, since viruses written on an assembly must be portable.

  • What is an HLA, but is it the real thing or just an HLL disguised as an assembly to help educate beginners?

  • And where is the build community, with the exception of the obvious vxheaven websites and hacking?

I have been reading a lot lately, but I feel like someone who studies Latin, but never gets to the Vatican to meet others who speak Latin. My friends are all Java programs, but don't seem to care about C or C ++, they think they can use Java for everything. I am running Windows 7 and Ubuntu 10.0.10 on Intel. I only programmed for about a year ... Am I too immersed in assembly? My reasons for wanting to learn the assembly:

  • Want to learn more about how the CPU works.
  • Looking for a challenge.
  • Want to learn how to write efficient code.
  • Want to write faster programs.
  • Want to know more about dev when I mastered the build.
  • If I can master the assembly, learning more about HLL will be easier.
  • Want something to offer when applying for a job that others don't have.
  • Interested in AVR, for example, Arduino, which uses C rather than assembly, but would like to know more about AVR.

Thanks. T

+6
assembly
source share
4 answers

1) In fact, you cannot ā€œdamageā€ your system more from running the build program than, for example, from C. On a modern OS, the worst thing you usually end up with is the failure of your process. However, it may be a little easier to compromise your process from assembler code. If you want to get something useful from the emulator, check out Bochs or QEMU - instead of just providing a sandbox, they have useful debugging tools. You will be fine without vm, though by writing + test code on your regular OS with your regular debugger.

2) Actually not. You can do a transfer between the OS (but with the same CPU) as you do for C, but building cross-cpu just doesn't make sense (if you want to do this, you can use C or .NET or Java byte- the code).

3) The theme of many fire. Depends on how you look at it ... Assembler is just a compiler that deals with assembly language. There are many tastes of the assembly, some above others; most of those available for x86 support macros. HLA adds a lot of macro support and syntax that many don't like, plus a large standard library. Not my cup of tea (I would prefer to use the "real" HLL), but in my book it is still assembly language.

4) http://www.asmcommunity.net/board/ , http://board.flatassembler.net :) - stay away from IRC channels. Also, stay away from usenet alt.lang.assembly, it was almost destroyed by several middle persons.

As for a few reasons to study the assembly:

6.If I learn assembly, getting to know HLL will be easier.

Not necessarily, and it can be even harder if you "do too much" before breaking into the HLL. I find that some knowledge of machine architecture can lead to writing better software, but only if you learn to constantly not dwell on tiny irrelevant details.

7. You have something to offer when you apply for a job that others will not have.

It will not necessarily help you, since the assembly is absolutely irrelevant in most positions. Damn, you risk the prejudice, "oh, he will never achieve something lost in worthless microoptimization."

+6
source share

Here goes ...

  • x86 is not perfect:
    • Very few 3-op instructions ( lea commonly used as a 3-op add IIRC). I like the instructions with three operations.
    • x86 machine code is very different from micro-operations that actually run on the processor. There is a big pile of preprocessing; the assembly you see says very little about how the CPU works.
    • Many assembly tips (ā€œthis instruction is fasterā€) are a bit outdated. Apparently, you can make some ancient x86 applications faster by using binary conversion of x86 to x86 to get rid of slow instructions.
  • Building does not necessarily teach you how to write "fast code." When someone goes "oh, this $ large_function is slow, so I will write it myself in the assembly", it usually ends more slowly. Reading builds and slowing down slow bits is helpful; you can then tweak the code to find out what helps the compiler (even if it's as simple as ā€œoh, GCC didn't notice that the result of this function call is constantā€).
  • The assembly probably allows you to write less code (people are well versed in the code golf course), but the biggest saving in space is often because you don't need to include the C runtime. People can also leave without following the challenges.
  • Operating systems are mostly not written in the assembly (this is where I dig up a joke about the person / people who wrote the entire OS in the assembly, only to find out that it was slower). A few bits, the largest of which is the bootloader (which on x86 is still in 16-bit real-time mode). I know someone who has programmed something in their bootloader; it sounds fun (but you can run it in a virtual machine, if only so that you can use the Internet at the same time).
  • Assembling probably will not help you with most jobs (but just as I would not work for a place that wanted to see $ list_of_languages ​​in my resume, I would not work for a place that rejected me, you did some hobbies collector).
  • The assembly is not portable. Even systems that use the same CPU often use different ABIs (for example, the "classic" Mac OS and Mac OS X).

Most CS courses usually use something RISCy (ARM, MIPS, SPARC). I started with the M68K, picked up the PPC a bit and recognized ARM at the university. ARM is fairly clean and potentially useful if you want to work with phones / embedded devices or for ARM; for fun things you can do on ARM, try SheevaPlug or similar.

I have never done anything on a microcontroller, but it looks like using ARM dev boards (perhaps the most interesting thing that I had on the entire CS course).

+1
source share

As you say in nr. 8, I recommend you use AVR, as it is a good platform for learning and using assembler.

Why?

Because on my computer, I didn’t just run some kind of self-employed assembler program, except in the emulator.
I can’t think of any ordinary PC program where it makes sense to program in assembler than in a modern, complex language.

AVR or other microcontroller (μc) related software is very close to hardware filling in registers, shifting bit sets, etc.
At μc, you get immediate results that you can show (flash some led! Yeah.). In addition, μc programs tend to be short, and their speed depends on efficient programming.

0
source share

Assembly language optimization is a thing of the past. Modern C / C ++ compilers and processors are amazingly effective at optimizing well-written C code. They are well aware of all the tricks for ordering instructions so that they maximize parallel execution and maximize the use of cache. This is very difficult to do manually. Most compilers also have the ability to optimize size if this is a problem.

If you want to play with the build, you can check out the GNU builder. This is a reasonably cross platform, but assembly is not inherently a cross platform. You program assembly language because you want to perform some specific hardware tricks that your compiler may not know.

If I were you, and I wanted to go low, I would rather delve into the graphics equipment. Quite close to magic, what you can do with a modern GPU.

Or learn to be great in C ++. Check out sites dedicated to boost.org or gaming programming. This will give you a lot of problems and all the necessary speed.

0
source share

All Articles