[c-prog] Re: memory access questions

2008-07-08 Thread teletep
Thank you Jhon, I found a very good description about the inline assembly for PPC from Metrowerk's CodeWarrior. Apple's xcode accepts the syntax. It's a real break-out of the restrictions of c. It allows me to access all memory without alignment problems. I even can access the code, implement

Re: [c-prog] Re: memory access questions

2008-07-08 Thread John Gaughan
teletep wrote: I found a very good description about the inline assembly for PPC from Metrowerk's CodeWarrior. Apple's xcode accepts the syntax. It's a real break-out of the restrictions of c. It allows me to access all memory without alignment problems. I even can access the code,

[c-prog] Re: memory access questions

2008-07-05 Thread teletep
Thank you Paul, answer to Q5: To store the address of a label into cell n of array r: void *labelptr=labelname; r[n]=labelptr; To jump to the label: goto *labelptr; This works with GNU-C compiler 3.3 but not with MetroWorks. I think i need to use inline asm to solve the remaining questions. I

[c-prog] Re: memory access questions

2008-07-03 Thread teletep
Hi all, This is a review of my topic: memory access. Given: long int r[100],m,n,o,v; // array and workvariables char b[4];short int w[1];long int l[1]; // dummy arrays b w l int ba=(int)b,wa= (int)w,la= (int)l; // array base addresses RUN-TIME issues: Each 4-byte cell of array r can contain

[c-prog] Re: memory access questions

2008-07-03 Thread teletep
--- In c-prog@yahoogroups.com, Paul Herring [EMAIL PROTECTED] wrote: On Tue, Jul 1, 2008 at 8:05 PM, teletep [EMAIL PROTECTED] wrote: for 1-byte access: index = memoryaddress - array-base for 2-byte access: index = (memoryaddress - array-base)/2 for 4-byte access: index = (memoryaddress

Re: [c-prog] Re: memory access questions

2008-07-03 Thread Paul Herring
On Thu, Jul 3, 2008 at 12:28 PM, teletep [EMAIL PROTECTED] wrote: --- In c-prog@yahoogroups.com, Paul Herring [EMAIL PROTECTED] wrote: On Tue, Jul 1, 2008 at 8:05 PM, teletep [EMAIL PROTECTED] wrote: for 1-byte access: index = memoryaddress - array-base for 2-byte access: index =

Re: [c-prog] Re: memory access questions

2008-07-01 Thread Paul Herring
On Mon, Jun 30, 2008 at 7:18 PM, teletep [EMAIL PROTECTED] wrote: Thank you again Paul, My compiler disregards a cast from int to pointer. int v,f*; f=(int *)v; generates a Type mismatch error. int v, *f; f = v; // or f = (int*)v; // depending on whether you want the address or the value of

[c-prog] Re: memory access questions

2008-06-30 Thread teletep
Thank you Paul. I agree that no solutions can be found using ansi C. I figured out Q4. The answer is: r[n]=(int)r[m]; For Q5, my compiler refuses xxx where xxx is the name of a label. I need some time to figure out Q6. The first problem to solve the other questions concerns pointer assignment.

[c-prog] Re: memory access questions

2008-06-30 Thread teletep
Thank you again Paul, My compiler disregards a cast from int to pointer. int v,f*; f=(int *)v; generates a Type mismatch error. Note: The questions are mine. Your answers will save me time. --- In c-prog@yahoogroups.com, Paul Herring [EMAIL PROTECTED] wrote: On Mon, Jun 30, 2008 at 3:36 PM,