MARIE Code

Sum:= 0;
for X := 1 to 10 do
Sum:= Sum + X;

I am trying to write this code in MARIE but i have no idea where to start. Can someone walk me through this process step by step?

Comments

  • : Sum:= 0;
    : for X := 1 to 10 do
    : Sum:= Sum + X;
    :
    : I am trying to write this code in MARIE but i have no idea where to
    : start. Can someone walk me through this process step by step?
    :

    I don't exactly know MARIE, but:
    [code]
    mov [Sum], 55
    [/code]

    But I guess that's too lame :P

    Anyway, the first line should be easy. For the second you need to know how to create a basic loop structure.
    In this case, you could also use a "10 downto 1" loop, which is more 1:1 with x86 assembly code (and so probably also MARIE).
    Then, what happens in the loop is simple ADDition.

    Good luck

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • : Sum:= 0;
    : for X := 1 to 10 do
    : Sum:= Sum + X;
    :
    : I am trying to write this code in MARIE but i have no idea where to
    : start. Can someone walk me through this process step by step?
    :

    A quick google search gave me some code, and I started hacking and ended up with this:
    [code]
    LOAD X
    L, SUB Z //decrease loop counter
    STORE X
    LOAD Y
    ADD X
    STORE Y
    LOAD X
    SKIPCOND 400 //if AC == 0 don't jump
    JUMP L
    X,11
    Y,0
    Z,1
    [/code]

    I really HATE code with accumulators.

    Have fun.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories