Assembler Developer

Moderators: None (Apply to moderate this forum)
Number of threads: 970
Number of posts: 1762

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
MARIE Code Posted by I9eleven on 2 Oct 2007 at 1:30 PM
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?
Report
Re: MARIE Code Posted by BitByBit_Thor on 2 Oct 2007 at 2:48 PM
: 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:
mov [Sum], 55


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
Report
Re: MARIE Code Posted by IDK on 3 Oct 2007 at 5:10 AM
: 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:
   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


I really HATE code with accumulators.

Have fun.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.