What is a good built-in assembler learning platform?

I have good programming experience, but all this is in high-level languages. I recently took C, and this project went very well, and the learning experience was worth it.

Now I want to take one more step and learn assembly language, but ideally I would like to learn on the built-in platform where I see some of my future projects. The question is, what is the best starting point or “set” for a beginner?

I am looking for something that is easy enough to assemble, can do things of the “real world” and, as a rule, provides a good foundation on which to build.

+8
assembly embedded
source share
5 answers

AVR is not the best instruction set. I would save it for the second or third set of commands. But in the end, you may find yourself there, as arduino is incredibly popular and has good support through the community (although asm is the exception, not the rule in this world).

right now you can get the msp430 board for $ 4.30, basically TI eats the cost to give these things away. msp430 is a good set of instructions to learn.

Armmite pro is not bad, arduino size, board, but uses a hand instead of avr. hand and thumb are good instruction sets.

There are emulators for almost everything, if not, creating an emulator is a very good way to find out how everything works. If nothing else, I usually do not recommend writing a disassembler.

Also, the set of commands with the C compiler is good in that you can write some code in C, play with optimization and see what type of assembler is output, and learn different things about assembler. Learn some tricks for efficiency and productivity first, later you can beat the compiler, or at least be on par. all of those mentioned have some kind of C compiler, avr and msp have ways to make gcc work, hands and thumb are supported by mainline compilers. Llvm is automatically a cross-compiler, so you do not need to compile the compiler to get started, the msp430 database for llvm is experimental, but should work or be close, hands and thumbs are ok (use -m32 in clang to avoid 64-bit integers numbers on a 64-bit node).

The stellaris chips, formerly a microworld, are now ti (texas instruments) good, only with a finger / thumb2. Mbed is actually pretty good, except for the blue LEDs (give me a migraine), you do not need to make a sandbox, connect a USB drive, mount it as a file system, copy your .bin file to a flash, press the reset button and it starts your program.

sparkfun.com is your friend, developer tools, and there is a long list of microcontroller-based boards from all players. The msp430 tip I mentioned is about $ 5, something there, army pro, a lot of arduino flavors, I recommend a panel for lily, it's about the same price as arduino pro, but already has a header soldered for use with small USB to serial stuff that you also want to purchase. stellaris is not represented in sparking, but many boards are less than $ 50.

The msp430, armmite pro, arduino, stellaris, mbed, and other boards need power that usually goes through a USB cable or is used for serial operation by some usb ftdi-based users.

If you are following an emulator’s route, qemu supports multiple sets of commands, hands / thumb. There are gameboy and nds emulators. I wrote one on github called thumbulator. the nds ideas emulator, in the initial form, comes with hand kernels for both arm9 and arm7, but I did not try to extract and use them myself. If you want to go to an old school, there are tons of 6502 and z80 emulators there, and some compilers believe or not, of course, assembler.

The last assembler that I would know is x86, a terrible set of commands, and with options and microcoding you will not exceed the compiler in all directions, yes your computer at that moment, but all x86 computers are not worth the time, other instruction sets are more important to know ( hand, thumb, thumb2, avr).

+2
source share

For the built-in AVR platform, you can use the free WinAVR , which has an integrated simulator, so it will be easy to recognize ASM even without a real board. You can find the ASM tutorial here . A quick guide for AVR can be found here . For example, all Arduino processor boards have an AVR inside them, so you have a very wide selection.

0
source share

I partially relate to the 14-bit PIC (Microchip) instruction set for the low end and the ARM instruction set for the high end. Both are relatively simple, but powerful for what they can do. The PIC 18F series has a slightly more powerful instruction set, but aesthetically I don't like it.

0
source share

Now I want to take one more step and learn assembly language

Is this really a step forward or a step back? This is probably the path to a deeper understanding, and it hardly means the path to greater productivity.


There is not a single “assembly language”, each processor architecture has its own set of instructions, so learning assembly language will only allow you to program this specific target (although it will also give you general low-level programming skills and an understanding of how the processor works). The code you create will also be specific to one architecture, so all your efforts and investments in the code will be much less portable than in a high-level language. If in the end the architecture that you choose becomes obsolete (and there are many), then the build skills for this architecture become largely redundant knowledge, in addition to the general skills that it can provide (it will quickly learn a new set of commands and architecture).

If you do not do a lot of assembler and become proficient in a certain set of instructions (and there is a strong justification for this), then learning assembly language is generally of limited value. This is useful if you inject the initial code to initialize the processor and create a runtime environment for your C or C ++ code, but it can be largely provided by the chip or the tool vendor, and you do not need a complete incomplete architect or set of instructions to use. or adapting such a code.

