为什么我的功能没有循环?以及如何在ARM Assembly中创建此功能?

时间:2019-03-23 01:53:23

标签: assembly arm

Click for question description

此代码是使用ARM程序集实现的,并且有一个主函数调用幻数函数输入'Yusuf Ozturk'

/*
 * AssemblyFunctions.S
 *
 */

.global upper
.text
upper:











    bx  lr

.global computeMagicNumber
.text 
computeMagicNumber:
  MOV R1, #0 //The value gets i = 0
  MOV R3, #0 //Sets the sum to 0
  MOV R5, #0 //R5 holds the value of Magic Number
  LOOP:
    LDR R0, [R2, R1] //R2 gets the string inputted by the user at the index i
    CMP R2, #0 //If the string is empty then...
    BEQ END //...the program is branched to end
    ADD R1, #1 // Increments the value of i by 1
    MUL R4, R2, R1 //R4 gets the value of the string indexed at i multiplied by i+1
    ADD R3, R3, R4 //The sum is added by the value above (R4)
    B LOOP //Returns to top of loop

  END:
    AND R3, #1000 //Sum is divided by 1001 and gets the remainder
    MOV R0, R3 //Value is returned

    bx lr

0 个答案:

没有答案