>This brings to mind the relative speed increase of register variables. >Does anyone know how much faster it would be to have a variable in >a register than on the stack? >M >> >You can't put function parameters in registers because they are >> >passed on the stack. In 68K, all parameters are indeed passed on the stack. But in PPC, registers are used to pass up to 8 parameters of the right kind (integer, long, pointer, and so on). If you have register on, they stay in registers. If register is off, they get transferred from the registers to become, in effect, local variables on the stack. Sometimes it's desirable to force this explicitly, for example if you want your true local vars to be register but the parameters use up all available registers: register off local fn Test(a, b, c, d, e, f, g, h) // parameters becomes RAM vars register on dim j as long, k as long.... // up to 8 register vars .... The reason for using this technique is that parameters are most often "read-only" variables. There's not much speed advantage in having them in registers, because they are loaded extremely quickly from the PPC cache. You get a more significant speedup by putting "variable value" variables into registers, and these are (usually) your FN's local vars. Derek explained that such "variable" variables get both read and written: hence the advantage of registers. BrianHughes@... wrote: >Maybe this is too simplistic to work or maybe I'm doing something >wrong but the code below showed almost no difference. < code example snipped > All the variables in your code example are globals, and hence cannot be register. See below for a working demo, or put END GLOBALS at the top of your code. (In the demo below, END GLOBALS doesn't affect the timing, because that's based entirely on FN vars and parameters). Robert P. end globals register off local fn LoopsNoRegister(n as long) dim j as long, x as long for j = 1 to n: inc(x): dec(x): inc(x): dec(x): next end fn register on local fn LoopsRegister(n as long) dim j as long, x as long for j = 1 to n: inc(x): dec(x): inc(x): dec(x): next end fn _nLoop = 5000000 print "loops " _nLoop dim ticks as long ticks = fn tickcount: fn LoopsNoRegister(_nLoop) ticks = fn tickcount - ticks print "No register "ticks " ticks" ticks = fn tickcount: fn LoopsRegister(_nLoop) ticks = fn tickcount - ticks print "Register "ticks " ticks"