Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

MARIE Simulator?

Hello

Well, doing a search turned up nothing to help me because this MARIE simulator is not really mainstream yet i guess! Anyway i'm trying to write a program to multipy two numbers (user input) by repeated addition since MARIE is real basic. I've got my code written but it doesn't give me any output. I was hoping some of you guys could help me out! I'm thinking it might have something to do with my loop but i've looked at it for hours the last couple days and i can NOT figure it out! Any help would or tips would be great! Thanks
[code] [/code]
org 100

input
Store VarA
input
Store VarB


Load VarB

Subt One
Store Ctr




Loop, Load Sum
AddI VarB
Store Sum

Load VarA
Add One
Store VarA

Load Ctr
Subt One
Store Ctr
Skipcond 000

Jump Loop
Halt



Next, Hex 0
VarA, Dec 0
VarB, Dec 0
Sum, Dec 0
Ctr, Hex 0
One, Dec 1
Num, Dec 0

Comments

  • IDKIDK Posts: 1,784Member
    : [code]:
    : org 100
    :
    : input
    : Store VarA
    : input
    : Store VarB
    :
    :
    : Load VarB [red]//is this necesary? isn't acc already VarB?[/red]
    :
    : Subt One
    : Store Ctr
    :
    :
    :
    :
    : Loop, Load Sum
    : AddI VarB
    : Store Sum
    :
    : Load VarA
    : Add One
    : Store VarA
    :
    : Load Ctr
    : Subt One
    : Store Ctr
    : Skipcond 000 [red]//What does this mean?[/red]
    :
    : Jump Loop
    : Halt
    :
    :
    :
    : Next, Hex 0
    : VarA, Dec 0
    : VarB, Dec 0
    : Sum, Dec 0
    : Ctr, Hex 0
    : One, Dec 1
    : Num, Dec 0

    [/code]

    Sorry to tell you, but you failed to use code tags.

    The code goes [b]between[/b] the two tags.

    Also, I don't think there's any MARIE guys here.
    I don't even know what MARIE is...

    Is it a machine? And what's so special about it that you use it?
    It seems to use a very ugly assembler syntax...

    : I've got my code written but it doesn't give me any output.
    That's probably because you don't tell it to output anything, it just halts after the loop.

    Also, I think you have the loop wrong...
    (if I understand your code correctly, which I may not do, because I
    don't know MARIE)
    This is psuedo asm:
    Your code:
    [code]
    Loop:
    sum+=B
    A+=1
    Ctr-=1
    jmp Loop if Ctr>0
    halt
    [/code]

    Proper code:
    [code]
    Loop:
    sum+=A
    B-=1
    jmp Loop if B>0
    print sum
    halt
    [/code]
    Happy coding wishes
    the one and only
    [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]
  • zzthejimzzzzthejimzz Posts: 2Member
    MARIE is a JVM simulator used to simulate a simple computer through basic assembly language instructions. Ok, i finally figured it out!!! Good old fashion trial and error helped out! I'm going to post my solution for anyone else who has problems with it, thanks.
    [code]
    org 100

    input /user input first integer
    Store VarA

    input /user input second value
    Store VarB

    Jns prod
    Load Sum
    Store answer

    Output
    Halt

    prod, Hex 0

    Load VarB
    Store Ctr
    Clear

    Store Sum
    Loop, Load Sum
    Add VarA
    Store Sum
    Load Ctr
    Subt One
    Store Ctr

    Skipcond 400 /If control variable <0 skip next instruction
    Jump Loop / go to loop
    Load Sum
    JumpI prod

    Next, Hex 0
    VarA, Dec 0
    VarB, Dec 0
    Sum, Dec 0
    Ctr, Hex 0
    One, Dec 1
    Num, Dec 0
    answer, Dec 0










    [/code]

  • wasichuwasichu Posts: 1Member
    First: Have you found that MARIE helped you understand x86 assembly programming? Has MARIE been useful as a learning tool?


    Secondly: I created a MARIE program that squares two numbers.

    Let me know if you have a better way to do this (which I'm sure there is--e.g., looking at it again, exponent isn't needed):

    [code]
    Input /Enter the base
    Store Base
    Subt Decr
    Store BaseCtr
    Store BaseReset

    Input /Enter the exponent
    Store Exponent
    Subt Decr
    Store ExpCtr

    PreLoop, Load Base
    Store Result

    AddLoop, Load Result
    Add Base
    Store Result

    Load BaseCtr
    Subt Decr
    Store BaseCtr
    Skipcond 400
    Jump AddLoop
    Jump ExpTally

    ExpTally, Load Result
    Store Base
    Load BaseReset
    Store BaseCtr
    Load ExpCtr
    Subt Decr
    Store ExpCtr
    Skipcond 400
    Jump PreLoop
    Jump Finish

    Finish, Load Result
    Output Result
    Halt



    Base, Dec 0
    BaseCtr, Dec 0
    BaseReset, Dec 0
    Exponent, Dec 0
    ExpCtr, Dec 0
    Decr, Dec 1
    Result, Dec 0[/code]
  • jdlc010jdlc010 Posts: 2Member
    just join!

    me to have a problem with marie simulator.

    does anyone knows "How to output the sum of all integers from 1 to 100 in marie simulator?"
  • dntclmeidoldntclmeidol Posts: 4Member
    can any one help me about marie>?
  • dntclmeidoldntclmeidol Posts: 4Member
    This post has been deleted.
  • MrWrongsAliveMrWrongsAlive Posts: 2Member
    I know this isn't a new post but, I too had to struggle with MARIE, I'm a relatively new programmer so after I got some of it figured out I decided to do the world a solid and create a powerpoint explaining the basics of MARIE. Enjoy
  • MrWrongsAliveMrWrongsAlive Posts: 2Member
    Same as my previous post.
Sign In or Register to comment.