Stevebe wrote: ↑13 Jan 2020, 19:36
Go4IT wrote: ↑13 Jan 2020, 18:44
Sorry bones, you disassembled nonsense,
just my stupidity
Oh boy, you don't got me wrong, didn't you!?
What i mean is that if you use the wrong settings, all that come out of the disassembler makes no sense.
If you put in the params i pointed you in my link and disassemble ("c") the first 8 DWORDs it should look like this:
13-01-_2020_22-30-18.png
You see the branch operations, each one 4 byte long (=DWORD). Following the RESET-Vector at 0x0000 it branches to the named location "loc_1018" which IDA creates on the fly for the address offset 0x0000 01018. Simply double-click the name and you get here:
13-01-_2020_22-36-31.png
The first operations setup the stackpointer (place for variables) and the program execution mode (CPSR):
Code: Select all
ROM:00001018 loc_1018 ; CODE XREF: ROM:00000000↑j
ROM:00001018 LDR R0, =0x4000BEFC
ROM:0000101C MSR CPSR_c, #0xD2
ROM:00001020 SUB SP, R0, #0x100
ROM:00001024 MSR CPSR_c, #0x5F ; '_'
ROM:00001028 B loc_3DF8
ROM:00001028 ; ---------------------------------------------------------------------------
ROM:0000102C dword_102C DCD 0x4000BEFC ; DATA XREF: ROM:loc_1018↑r
ROM:00001030 ; ---------------------------------------------------------------------------
As you see "LDR" means "load register", in this case "R0", one of 16 32-Bit registers of an ARM CPU. As each operation in ARM Mode is exactly 4 bytes long (1 DWORD) it is not possible to load a 32 Bit value directly. Instead the value itself is placed "nearby" the load operator an only an offset from the current PC (program counter, which is the execution pointer of the CPU) refers to the memory location where the 32-Bit value is placed. You see this by IDA using the ASM macro "=" which denotes this kind of operation. Because IDA knows where the bytes are located, it can create a named location for it ("dword_102C" above) and also can show the value loaded directly after the equal sign. Helpfull, isn't it?
You also find a data reference given at the dword location. It points upwards (arrow) which means the command using it is located before this. It also gives the segment "ROM" and the location "loc_1018". There are some context-functions (right mouse) which help you go to the used locations.
"MSR" means that the value is written to a register of the Co-Processor (CP15). Here it is 0xD2 which set's the MPU to Supervisor mode.
The next one, "SUB" is funny, it primarily loads the stackpointer "SP" with a value of R0 - 0x100, which is 0x4000BDFC. So from this memory location downwards the variables (implicitly used by branch operations or by push/pop operations, depending in the standard calling convention used) are stored. As we know that MAC's SDRAM is located from 0x4000 0000 up to 0x4000 BFFF, we now know where the stack is located
This operation needs a special privilege, which was set before by the CPSR command. The following instruction permits changes of the stackpointer register by setting a lower privilege. Any attempt to do so would raise an internal error and abort the program (reset vector).
In the last instruction it branches forward to 0x3DF8, where it continue execution.