hi gents
i can't start to resolve this progarm it's so deficult ...
....Write program can be used to generate (n) random number (0<= x <1).
Show a sample output for 10 numbers????
:crying:
51 replies to this topic
#1
Posted 24 April 2011 - 12:03 AM
|
|
|
#2
Posted 24 April 2011 - 12:26 AM
We'll help with homework, but we won't do it for you. What do you have so far? What libraries are you allowed to use, if any.
sudo rm -rf /
#3
Posted 24 April 2011 - 12:54 AM
I appreciate that...
But I do not know how to be like or what is steps to reach to the result....
I want more explanation. Because I very beginning in this program
But I do not know how to be like or what is steps to reach to the result....
I want more explanation. Because I very beginning in this program
Edited by Ebda3, 24 April 2011 - 11:41 AM.
#4
Posted 24 April 2011 - 01:23 PM
So the question is "write a program that outputs a random number; the number must be greater than or equal to zero, but must be less than one."; is that right?
Maybe if you find some random number, you could divide that number by the [maximum number possible divided by 1].
There's this link I found about random numbers:
HowStuffWorks "How can a totally logical computer generate a random number?"
Maybe if you find some random number, you could divide that number by the [maximum number possible divided by 1].
There's this link I found about random numbers:
HowStuffWorks "How can a totally logical computer generate a random number?"
#5
Posted 25 April 2011 - 03:18 AM
here is a formula to generate random number but how i can write this prog in mips

i need more explain

i need more explain
#6
Posted 25 April 2011 - 09:17 AM
Split the formula up into distinct operations, like this:
Z = A * (B + C)
From there you should be able to translate it directly into machine language.
EDIT: Are you sure it's Xi + 1 and not X[i+1] like the G in the second line?
Z = A * (B + C)
R0 := A R1 := B R1 += C R0 *= R1 Z := R0
From there you should be able to translate it directly into machine language.
EDIT: Are you sure it's Xi + 1 and not X[i+1] like the G in the second line?
sudo rm -rf /
#7
Posted 26 April 2011 - 12:39 AM
R0 := A
R1 := B
R1 += C
R0 *= R1
Z := R0
:confused:
what do u mean about these??
R0:=A
B??
Z := R0
R1 := B
R1 += C
R0 *= R1
Z := R0
:confused:
what do u mean about these??
R0:=A
B??
Z := R0
#8
Posted 26 April 2011 - 12:50 AM
Z = A * (B + C) consists of several operations, namely an addition, a multiplication, and a store. This is entirely conceptual, so I'm just making up register names R0, R1, etc. To translate this to MIPS assembly language...
We first load A, B, and C into registers:
R0 := A
R1 := B
R2 := C
Now we add B + C
R3 := R1 + R2
Multiply A by B + C
R4 := R0 * R3
Store the result into Z
Z := R4.
So our program now looks like:
Z = A * (B + C)
Translating this into equivalent instructions in MIPS:
See how each line in my intermediate code corresponded exactly to one MIPS instruction? You need to do the same with your program. Write a high-level version of what you need to do (pseudocode works) and post it here.
Does this make sense? All you need to do is write the program in a high-level way that makes sense to you, then translate that into something like what I showed above, then from here to MIPS.
We first load A, B, and C into registers:
R0 := A
R1 := B
R2 := C
Now we add B + C
R3 := R1 + R2
Multiply A by B + C
R4 := R0 * R3
Store the result into Z
Z := R4.
So our program now looks like:
Z = A * (B + C)
R0 := A R1 := B R2 := C R3 := R1 + R2 R4 := R0 * R3 Z := R4
Translating this into equivalent instructions in MIPS:
lw $t0, A lw $t1, B lw $t2, C addu $t3, $t1, $t2 mul $t4, $t3, $t0 sw $t4, Z
See how each line in my intermediate code corresponded exactly to one MIPS instruction? You need to do the same with your program. Write a high-level version of what you need to do (pseudocode works) and post it here.
Does this make sense? All you need to do is write the program in a high-level way that makes sense to you, then translate that into something like what I showed above, then from here to MIPS.
sudo rm -rf /
#9
Posted 26 April 2011 - 02:38 AM
Quote
lw $t0, A
lw $t1, B
lw $t2, C
addu $t3, $t1, $t2
mul $t4, $t3, $t0
sw $t4, Z
lw $t1, B
lw $t2, C
addu $t3, $t1, $t2
mul $t4, $t3, $t0
sw $t4, Z
is there wrong when i load A to $t0??

and aslo what about a seed in syscall(40) when i can use it
and random number(42) in syscall ??
:confused:
#10
Posted 26 April 2011 - 09:32 AM
My post was an example. I didn't do any part of your assignment for you. As for your second question, I'm not entirely sure what you mean by "when can I use it."
sudo rm -rf /
#11
Posted 27 April 2011 - 12:09 AM
Dear dargueta i never told u to do my assignment...
so the question is can the program store letter(A or B) in register as ur wrote ??
if ur answer is yes so how i can enter the values inside these letters ??
and y the program told there is a wrong ??
do u get why i'm so confused now ?
:confused: FYI i'm so beginner so I hope that u didn't angry from my stupid qeustion.
:)
Quote
lw $t0, A
if ur answer is yes so how i can enter the values inside these letters ??
and y the program told there is a wrong ??
do u get why i'm so confused now ?
:confused: FYI i'm so beginner so I hope that u didn't angry from my stupid qeustion.
:)
Edited by dargueta, 02 May 2011 - 10:19 PM.
Fixed formatting
#12
Posted 27 April 2011 - 12:21 AM
You need to declare your variables first in the data section so you can reference them in your code:
# data and variables go in here .data A: .word 200 B: .word 15 C: .word 9 Z: .word 0 # code goes in here .text lw $t0, A lw $t1, B lw $t2, C addu $t3, $t1, $t2 mul $t4, $t3, $t0 sw $t4, Z # SPIM exit li $v0, 10 syscall
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









