If I was to use a hi-speed link connecting the CPU to a RAM chip and I was to write my program in C and use the compiler to convert the C into assembler to run on the CPU how would I address the memory on the RAM chip? Would it be automatically assigned? Can I even use the RAM chip if I write a program in C?
I am thinking in terms of making a very large 3 dimensional array in C and I am wondering how it would get stored onto the RAM chips and if there is any nice method that it does so, so that I can use regular chips to use values from this same RAM as well.[/b]
Yes, thats possible. Here is the code (example for my_array with 3 sizes), it should work:
Code:
#asm
**define _my_array,65536; //my_array is your name (with _ in front cuz its C), 65536 is where it starts
**define _size_x,64; //X size
**define _size_y,64; //Y size
**define _size_z,64; //Z size
#endasm
read_3d(x,y,z) int x,y,z; {
**return *(my_array + z*size_x*size_y + y*size_x + x);
}
write_3d(x,y,z,value) int x,y,z,value; {
***(my_array + z*size_x*size_y + y*size_x + x) = value;
}
main() {
**int i;
**write_3d(1,2,3,4);
**i = read_3d(1,2,3);
} Ignore "external reference" messages, it should compile correctly.
Bookmarks