Spectrum
08-17-07, 07:52 AM
I'm having problems using peek in QBasic. When I peek address(&H0) I get the ascii letter 'p' and when I peek address(&H1) I get the letter 't'. Shouldn't the program itself be loaded into memory so I get 'C', 'L' and 'S'? Any help would be appreciated.
leopold99
08-17-07, 08:06 AM
this depends entirely upon what machine you are using.
do you get any errors? if so what exactly is it?
Cyperium
08-17-07, 02:37 PM
I'm having problems using peek in QBasic. When I peek address(&H0) I get the ascii letter 'p' and when I peek address(&H1) I get the letter 't'. Shouldn't the program itself be loaded into memory so I get 'C', 'L' and 'S'? Any help would be appreciated.No, the memory peeked into is the DOS memory, not only QBASIC, but the entire DOS environment, the memory is divided into 64k segments, so you should DEF SEG into the right segment (for example DEF SEG = &HA0 or whatever...), the program QBASIC is itself loaded into the memory, I have made a memory seeker that enabled me to do funny stuff to the QBASIC environment, it is fun!
Also, if you do things wrong you could hang your computer or DOS...
To get the segment and address of a variable you do VARSEG(variable) for segment and VARPTR(variable) for address pointer, you can POKE to that address to change the variable if you want, this is useful in libraries (DirectQB and such).
When I had Commodore 64 I used to experiment with addresses, it was very fun, one time I made the cursor move at light speed! This was normally not possible in C64 I think.
Remember though, in QBasic you deal with the entire DOS memory so it might be dangerous to experiment. POKEing things to VGA memory can make you do different screen modes than the ones originally in QB, ModeX for example.
I don't know the segment and address where QBasic stores the program you have written. I would love to change the program while it is running.
I know that the default segment is the QBasic segment, but I don't think that the program you have written is stored there...or it is encrypted in some way...
leopold99
08-17-07, 06:56 PM
Also, if you do things wrong you could hang your computer or DOS...
PEEK reads a memory location. it's POKE you must be concerned about.
if you don't know what you are doing you could easily hang your machine with POKE.
kevinalm
08-18-07, 12:55 AM
Most of my peek and poke experience was on an apple II+ , so it may be different for pc architecture, but iirc peek can blow up in your face as well. Sometimes hardware designers used to switch stuff just by accessing a memory location, whether you wrote to it was immaterial. Hopefully that's no longer the case, but I would still be cautious with peek as well.
leopold99
08-18-07, 02:31 AM
all peek does is read a memory location.
Spectrum
08-20-07, 08:31 AM
I'm after the memory addresses where QBasic is stored in memory.