I am very new to using Marie simulator, and if anyone could help, it would be great.
the following program:
ORG 200
If, Load X
Subt Y
Skipcond 400
Jump Else
Then, Load Y
Store X
Jump Endif
Else, Load Y
add X
Store Y
Endif, Output
Halt
Two, Dec 2
X, Dec 10
Y, Dec 10
END
From this code, what does this particular part mean? And how do I input a new value to Y? Also, what does first load instruction mean?
Two, Dec 2
X, Dec 10
Y, Dec 10
I am trying to figure this MarieSim out, I would really appreciate it if anyone could help out. thank u.
Related
ORG 100 /Start Here
INPUT
Store X /Store 1st input value in X
INPUT
Store Y / Store 2nd input value in Y
choice, INPUT
Store C /Store choice in C
if, Load C
Subt A
Skipcond 400
Jump elseif1
JnS ADDITION /Call subroutine
Jump end
elseif1, Load C
Subt S
Skipcond 400
Jump elseif2
JnS SUBTRACT /Call subroutine
Jump end
elseif2, Load C
Subt M
Skipcond 400
Jump elseif3
JnS MULTIPLY /Call subroutine
Jump end
elseif3, Load C
Subt D
Skipcond 400
Jump elseif4
JnS DIVISION /Call subroutine
Jump end
elseif4, Load C
Subt Q
Skipcond 400
Jump choice /re-enter choice
Halt /stop the program
end, Output /Display the value
Halt /Stop
X, DEC 0
Y, DEC 0
C, DEC 0
/add two numbers
ADDITION Load X
Add Y
JumpI ADDITION / Indirect jump to return.
/subtract two numbers
SUBTRACT Load X
Subt Y
JumpI SUBTRACT / Indirect jump to return.
/multiply two numbers using continuous add loop
MULTIPLY loop, Load num
Add X
Store num
Load Y
Subt one
Store Y
Skipcond 400
Jump loop
Load num
JumpI MULTIPLY / Indirect jump to return.
/divide two numbers and return the quotient
DIVIDE If, Load X
Subt Y
Skipcond 800
Jump EndIf
Store X
Load quo
Add one
Store quo
Jump If
EndIf, Load quo
JumpI DIVIDE / Indirect jump to return.
/constants values
one, DEC 1
num, DEC 0
rem, DEC 0
quo, DEC 0
A, DEC 97 /a
M, DEC 109 /m
S, DEC 115 /s
D, DEC 100 /d
Q, DEC 113 /q
This is a calculator that is supposed to add, subtract, multiply, and divide. Once the user is done with an operand it is supposed to directly go to the next one as well, but it is giving me errors and I can't seem to fix them. Everything looks fine to me but it keeps saying "Operand undefined." I'm sure this is an obvious error to others but I can't seem to fix it. Was hoping someone can help me with this! Thanks!
I need to write a code for raising x to the power of y in Marie.js. That's what I have for now, however it spits out an error SyntaxError:L41 - Unknown label Loop.
Input
Subt One
Store Count
Input
Store x
Store y
Jns Exp
Load Wyn
Output
End, Halt
Exp, Hex 0
Loop2, Load Count
Skipcond 800
JumpI Exp
JnS Multi
Load Wyn
Store x
Load Count
Subt One
Store Count
Jump Loop2
Multi, Hex 0
Load Zero
Store Wyn
Loop, Load x
Skipcond 800
JumpI Multi
Load Wyn
Add y
Store Wyn
Load x
Subt One
Store x
Jump Loop
x, Dec 2
y, Dec 3
Zero, Dec 0
One, Dec 1
Wyn, Dec 0
Count, Dec 0
I understand the necessity for 2 loops, which execute y-1 times, however Im completely clueless what I'm doing wrong.
You have to define a label before you can Jump to it; you have not defined the label Loop. You have defined a label named Loop2.
The question asks us to solve for x in the given equation c' = x^e mod N, given the fact that we already know c', e , mod N. I looked into my tutorial, bu they only gave us a way to get e, but not for x.
I have manually tried to solve it and got the equation:
log c' = e log x mod N
but I don't know how to put in in Sage Math.
This is from the tutorial to find e:
discrete_log (c',Mod(x,N))
The question is really asking how to find an e-th root of c' modulo N.
Say for example one wants to solve 12 = x^99 modulo 347.
This amounts to finding a 99-th root of 12 modulo 347.
Just set up the ring of integers modulo 347,
sage: A = Zmod(347)
sage: A
Ring of integers modulo 347
give a name to the element 12 in that ring,
sage: a = A(12)
and ask Sage for a 99-th root of this element:
sage: a.nth_root(99)
241
Check that this answers the question:
sage: A(241)^99
12
sage: pow(241, 99, 347)
12
sage: power_mod(241, 99, 347)
12
Samuel's answer is far more comprehensive than this, but if you are looking for a really quick fix, you could use this (naive) function for small moduli:
sage: solve_mod(x^99==12, 347)
[(241,)]
multiplication of two numbers 6 and 3 by, repeatedly addition of 3 six times,using a loop that will add 3 six times and store the result into accumulator.
INPUT
STORE x
INPUT
STORE y
loop, LOAD x
ADD multiply
STORE multiply
LOAD y
SUBT one
STORE y
SKIPCOND 400
JUMP loop
LOAD multiply
OUTPUT
HALT
x, Dec 0
y, Dec 0
one, Dec 1
multiply, Dec 0
I'm trying to gnuplot a data set like this
Di 4. Dez 19:10:09 CET 2012
Garbage
description: 10.5 description2: 22.3
Mi 5. Dez 01:51:15 CET 2012
Garbage
description: 10.5 description2: 22.4
Those 3-line-blocks repeat several times. I want to use the time from line 1,4,7 etc. to provide the date (as X-value) for the actual data in lines 3,6,9 etc. (as Y-values) every other column. In the end the plot should be composed by the following lines (in [X,Y]-format) [1,3],[1,6],[1,9],[4,3],[4,6],[4,9] etc.
From what I read here it's possible to use every but I can't figure out how.
EDIT: I solved the timefmt issue below thanks to user1901493's tip. Disregard the issue below (didn't delete it there for reference).
A test with just the first line with set timefmt "%d %b %H:%M:%S" and using 2:6 doesn't work either, complaining about a bad month abbreviation. This should work though. This could be part of the problem though.
The bad month abbreviation might come from the fact that gnuplot does not understand the german Dez. abbreviation, so try again with dec instead of Dez.
Secondly, I think gnuplot only uses data in columns, so a file with your format:
x1
...
y1 z1
x2
...
y2 z2
might not work at all. I suggest that you rearrange your data file with something like grep so that your datafile looks like this:
x1 y1 z1
x2 y2 z2