I have an assignment but I'm having trouble because I don't know almost any assembly. I have figured out something but please help me if I have mistakes, and with the 3rd formula.

Using knowledge from previous weeks, write assembly programs which calculate the given formulas:
a)Sum (i=1 to n) i
b)Mult (i=1 to n) i
c)Mult (i=0 to n) (2*i + 1)
n = <Last digit of Student ID> mod 5
If n = 0, then n = 5

Please help me with the c) . Here what I have so far:

;part a

ld r0, #0h	; load 0 to r0
ld r1, #1h	; load 1 ro r1

add r0, r1	; add r1 to r0 and store on r0
inc r1		; increase r1 by 1
eq r1, #5h	; compare r1 == 5
jr z, loop1	; if not true go loop1 again

;part b

clr r0
ld r1, #1h
ld r2, #1h

ld r0, r2
mult rr0
inc r2
eq r2, #5h
jr z, loop2
6 Years
Discussion Span
Last Post by Kieran Y5

I might be able to help out but I need to know what assembler you are using (Nasm, Tasm, etc).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.