Qbasicnews.com

Full Version: memory question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Got a question to pose to the QB gurus on here :

Can you access ANY location in physical memory in QB?

I know DEF SEG exists but is that just for within the segment of QB/your program once its compiled?

If any of you guys could whip up a quick program that will illustrate accessing any user specified memory location and echoing its contents you would rock. Smile

thanks
Code:
DIM A AS LONG
SCREEN 13
DEF SEG = &HA000
FOR A = 0 TO 63999
  POKE A, INT(RND(1)*256)
NEXT A
Nevermind, my real question was whether or not DEF SEG could address any location in your physical memory or if it just set a point inside the code segment of the process that was running. I just tested it with this to see if it would or not.

(I know its not pretty. :wink: )
Code:
OPEN "output.dat" FOR OUTPUT AS #1
FOR M = 0 TO 5
DEF SEG = (M * 1000)
FOR N = 0 TO 1000
PRINT #1, M, N, PEEK(N), CHR$(PEEK(N))
NEXT N
NEXT M
CLOSE

Going to use it to write a utility to search memory for a string, and just wanted to know if DEF SEG had any limits to the range it can address.
Although this is pretty cool to do in qb, if you're interested in it you really should try out something else, such as c or asm. Don't worry, you won't be considered a traitor :bounce:
You can only access the first 640 Kb in that way, and all that inside the protected, uncrossable walls of your DOS box.
Stupid dos....can freebasic access the whole physical memory?


Yeah I already knew how to do it in C though, wanted the style points for using QB. :rotfl:
In windows, memory is protected.
But you will have access to about half of the running processes virtual memory, the other half is reserved for the operating system, but its still ~2GB to play with.
Oh well, that is, reading Smile