Assembly code

Hi, I try to execute the following code:

        LDR R1,=0X40000000
        LDR R2,=0X11223344
        STR R2,[R1]
        ADD R1,R1,#3
        LDR R2,=0X55667788
        STR R2,[R1]
        ADD R1,R1,#3
        LDR R2,=0X99AABBCC
        STR R2,[R1]
        ADD R1,R1,#3
        LDR R2,=0XDDEEFF11
        STR R2,[R1]
S        B    S        
       After execution data in memory is as follows:

0x40000000: 88 77 66 55 CC BB AA 99 11 FF EE DD

Why and how?

Thanks in advance.

  • Most "classic" core truncate the addresses if you do a unaligned access. So 0x4000.0003 becomes 0x4000.0000 on the address bus.
    0x4000.0006 becomes 0x4000.0004 and last 0x4000.0009 becomes 0x4000.0008.

    1. This how assembly implements things like if statements. You jump to specific code if the statement is true, and somewhere else (or not jump) if not. For example, if(a == b) when EAX is holding the value of a and EBX is holding the value of b, the assembly code will subtract the values (cmp subtract the registers and save the result in the flag registers), and if it zero, it jumps to the code inside the if, and if not, continue or jump to the else statement.

More questions in this forum
There are no posts to show. This could be because there are no posts in this forum or due to a filter.