HELP.. assembly program- Even Odd numbers

Discussion in 'Assembly Language Programming (ALP) Forum' started by RobertH900, Nov 11, 2009.

  1. RobertH900

    RobertH900 New Member

    Joined:
    Nov 11, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hey, watsup all

    I'm new to assebmly language and i need help with a program (if you all wana help)
    the program should prompt the user to enter a number if the number is even output 0 and 1 if it is even

    i have this so far:

    .begin
    in first
    load first
    here is where i have problems, i don't know how to say, if first is even print 1 for even, if odd print 0

    out first
    jump done
    done: halt
    first: .data 0
    even: .data 1
    odd: .data 0
    .end

    thanx,
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Your course notes should give you an example of how to display a message and receive input.
     
  3. RobertH900

    RobertH900 New Member

    Joined:
    Nov 11, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    my course notes only gives me an example of a program that determines which is larger of to inputs that is prompted to enter

    please if anyone can help, my assignment is past due
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    OK, so basically you can use the same program with the following changes:
    - input 1 number instead of 2
    - test if it's odd or even instead of whether it's larger or smaller than another.
    - change any messages displayed by the program.

    You can test if a number is odd by looking at the least significant bit of the number: if 1 then it's odd, if 0 then it's even.
     
  5. RobertH900

    RobertH900 New Member

    Joined:
    Nov 11, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    thank you for your reply
    , but where would i put the information you provided, i have a big problem with the organization

    if you could give me an example, that would be helpful

    Thank you,
     
  6. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Post the code (using code tags) and I'll show you where to make the changes.
     
  7. RobertH900

    RobertH900 New Member

    Joined:
    Nov 11, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    here is what i have until now, i just want it to print 0 for even numbers and 1 for odd nunmbers


    Code:
    .begin
    in first
    load first
    out first
    jump done
    done: halt
    first: .data 0
    even: .data 1
    odd: .data 0
    .end
     
  8. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Sorry, the code I meant was the one you described as "my course notes only gives me an example of a program that determines which is larger of to inputs that is prompted to enter". Not the code you haven't written yet cos you can't figure it out.
     
  9. RobertH900

    RobertH900 New Member

    Joined:
    Nov 11, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    the assignment has already been late so i submited anything to recieve a grade

    thank you for your help :)
     

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