This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

useless arm asm instructions

Note: This was originally posted on 10th December 2009 at http://forums.arm.com

Hi,

Still trying to learn arm asm and this time there is a construct I don't understand :

void add_chunk(somestruct* ptrSomeStruct)
{
  unknow chunkData;

__text:00015718 _add_chunk                              ;
__text:00015718                                         ;
__text:00015718
__text:00015718 var_8           = -8
__text:00015718
__text:00015718                 PUSH    {R4,R7,LR}
__text:0001571A                 ADD     R7, SP, #0xC+var_8
__text:0001571C                 MOV     R4, R0    ; R4 = ptrSomeStruct
__text:0001571E                 MOVS    R0, #0x98 ; '√ø'   ; size_t
__text:00015720                 BLX     _malloc    ; chunkData = malloc(0x98)
__text:00015724                 CBZ     R0, locret_15736  ; if (!chunkData) goto locret_15736
__text:00015726                 MOVS    R3, #0    ; R3 = 0
__text:00015728                 STR     R3, [R0]           ; chunkData->field0 = 0;
__text:0001572A                 STR     R3, [R0,#4]   ; chunkData->field4 = 0;
__text:0001572C                 LDR.W   R3, [R4,#0xB4]  ; R3 = ptrSomeStruct-> fieldB4;
__text:00015730                 STR     R0, [R3]           ; ptrSomeStruct->fieldB4 = chunkData;
__text:00015732                 STR.W   R0, [R4,#0xB4]         ; ptrSomeStruct->fieldB4 = chunkData;
__text:00015736
__text:00015736 locret_15736                           
_add_chunk+C j
__text:00015736                 POP     {R4,R7,PC}
__text:00015736
}

What I don't understand (if I didn't badly interpret last asm lines) is the fact that the 2 last lines
are doing exactly the same.
But maybe I forgot something simple.
I should add that I don't have corresponding source code so I make some assumptions about structure.
0