If you are a student of electronic communication or are engaged in embedded electronic communication work engineer, assistant engineer, intern, handyman, I think you have a complex fear of the assembly, and even this fear is the University of learning "microcomputer technology" began. But for the author's superficial work experience, it seems that if you can master or step back and understand the assembly, then you can enjoy the fun as a hardware programmer at the bottom. Imagine using the assembly arbitrarily manipulate an ARM core processor register, memory space, peripheral space, play it in the palm, this is not a sense of accomplishment.
At the same time, I think, to have a more profound understanding of the arm core, it really has to cross the assembly of this. Because a lot of things related to the assembly, such as ARM's interrupt vector table, interrupt process mode, stack changes, arm of some coprocessor registers, Cache,mmu and so on. So I think I need to record how to engage in this arm of the Assembly.
If someone called the author of the scene to an arm assembly show, that really test people, probably is not written, this may also be related to the author's bad habits, that is, some things do not need to be quickly forgotten by the brain. However, if you can give me an arm instruction table, or the relevant compiler documentation for reference, write a piece of the arm boot file can be used, it is still not a problem. So if you do not remember the so-called "streamlined instruction set", also do not have to be too discouraged, download a copy of the instructions from the predecessors, according to the need for a piece of a check. The assembler program starts with the "MOV, LDR, STR" command, which is also a piece of the Assembly to use, and then naturally understand. Now some arm core processors of the official assembly startup file seems very complex, but I think most of it is because such a file will be considered in all kinds of situations, and in the case of users may only use the inside of a situation, so if users can adapt to their own system, The procedure that comes out then is not complicated. On the superficial understanding of the author, an arm of the boot file, as long as there is a section of the interrupt vector table, and stack settings can be the processor run up.
Here are some simple and common instructions to start with. (The author uses the compilation environment is RVDS4.0, the assembly instruction size writing is the same OH)
(1) MOV instruction
mov r0, #0x10; Assigns an immediate number 0x10 to the R0 register. MOV instructions are commonly used in this function.
MOV r0,r1; Assigns the value of the register R1 to the Register R0
(2) LDR directives
LDR r0,=0x12345; loading the constant 0x12345 into the R0 register is not like Mov.
LDR R0,[R1]; load the number on the R1 value to R0, which is a mouthful. such as r1=0x80000000, it is equivalent to the address
The value of 0x80000000 is assigned to R0, which can be expressed in C as follows, unsigned int *pdata= (unsigned
; int *) 0x80000000, "R0" =*pdata; This directive can derive many common forms, no longer examples.
Note: Both the MOV instruction or LDR instruction, can assign a number to a register, but for the MOV instruction, the number of the "MOV" is conditional, not so the number can be used with MOV instructions to assign to a register, Can only be by the 8bit (0 or 1) continuous effective bit through an even number of shifts can be obtained, in this can come to a conclusion is that all small equals 255 of the number can be used MOV instructions, more than 255 also have a line oh. I am accustomed to commonly used LDR directives, but the interest to thick will also use the MOV instructions, "MOV" Can not be used to use LDR instructions.
(3) STR instruction
STR R0,[R1]; Writes the value of the register r0 to an address of R1, such as r1=0x80000000, to a value that writes 0x80000000 to the address r0
Note that STR is often used with LDR and is also the most commonly used pair instruction.
(4) Orr directive
Orr R0,r0,r1; r0 and R1 bitwise OR then assigns to R0
(5) Sub Instruction
Sub R1, R1, #1; R1 minus 1
Subs R1, R1, #1; there is a difference, especially when arm interrupts return when used "subs", to elaborate on this is a lot of
Language, or use it for your own reference.
(6) B,BL directive
Are the jump instruction, the jump range is limited (ARM directive positive and negative 32mb,thumb command plus/minus 16MB)
The b instruction is a jump without a link, and when you jump to a function with a B instruction, you cannot jump back after executing the function.
BL instruction is a link jump, before jumping the program will automatically back up the link register, after jumping out can also jump back.
(7) Circular instruction
mov r0, #3
1
Subs R0, R0, #1
Bne
Note: The previous paragraph is r0 minus 1, the back "bne" is to judge R0 not equal to 0 of the words on the execution "", wherein the "B" can be understood as back, "1" is the assembly label, meaning that the r0 is not equal to 0 o'clock to find the first "1" of the label of the instruction segment and then sequentially executed. It's actually a 3-time loop.
(6) Other common directives ...
Check ARM instruction Set ...