help in 68k assmbly language

Hello everyone,

i am taking a class about assembly language where we have to use easy68k assembler to write assembly programs,

the teacher sucks and expect us to do everything without explaining anything.

if it is possible i am seeking someones help in my first program.

which is :

write a program that will allow a user to enter an arbitrary number of unsigned integers. Zero is to be used as a sentinel value for the end of input (when the user enters zero, it means they are done entering input). Your program will compute the sum of these numbers. All operations are to be done using 16 bits. An error message will be printed to the screen if an overflow occurs, otherwise the sum will be printed.

* Begin your data area at location $3100.
o Reserve space for 15 words, label it INPUT.
o Define a string that you will use to prompt the user for input, such as

"Enter values, zero when done:"

o Define a string that you will use if the user has entered 15 numbers, such as

"That is all the input allowed. Calculating sum..."

o Define a string that you will use if you need to print an error message, such as

"The values you entered caused an overflow condition."

o Define a string that you will use to ask the user if they want to repeat, such as

"Do you want to repeat? [0=No, 1=Yes]."

* Begin your main routine at location $4000:
o Prompt the user to enter input.
o Loop, reading input using TRAP #15, until the user enters zero.
o As each value is entered, store it sequentially in memory beginning at the location labeled INPUT.
o You only have space for 15 numbers, so if the user enters 15 values print the message above and proceed with the next step.
o Load D0 with the count (the number of values input).
o Load A0 with the address given by INPUT.
o Call the subroutine, SUM, to compute the sum.
o On return, if D0 contains 0, print the sum contained in D1.
o Else if D0 contains 1, print the error message.
o Ask the user if they would like to compute another sum, if so repeat the steps listed above.
o If not, then return control to the simulator using TRAP #15.

* Begin your subroutine at location $4500, label it SUM:
o Expects the count in D0 and the starting address of the input in A0.
o Loop count times, adding each input value to a sum in D1.
o Use indirect addressing to obtain the input values.
o Test for overflow (unsigned).
o Return the value 1 in D0 if an overflow condition occurred.
o Otherwise, return a 0 in D0, and the sum in D1.

* Be sure to document your program.

thanks for anyone's help.........

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!