You are not logged in.
Pages: 1
As a challenge, I decided to try making a simple CPU emulator. When I try to execute the program, I get segmentation faults.
What exactly is a segmentation fault? How do I get rid of it?
#include <stdio.h>
main()
{
int ram[0xffff];
int pcounter;
int somevalue = 5;
ram[0x1024] = 0xff;
somevalue = ram[pcounter];
switch (somevalue) {
case 5:
printf("Hello, World!");
break;
default:
break;
}
return 0;
}
Personally, I'd rather be back in Hobbiton.
Offline
Nvm, I figured it out. I'm such a noob.
Personally, I'd rather be back in Hobbiton.
Offline
What exactly is a segmentation fault?
This may help better your understanding: http://en.wikipedia.org/wiki/Segmentation_fault
Offline
Commenting on a non-issue here, but I guess my curiosity got the best of me;
Why 0x1024? 1024 is a power of two and would make some kind of sense in that everything boils down to binary, so powers of two are nice.
But in hex 1024 is 0x0400...
I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.
Offline
Commenting on a non-issue here, but I guess my curiosity got the best of me;
Why 0x1024? 1024 is a power of two and would make some kind of sense in that everything boils down to binary, so powers of two are nice.
But in hex 1024 is 0x0400...
You're completely right, OP should take note
That's probably the only reason he used 1024.
Offline
Pages: 1