. Balignl 16, 0 xdeadbeef
Is the 57 lines of the start. s file under the uboot start file.
Baidu is curious about the meaning of this Code:
========================================================== ================
Http://haoyeren.blog.sohu.com/84511571.html)
First, you need to understand. balignl means that this is actually a pseudo operator. The pseudo Operator means that in the machine code, there is no Compilation instruction corresponding to it, and it is implemented by the compiler .. Balignl is. the variant of balign ,. balign indicates that, starting from the current address, the address counter must end with the address that is an integer multiple of the first parameter and record the length of a byte, the information content is the second parameter.
. Balign 8, 0xde
It indicates that, starting from the current address, a byte content of 0xde is filled in front of the address multiple of 8. If the current address is a multiple of 8, nothing is written to the memory.
========================================================== ====================
Http://blog.163.com/mcu_expert/blog/static/131245153201073125947792/
For the. balignl 16, 0xdeadbeef statement, the function description is correct, that is, to insert the special memory value 0xdeadbeef at a certain position. The error lies in my understanding of this 16. 16 is 16 bytes. This is correct, but the origin of 16 is not what I understand as at least 16 bytes, this special memory value can be inserted under any circumstances. In my post on this blog, I answered a user's question and gave a PC address 0x00000007 with an offset of 8 bytes. At this time, it would not be 4 bytes long, at least 16 bytes can be exported to ensure that the insertion of this special memory value is completely incorrect.
For example, if there is a 16-byte offset according to the explanation given to the netizen, there is only one character space when the PC address is 0x0000000f, the value of deadbeef is not enough. And so on, even if this value is any value, the error logic I explained earlier is not satisfied. I have corrected the above inference. Now I will describe the origin of the value 16.
The ARM920T processor core supports the length of 32-bit and 16-bit commands. The 16-bit command is called the thumb instruction set. Because I use the 32-bit instruction set, therefore, everything is described in a 32-bit instruction set.
Since it is a 32-bit instruction set, a command occupies 32 characters, that is, 4 bytes. Therefore, in the debugger, the address display is also 4-byte hop (the debugger has links in this blog post), so the Pc value is also 4-byte hop, there is no possibility that the Pc value is 0x00000007.
Fill in 16 offsets in this place because
. Globl _ start // no memory occupied
_ Start: B start_code // occupies 4 bytes of memory
Ldr pc, _ undefined_instruction // occupies 4 bytes of memory
Ldr pc, _ software_interrupt // occupies 4 bytes of memory
Ldr pc, _ prefetch_abort // occupies 4 bytes of memory
Ldr pc, _ data_abort // occupies 4 bytes of memory
Ldr pc, _ not_used // occupies 4 bytes of memory
Ldr pc, _ IRQ // occupies 4 bytes of memory
Ldr pc, _ FIQ // occupies 4 bytes of memory
4x8 = 32 bytes of memory.
_ Undefined_instruction:. Word undefined_instruction // 4 bytes memory
_ Software_interrupt:. Word software_interrupt // occupies 4 bytes of memory
_ Prefetch_abort:. Word prefetch_abort // occupies 4 bytes of memory
_ Data_abort:. Word data_abort // occupies 4 bytes of memory
_ Not_used:. Word not_used // occupies 4 bytes of memory
_ IRQ:. Word IRQ // occupies 4 bytes of memory
_ FIQ:. Word FIQ // occupies 4 bytes of memory
Memory occupied 4x7 = 28 bytes.
So here. before the balignl 16 and 0xdeadbeef commands, a total of 4x15 = 60 bytes of memory were occupied. Therefore, the author of this Code simply added 1 to the number of 15, that is, 16. Move the current pointer back to the position where the address is 64, and insert the special value 0xdeadbeef in front.
I don't know if this is the author's mistake. It's just a joke, or how to handle it. In fact, there are many situations in which the offset value may be used. If the minimum value is used, it can also be written as. balignl 8, 0 xdeadbeef, which can achieve the same purpose. Because 60 is not a multiple of 8, but 64 is a multiple of 8 (between 60 and 64 are not a multiple of 8, it is also not a multiple of 16, so it is feasible to write 8 and 16 ), if you write 8, it is inserted in front of 64, that is, the starting address of the memory 60. If it is a little bigger, you can enter 32 to achieve the same effect, that is,. balignl 32, 0 xdeadbeef. Of course, it cannot be 4, because the Pc value is a multiple of 4 at any time (60 is a multiple of 4). If it is not 0, it is a multiple of 4, if this value is used, 0xdeadbeef will never be inserted.