MARIE assembly language

Discussion in 'Programmer's Corner' started by m8763, Feb 5, 2009.

  1. m8763

    Thread Starter New Member

    Dec 2, 2008
    How can I write this code segment in MARIE?

    if x>1 then
    y= x+x;
  2. m8763

    Thread Starter New Member

    Dec 2, 2008
    The following is what I came up with as an answer.

    Load x
    Subt one
    Skipcond 800
    Jump Next
    Load x
    Add x
    Store y

    Store x

    Load y
    Add one
    Store y

    Next, Halt
    x, dec 20
    y, dec 10
    one, dec 1

    Can anyone correct my mistakes, if any, please?
  3. beenthere

    Retired Moderator

    Apr 20, 2004
    In my very limited knowledge of assemblers, MARIE is absolutely new. My experience with assembly language is that you have to be fully conversant with the processor and its instruction set in order to write code. The assembler imposes constraints as to syntax acceptable to itself, but has very little to do with the actual functioning of the code.

    Your directives would never get parsed correctly by any assembler I have used, but I don't have any knowledge of MARIE. It is otherwise conventional to begin with an ORG statement to tell the assembler where the code block is to start. One follows with directives that EQUate labels to fixed addresses, and so on.
    Last edited: Feb 5, 2009
  4. atferrari

    AAC Fanatic!

    Jan 6, 2004
    Is it MARIE currently in use? What micros?

    Hi BT,

    The OP seems to be asking about syntax only, isn't it?
    Last edited: Feb 7, 2009
  5. m8763

    Thread Starter New Member

    Dec 2, 2008
    This is the best solution with comments:

    If, Load X / Load X
    Subt One / Subtract 1, store result in AC
    Skipcond 800 / If AC>0 (X>1), skip the next instruction
    Jump Endif / Jump to Endif if X is not greater than 1
    Then, Load X / Reload X so it can be doubled
    Add X / Double X
    Store Y / Y= X + X
    Load Zero / Move 0 into AC
    Store X / Set X to 0
    Endif, Load Y / Load Y into AC
    Add One / Add 1 to Y
    Store Y / Y = Y + 1
    Halt / Terminate program
    X, Dec ? / X has starting value, not given in problem
    Y, Dec ? / Y has starting value, not given in problem
    One, Dec 1 / Use as a constant
    Zero, Dec 0 / Use as a constant
  6. RiJoRI

    Well-Known Member

    Aug 15, 2007
    Found on Giggle:
    Training wheels?

    And for the OP, look up MarieSim, and put your code through that.

  7. russ_hensel

    Well-Known Member

    Jan 11, 2009