The following content is reprinted:
First, let's look at a piece of assembly code.
LDR R0,=0x56000010 #R0 is set to be register GPBCON and is used to select pin function for Port B #in,out special function and others MOV R1,#0x00004000 STR R1,[R0] #pin GPB7 is set to be output port
The functions of the preceding three Assembly statements are to store the value 0x00004000 to a storage unit with the address 0x56000010.
The disassembly code is as follows:
0: e59f0044 ldr r0, [pc, #68] ; 0x4c 4: e3a01901 mov r1, #16384 ; 0x4000 8: e5801000 str r1, [r0] ...... 4c: 56000010 undefined
LDR r0, = 0x56000010 is converted to the LDR command for execution.
Second look
LDR R0,=0x56000000 MOV R1,#0x00004000STR R1,[R0]
The disassembly code is as follows:
0: e3a00456 mov r0, #1442840576 ; 0x56000000 4: e3a01901 mov r1, #16384 ; 0x4000 8: e5801000 str r1, [r0]
Here LDR r0, = 0x56000000 is converted to mov r0, #1442840576
That is to say, the LDR pseudo command is based on the subsequent data values to decide the conversion to the LDR command or mov command execution.
Similarly, we assign a value to R0. Can LDR r0, = 0x56000010 be replaced by mov r0, #0x561_10,
Iii. Differences between mov and LDR
There is a limit on the immediate number after the mov command. This immediate number is required.Valid data is obtained only after an 8-bit binary number is shifted to the right after an even number of times.
LDR r0, = 0x56000000 is converted to mov r0, #0x56000000, where the number of immediate 0x56000000 can be obtained by the right shift of 0x56 through loops, 0x5621310 cannot be obtained after an even number of eight-bit binary values are shifted to the right, so it cannot be converted to the mov command.
4. Example:
mov R0,#0x101mov R0,#0xFF1
The preceding two commands are incorrect because the immediate number is invalid.
In this case, using mov commands is troublesome, because some simple data is easier to see, and some data is not easy to see if it is legal data.
5. Use the LDR command to solve this problem
To solve this problem, we can use the LDR pseudo command to implement the conversion to the LDR command or mov command execution based on the subsequent number of immediate commands, if the value of the valid number of mov commands is not met, the value is converted to the mov command. If the value is not met, the value is converted to the LDR loading command.
In the uboot source code, we can see this command mov R1, #0 xffffffff
A bit confusing. view the disassembly Code as follows:
MVN R1, #0
It turns out that.