Nobody codes programs in machine code anymore, and the volume of assembly language programming done in industry is limited. However, learning those two programming lanuages remains the simplest way to understand what’s “underneath the hood” of a given microcontroller (ìC) and prepare one once and for all high-level code programming. Debugging is frequently performed on the assembly level even for high-level code programs (that is usually C for ìCs).
All compilers will generate assembly listings for the code they generate so the programmer can see the details of the code they produce. Difficult to get bugs usually require inspecting this program logic at this level. Therefore, any ìC programmer will be able to read and understand assembly code code. Many individuals (this author included) believe the most effective way (arguably the only way) to get proficient at reading assembly language is always to program in it. The most effective overview of assembly code is always to first look at several programs developed in computer code. It will help offer a better knowledge of the ìC framework, plus an knowledge of the purpose of many of the features that can be found in assembly.
What do After all from the framework of any ìC? It is the detailed functional description (what it does – not the actual way it can it) in the ìC. It is not required to understand anything about how to develop a ìC to be able to understand its framework. It is actually, however, essential to understand its framework to be able to either design the hardware for this, or even to program it in assembly. In fact, you have to know a lot regarding the architecture in the I/O, timer, and possibly the interrupt subsystems even to program a ìC in C.
Designing computers is the topic of other courses. Programming a ìC (and interfacing it to the world) is the topic of this program. Learning our ìC’s framework is the first step. The main components of the framework of a given ìC is the description of the CPU, its memory organization, its processor control registers, I/O registers, and timer subsystems registers that can be found. These later three are usually memory-mapped registers.
An assembly statement consists as much as four fields. They may be: [label[:]] [operation-code-specification operand(s) separated by commas] [;comment]
where  surround optional fields (and also the optional colon in the label field). The only real field not optional is the operand(s) field along with its existence and number of elements depends on the operation code (opcode) field. It will not (must not) exist for many instructions. The label field supplies a symbolic handle for the information specified on that and perhaps succeeding lines. It is employed to assign names to program variables, constants, and the starting of parts of code that require a reputation. Code sections which need names include subroutines, beginnings of loops, or elements of if-then-else style program constructs. The opcode field can specify either a unit instruction or it could be a command for the assembler. Inside the later case it is almost always known as a pseudo opcode or pseudo-op for short.
These assemblers only have a few pseudo-ops, but 120 machine instruction mnemonics. The opcode field dictates the quantity of operands that can be present (if any). Any one of these fields might appear on the line itself except the operands field which must exist on a single line since the opcode that it is connected. If a label is not followed by the optional colon it has to start in column 1.
In addition to that the fields are in a free of charge format. Any quantity of white space may appear between fields. No field can contain white space except the comment field as well as the operand field when it is a quoted string. No statement, in and of itself, requires a izeurf label, but we will see programming situations that can necessitate labels. Try to identify those situations in the following assembly code programs which are rewrites from the previously presented machine code examples.