Simple Assembly Language doubts

I had worked out some code for my assignment and something tells me that I'm not doing it correctly.. Hope someone can take a look at it. Thank you!

 AREA   Reset, CODE, READONLY

  ENTRY

  LDR  r1, = 0x13579BA0
  MOV  r3, #0
  MOV  r4, #0
  MOV  r2, #8

Loop  CMP  r2, #0
  BGE   DONE

  LDR  r5, [r1, r4]
  AND  r5, r5, #0x00000000
  ADD  r3, r3, r5
  ADD  r4, r4, #4

  SUB  r2, r2, #1
  B    Loop
  LDR  r0, [r3]
DONE  B    DONE

  END

Write an ARM assembly program that will add the hexadecimal digits in register 1 and save the sum in register 0. For example, if r1 is initialized as follows:

        LDR    r1, =0x120A760C

When you program has run to completion, register 0 will contain the sum of 1+2+0+A+7+6+0+C.

You will need to use the following in your solution: · An 8-iteration loop · Logical shift right instruction · The AND instruction (used to force selected bits to 0)

I know that I did not even use LSR. where should I put it? I'm just getting started on Assembly hope someone makes some improvements on this code..

链接地址: http://www.djcxy.com/p/72558.html

上一篇: ARM汇编器BCD转换为不带乘法指令的整数

下一篇: 简单的汇编语言怀疑