Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   Need help to write an assembly language program. (http://www.go4expert.com/forums/help-write-assembly-language-program-t19875/)

myst3 24Oct2009 06:40

Need help to write an assembly language program.
 
I'm pretty new to ALP. I need to write a program to find the total, minimum and maximum of 10 numbers. I sort of have the part to find the total as can be seen below.

IN
ADD 55
STO 55
LDA 44
SUB 66
STO 44
BRZ 08
BR 00
LDA 55
OUT
HLT
*44
DAT 010
*55
DAT 000
*66
DAT 001

I need to know how to add on to that to find the minimum and maximum number.

Thanks.

xpi0t0s 26Oct2009 01:57

Re: Need help to write an assembly language program.
 
Make two variables (memory locations, or registers, whichever you prefer) equal to the first number; one represents minimum number found so far and the other represents maximum so far. As you loop over the numbers, if the current one is bigger than "maximum so far", then set "maximum so far" equal to "current one", and similar for "minimum so far". At the end of the loop these two variables will contain the smallest and largest numbers in the data set.


All times are GMT +5.5. The time now is 04:02.