Need help to write an assembly language program.

Discussion in 'Assembly Language Programming (ALP) Forum' started by myst3, Oct 24, 2009.

  1. myst3

    myst3 New Member

    Joined:
    Oct 24, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice