1. more about memory
- Posted by Luis Campos <lcasoft at TELELINE.ES> Jun 09, 2000
- 502 views
mic _ wrote: > Segment/offset-pairs are relics of the 16-bit days (or for those who ar= e > used to MS QB). Euphoria runs in protected mode wich leaves you with a = very > simple linear memory addressing mode. This means that you access memory > using only a 32-bit offset. > > An Example: > > atom mem > > mem =3D allocate(1000) -- allocate 1000 bytes > poke(mem+1,50) -- write to the second byte of the mem-block > print(1,peek(mem+1)) -- ..and then read it > free(mem) > > This _should_ print out "50" on the screen... > > _______________________________________________________________________= _ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.co= m thanks for the example Mic, but imagine I want to read the whole 32MB ram in my computer.I think woul= d be somthing like: sequence data_in_ram for offset =3D 1 to ?????? do --what's the final value ? data_in_ram =3D append(peek( offset), data_in_ram) end for ----- I also want to create a routine to check the amount of free low memory,like the "mem" command under Dos.I think it would be=20 something like this(any suggestions are welcomed): function Free_Mem() atom memory_allocation object bytes_allocated sequence memory_pointers memory_pointers =3D {} bytes_allocated =3D 0 for N =3D 1 to ???? do -- again,wich value I should put=20 -- in here? 640kbytes?,6400000? memory_allocation =3D allocate_low(1)-- 1 byte if atom(memory_allocation) then=20 -- could not allocate the byte else -- succes when allocating poke(memory_allocation,'X') --whatever you want bytes_allocated +=3D 1 -- create list of allocated bytes & their addresses memory_pointers =3D append(memory_allocation,memory_pointers)=20 end if end for -- now I have to deallocate all my bytes. for Offset =3D 1 to length(memory_pointers) do free( memory_pointers[Offset] ) end for return (640.000 - bytes_allocated) -- free mem ??? end function thanx, ------------------------ Luis Campos lcampoar8 at far.ub.edu lcasoft at teleline.es ------------------------