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
: 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]
[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]
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]
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?"