MARIE Language????

Discussion in 'Homework Help' started by JoGo, Nov 17, 2009.

  1. JoGo

    Thread Starter New Member

    Nov 17, 2009
    2
    0
    How would I write this correctly in MARIE???


    Input a number

    If number >10 then
    number = number -5
    Else
    number = number + 3
    Endif

    This what I got please fix it....Thank You in Advance!!!

    Org 100
    Input
    Store X
    Skipcond 800
    Jump Else
    Store Y
    Subt Five
    Jump Endif
    Else, Load X
    Add Three
    Endif, Halt
    X, Dec 0
    Y, Dec 0
    Five, Dec 5
    Three, Dec 3
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Marie is apparently a teaching language in computer science. There does not seem to be any material available without the textbook.
     
  3. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,348
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    OK, here is your source code, re-formatted, with comments.

    Code ( (Unknown Language)):
    1.          Org 100    // Starting address
    2.          Input      // Load a number into AC
    3.          Store X    // Store the AC into X
    4.          Skipcond 800   // If AC > 0, skip next step
    5.          Jump Else  // AC was < 1; branch to Else
    6.          Store Y    // Store > 0 value in Y
    7.          Subt Five  // Subtract five from the AC
    8.          Jump Endif // Exit program
    9. Else,    Load X     // Load X into the AC
    10.          Add Three  // Add three to the AC
    11. Endif,   Halt       // End of run.
    12. X,       Dec 0
    13. Y,       Dec 0
    14. Five,    Dec 5
    15. Three,   Dec 3
    16.  
    Does that make the problem easier for you to solve?
    Hint:
    You are missing an important step right after you store the accumulator into X.
    What did you forget to do?
     
    Last edited: Nov 18, 2009
Loading...