Using sin and rand functions
Using sin and rand functions
Hi,
i have a probably very easy starter question, but i just can't figure it out on my own.
I have installed the ps2 dev environment and have writen some code, that runs fine on the ps2 emulator (haven't gotten it to run on my ps2 for now) but now i want to use some functions such as sin and rand but including math.h and stdlib.h doesn't work. Do i have to install newlib or use the compiler flag -lm -lc etc?
Because that doen't seem to work. I just used the code from the "Dreamtime's PS2DEV Tutorial #1" and had hoped i could just use rand() etc.
If someone could help me out i really appreciate it.
tnx,
Siebe
i have a probably very easy starter question, but i just can't figure it out on my own.
I have installed the ps2 dev environment and have writen some code, that runs fine on the ps2 emulator (haven't gotten it to run on my ps2 for now) but now i want to use some functions such as sin and rand but including math.h and stdlib.h doesn't work. Do i have to install newlib or use the compiler flag -lm -lc etc?
Because that doen't seem to work. I just used the code from the "Dreamtime's PS2DEV Tutorial #1" and had hoped i could just use rand() etc.
If someone could help me out i really appreciate it.
tnx,
Siebe
instead of rand() you could use the "mersenne twister"
its faster (4 times faster than the standard rand()),
and you get better "random" values (longer period) than with the standart function (read in the link above).
its faster (4 times faster than the standard rand()),
and you get better "random" values (longer period) than with the standart function (read in the link above).
Thanks for the help.
i actually am using another random function somewhat like mersenne twister, but i need a first really random number or else every time i run the program al randoms are the same for every run. So i want 1x rand() and then 8000x the other random().
I got the sinf() working with newlib and the -lm -lc linker commands but now when i use rand() i get the following:
c:/ps2dev/newlib/lib/libc.a(rand.o): In function `rand':
/home/Nickvv/source/ps2-build/newlib-build/mips64r5900-ps2-elf/newlib/libc/stdli
b/../../../../../../ps2/newlib-1.10.0/newlib/libc/stdlib/rand.c:84: undefined re
ference to `__muldi3'
Does anybody know how to fix this or what i am doing wrong?
Thanks,
Siebe
i actually am using another random function somewhat like mersenne twister, but i need a first really random number or else every time i run the program al randoms are the same for every run. So i want 1x rand() and then 8000x the other random().
I got the sinf() working with newlib and the -lm -lc linker commands but now when i use rand() i get the following:
c:/ps2dev/newlib/lib/libc.a(rand.o): In function `rand':
/home/Nickvv/source/ps2-build/newlib-build/mips64r5900-ps2-elf/newlib/libc/stdli
b/../../../../../../ps2/newlib-1.10.0/newlib/libc/stdlib/rand.c:84: undefined re
ference to `__muldi3'
Does anybody know how to fix this or what i am doing wrong?
Thanks,
Siebe
-
- Posts: 564
- Joined: Sat Jan 17, 2004 10:22 am
- Location: Sweden
- Contact:
Hey, that worked, amazing:
mrbrown, you the man! :)
I have got one other small question.
I tested the code i wrote on the ps2 emulator only (i don't have my ps2 at hand all the time :( ) and it worked just fine on it. But when i tried to upload it with InLink using Pukklink on my ps2 it gave the following error:
Exception handler: Address store exception
\par
\par Cause 60008014 BadVAddr 003f46d4 Status 70030c13 EPC 002040b4
\par
\par zero: 00000000000000000000000000000000 t8: 00000000000000000000000000000000
\par at: 00000000000000000000000000000001 t9: 00000000000000000000000000000000
\par v0: 00000000000000000000000000204740 s0: 00000000000000000000000000000000
\par v1: 00000000000000000000000000000190 s1: 00000000000000000000000000000000
\par a0: 00000000000000000000000000000000 s2: 00000000000000000000000000000000
\par a1: 00000000000000000000000000204744 s3: 00000000000000000000000000000000
\par a2: 0000000000000000FFFFFFFF80017B88 s4: 00000000000000000000000000000000
\par a3: 00000000000000000000000000000000 s5: 00000000000000000000000000000000
\par t0: 00000000000000000000000000001000 s6: 00000000000000000000000000000000
\par t1: 00000000000000000000000000000000 s7: 00000000000000000000000000000000
\par t2: 00000000000000000000000000000000 k0: 00000000000000000000000000000000
\par t3: 00000000000000000000000000000000 k1: 00000020810200040000000000000000
\par t4: 00000000000000000000000000000000 gp: 0000000000000000000000000020C6F0
\par t5: 00000000000000000000000000000000 sp: 000000000000000000000000003F46A4
\par t6: 00000000000000000000000000000000 fp: 000000000000000000000000000D6B60
\par t7: 00000000000000000000000000000000 ra: 0000000000000000000000000020425C
I havent got a clue as to what i did wrong. Must be some programming error, but what? Or should i change some stuff to make it work with pukklink etc?
mrbrown, you the man! :)
I have got one other small question.
I tested the code i wrote on the ps2 emulator only (i don't have my ps2 at hand all the time :( ) and it worked just fine on it. But when i tried to upload it with InLink using Pukklink on my ps2 it gave the following error:
Exception handler: Address store exception
\par
\par Cause 60008014 BadVAddr 003f46d4 Status 70030c13 EPC 002040b4
\par
\par zero: 00000000000000000000000000000000 t8: 00000000000000000000000000000000
\par at: 00000000000000000000000000000001 t9: 00000000000000000000000000000000
\par v0: 00000000000000000000000000204740 s0: 00000000000000000000000000000000
\par v1: 00000000000000000000000000000190 s1: 00000000000000000000000000000000
\par a0: 00000000000000000000000000000000 s2: 00000000000000000000000000000000
\par a1: 00000000000000000000000000204744 s3: 00000000000000000000000000000000
\par a2: 0000000000000000FFFFFFFF80017B88 s4: 00000000000000000000000000000000
\par a3: 00000000000000000000000000000000 s5: 00000000000000000000000000000000
\par t0: 00000000000000000000000000001000 s6: 00000000000000000000000000000000
\par t1: 00000000000000000000000000000000 s7: 00000000000000000000000000000000
\par t2: 00000000000000000000000000000000 k0: 00000000000000000000000000000000
\par t3: 00000000000000000000000000000000 k1: 00000020810200040000000000000000
\par t4: 00000000000000000000000000000000 gp: 0000000000000000000000000020C6F0
\par t5: 00000000000000000000000000000000 sp: 000000000000000000000000003F46A4
\par t6: 00000000000000000000000000000000 fp: 000000000000000000000000000D6B60
\par t7: 00000000000000000000000000000000 ra: 0000000000000000000000000020425C
I havent got a clue as to what i did wrong. Must be some programming error, but what? Or should i change some stuff to make it work with pukklink etc?
Those types of errors usually occur from trying to write to memory that either doesn't exist (i.e. just past end of RAM) or you don't have permission to write to (i.e. kernel memory)
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
One of the best methods of tracking down bugs is to get someone else to look at your code. Try to track down where your program breaks by sprinkling printf() around to get a basic trace of your program's execution. Once you pinpoint the line (or lines) that are broken, respond in this thread with the code or post it somewhere.
If the line(s) refer to other variables or functions then you should post those too.
Other than that, we can't help you if we don't know what's wrong :P.
If the line(s) refer to other variables or functions then you should post those too.
Other than that, we can't help you if we don't know what's wrong :P.
This is OT, but that reminded me of a problem I've run into...mrbrown wrote:Try to track down where your program breaks by sprinkling printf() around to get a basic trace of your program's execution.
Since ps2link apparently uses UDP to send its prints to the host, I've run into some issues where print statements come out in the wrong order (and some packets are disappearing entirely). That's an additional challenge...
Has anyone else run into the same thing? I probably don't have the latest of anything (ps2lib, ps2link, pksh, etc.) so maybe it's already been addressed.
-
- Posts: 564
- Joined: Sat Jan 17, 2004 10:22 am
- Location: Sweden
- Contact:
Using printf() is a good idea. They will show up in the InLink log window i presume. I was going to commend out code until it started working, but i will try the printf() first.
Unfortunally I am stuck to the emulator for a few days before i can test it on a real ps2. But when i narrowed it down but can't solve it (i hope i can offcourse) i will post it up here.
I tried to remove/avoid all use of doubles, i hope this helps (?)
And thanks again for all the help :)
Unfortunally I am stuck to the emulator for a few days before i can test it on a real ps2. But when i narrowed it down but can't solve it (i hope i can offcourse) i will post it up here.
I tried to remove/avoid all use of doubles, i hope this helps (?)
And thanks again for all the help :)