The often suggested argument for using assembler is performance, but in general, an optimizing compiler will generate code almost as efficiently as an expert build programmer, and more often than not less experienced one. You see that the compiler is essentially an expert system with respect to the target instruction set and architecture. He usually knows every instruction and execution time available, every register, every addressing mode, and understands the mechanisms of pipelining, caching and branch prediction, etc. On a complex moderatley processor, the experience of compilers will reassign all but the most dedicated full-scale assembler to programmers, and on simple processors in any case much less.

One area where assembler may be useful is to use aspects of certain processors that the compiler or its library cannot touch. Usually assembler is used on DSP processors, but even there the use of optimized DSP libraries (usually written in assembler), or compiler extensions or language idioms that the compiler recognizes and can optimize, make this pretty much unnecessary and learn the DSP instruction set with SIMD capabilities and parallel execution - a significant investment.

The last time I needed to use assembler other than the C startup code, it was when porting code from one ARM unlock to a new one with a VFP coprocessor; although the recompiled library used VFP, the sqrt () function was implemented using the convergence algorithm rather than the sqrt hardware instruction. One function, one or two assembly lines; Of course, I did not need to study the ARM instruction set to get to this.

The only prefabricated languages ​​that I studied in detail are the Z80 and 8051. That was a long time ago, and I forgot everything, and my knowledge is now largely outdated. However, the general skills that I learned allow me to set up systems and lift the tablet, as already described, but as someone who recruits other developers of embedded systems, I would not pay much attention to the skills of dialed assemblers.

I think that in assembler you will need knowledge of the level of tourist / phraseological knowledge that you need to get through when you need, or speak Russian so that your skills have real value, something between them was of little importance.

However, if you want or feel the need, I suggest an ARM Cortex M3 device. In the near future, it is unlikely to become obsolete (devices from several license providers) and is complex enough and modern enough to give you good grounding for other architectures.

0
source share

More important than learning to assembler, learn at least two. There is great diversity in existing architectures, and knowing several assemblies seems like a good way to avoid overly generalized assumptions.

Many installation courses use MIPS. The MIPS instruction set is simple and is used by high-performance PIC microcontrollers (from Microchip). MIPS processors are commonly found in home routers. OpenWRT is a firmware replacement for many of these Linux-based home routers. An OpenWRT-compatible router costs $ 50 and is a cheap and easy way to enter the world of embedded systems.

Many mobile platforms, in particular mobile phones, use ARM processors (in fact, all smartphones and tablets use ARM derivatives, but I read that about 15% of cheap, non-smartphone phones still use something else, usually MIPS). The ARM platform is a bit complicated; There are several sets of commands (original 26-bit ARM, 32-bit ARM, Thumb, Thumb-2) and several calling conventions (ATPCS, AAPCS ...). ARM-based development kits can be purchased from several vendors, for example. Gumstix There are several ARM-based routers that OpenWRT runs on, but they are much less common than MIPS-based routers.

The automotive and aviation industries seem to be very fond of PowerPC processors for their embedded systems. In addition, currently the main game consoles use the PowerPC architecture (PS3, Xbox 360, Wii). For the PowerPC development platform, I recommend buying an old Mac, for example. on ebay or from a refurbished computer dealer. There are pointers from Low End Mac ; Find a car with G3 or G4. I bought a $ 60 G3-based clamshell on iBay on Ebay; with NetBSD on it, it is an ideal PowerPC development platform.

The x86 processor found on any PC should also be studied, if only because it is so common. The machine you use, bet on your PC or Mac after 2005, is your development platform, so it's cheap (you already have the hardware). The set of instructions is "inelegant." Do not recognize it as your first assembly, but look at it for a second or third. Every year or so, the x86 processor develops a new set of additional instructions, so now they have hundreds of them, which can be very overwhelming; I recommend starting with the instructions for the original 80386 .

Some other architectures have been used and are still used for embedded products, for example. 68,000, but they are less common. Please note that I am talking about "large" embedded products here. There are also smaller systems with architectures such as AVR, pre-MIPS PIC, 80C51 ... It depends on when you say “built-in”, you think “home router” or “programmable toaster”.

In any case, I also recommend using QEMU . QEMU is a software emulator. It can run a fully functional virtual machine based on ARM or MIPS, complete with an operating system (for example, Debian Linux ), on a base PC.This will not help you with optimization related to synchronization, but it greatly simplifies development and correction.

0
source share

Source: https://habr.com/ru/post/650864/


All Articles