Assembly language Help

Thread Starter

jey11

Joined Jun 7, 2010
25
write an assembly language program to calculate the first 10 geometric sequence a+ar+ar^2................and store them sequentially in memory and push them to stack then display them in decimal 1s interval on seven segment display

I wrote a program for sum of Fibonacci series see below and stuck power of two. Thanks for your help.
Code:
start:
    mov r0, #0 @ answer
    mov r1, #10 @ n = 10
    mov r2, #0 @ first value in sequence
    mov r3, #1 @ second value in sequence
    mov r4, #0 @ i = 0
    mov r6,#0  @ Sum
  

loop:
    add r4, r4, #1
    cmp r1, r4
    ble exit
    mov r5, r0
    add r0, r2, r3
    mov r2, r0
    mov r3, r5
    add r6, r6,r0
    bal loop
exit:
    mov r7, #1
Moderator edit: added code tags like this: [code] your code [/code]
 

MrChips

Joined Oct 2, 2009
24,235
Is this homework?

There are hundreds of different ASM languages.
You need to state the target processor or MCU.

You also need to add appropriate comments on your lines on code, not what the instruction does since that is evident, but the intended purpose of the statement.

Begin every programming task with a flow chart or pseudo code.
 

Thread Starter

jey11

Joined Jun 7, 2010
25
Using ARM V7 simulator.
Code:
.global _start
_start:
   
start:
    mov r0, #0 @ answer
    mov r1, #10 @ n = 10
    mov r2, #2 @ first value in sequence
    mov r3, #2 @ multiplier
    mov r4, #0 @ i = 0
    mov r6,#0  @ Sum
   

loop:
    add r4, r4, #1      // loop condition
    cmp r1, r4          // compare the loop reach to max
    ble exit
    mov r5, r0           // move nth value to r5 temp
    mul r0, r2, r3      // multiply first value with multiplier
    mov r2, r0          // move multiplied value to r2
   
    add r6, r6,r0          // sum all multiplied values
    bal loop
exit:
Stuck on "store them sequentially in memory and push them to stack then display them in decimal 1s interval on seven segment display "

Thanks
Jey

Moderator edit: added code tags like this [code] your code... [/code]
 
Top