How can I be good at a meeting?

The answer to this question, of course, is "write the assembly code!"

But I can do this: I know the basic x86 syntax, types of registers and how to use them, routines, etc. etc.

When I took the assembly class, each assignment had the maximum number of instructions that we were allowed to use. If we go over, we lose points - this teaches us to do something effectively. You know, effectively, that if you saw how C does such things, you can attack that person to create complex code.

For C, you can suggest "write a multi-threaded program" or "write a server / client socket". For PHP, suggestions could be "write personal blog software." To find out the syntax of a language, a "project eiler" is often suggested.

So my questions are:

  • What things can I write in an assembly that will allow me to hone my assembly skills and performance? For example, I could solve the problem of a project euler in x86, but that does not help me with specific build skills. What are the design ideas that I could make that really can be encoded in assembler?

  • How would I start profiling, am I really writing "good" code? For example, with C and sockets on the Internet there are a billion study guides, and there are a billion people on my friends list who can look at my code, and there are about a billion questions about them: so it’s easier to measure one progress.

  • Are there any existing heavy build projects that I can look at to learn from? Or even parts of the programs in which they are broken into an assembly for [a specific task] for the sake of efficiency?

  • What books should I read? Blogs of people who usually look at low-level things?

(It is desirable that I could do on x86 on linux. I believe that the concepts will be transferred to other architectures.)

+7
performance assembly
source share
6 answers

An assembly can do many things that C cannot, and the optimizer is not magical. However, the most useful things that do not require you to be a demigod of the assembly fall into the compiler, standard libraries, and interpreter runtime categories.

Trampolines, for example, are or may be useful in all three of them, and you simply cannot use C to create an arbitrary call stack.

To better write the assembly, check out the guides here:

http://www.agner.org/optimize/

To see programs written exclusively in the assembly, and a community obsessed with optimization to compare you:

http://flatassembler.net/

+3
source share

Good answers. I would also suggest writing a small compiler and writing an assembler for you. Thus, you can think of different ways of doing things in assembler, for example, passing arguments, creating stack frames, composing address expressions, indexing arrays, managing memory, conditional expressions, loops, try-catch, etc. Etc.

+6
source share

One approach may be to select functions from the standard C library (for example, string functions, mem * ()) to implement from scratch in the assembly. Create benchmarking to measure the performance of your code, see if you can provide equal or better performance to the libraries provided on your system. I would not cheat to parse the system library code (after you pounced on it), often useful methods can be found by looking at the disassembled code. Reading other people's code is highly recommended (possibly starting with the codde compilation bit found in Linux kernel sources).

+3
source share

What to write:

Write a simple 3D rendering with texture mapping. This is a worthy project because it is not super complex, but not super trivial. And the fact that you can see the results of the work is always pleasant.

+2
source share

If you are jumping with two legs, consider improving the internal loops of distributed mass computing with the BOINC -like SETI @Home project . ( Other projects here .)

On my computers, every SETI @Home work unit needs a clock to crack, and is almost completely connected to the processor. As a rule, C / C ++ compilers are not excellent at organizing parallel floating-point and integer operations, especially for each type of CPU. It would be especially useful to optimize, say, x86 instructions for optimization for the specific capabilities of the processor on which it actually runs: SSE SSE2, 80586, 80686, Athlon, etc. Those who are still working with equipment with ten years of the year will appreciate such optimizations and modern equipment, undoubtedly, will benefit to a large extent.

+1
source share

First, how do you define a "good build code"? The fastest code, the most compatible with ABI code, or the code that is easiest to read? I think that β€œgood” depends on a common goal, and you really did not tell us what you want to use for assembly.

Others recommended writing a rasterizer software. I could catch on to this, but since you already know the x86 mnemonics, you don't need to write more build code. You need to understand more about how cars work under the hood.

My suggestion is to write an emulator of a system-wide or user space. I wrote a system emulator for ARM920 and learned a ton without writing one prefabricated mnemonic! Well, it ended up slow, slow, but I wrote it as a translator in pure C. Now I know most of the dark secrets of the ARM architecture, and this has given me a new perspective on how embedded computers work.

Just remember that peripherals can be difficult to follow. There is nothing wrong with emulating a processor, but adding simplified psuedo peripherals. If you are good, you can even create a plug & play system for them.

You might want to check out QEMU and DosBox to get good ideas, although they use a JIT scheme. My interpreter is here gp2xemu . It was an attempt at an emulator for GP2x, but I was stuck due to sucking documentation.

+1
source share

All Articles