What does this ARM assembly program do?

2019-09-25 07:00发布

Can somebody explain to me what this ARM assembly program does?

.L5:
    .worddata
    .wordtotal
_start:
    ldr ip, .L5
    mov r1, #0
    ldr r0, .L5+4
    mov r3, r1
    mov r2, r1
    ldr ip, [ip, #0]
    str r1, [r0, #0]
.L2:
    ldr r1, [ip, r3]
    add r3, r3, #4
    cmp r3, #64
    add r2, r2, r1
    str r2, [r0, #0]
    bne .L2

标签: assembly arm
1条回答
贪生不怕死
2楼-- · 2019-09-25 07:40

This function seems to be trivial and stupid at the same time.

extern int * worddata;
extern volatile int wordtotal;

void start(void)
{
  int i, temp;
  wordtotal = 0;
  for (i = 0; i < 16; ++i)
  {
    temp = worddata[i];
    wordtotal += temp;
  }
}

Have fun.

查看更多
登录 后发表回答