Question: PLEASE HELP IN ASSEMBLY LANGUAGE:: 1.Input an integer, then output the sum of all integers up to and including the one inputted. For example, if

PLEASE HELP IN ASSEMBLY LANGUAGE::

1.Input an integer, then output the sum of all integers up to and including the one inputted. For example, if the user inputs 6 then your program must output 21. (Because 1+2+3+4+5+6 = 21)

2.Input several integers, some positive, some negative, and the last one should be 0. Output only the positive ones.

What I have so far:

BR main

num: .EQUATE 0 ;local variable #2d

sum: .EQUATE 4 ;local variable #2d

msg: .ASCII "The sum is: \x00"

main: SUBSP 4,i ;allocate #sum #num

LDA 0,i

STA sum,s

DECI num,s

while: LDA num,s

CPA 0,i

BREQ endWhile

LDA sum,s

ADDA num,s

STA sum,s

DECI num,s

ADDA 1,s

BR while

endWhile: STRO msg,d

DECO sum,s

ADDSP 4,i ;deallocate #num #sum

STOP

.END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!