Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QBasic, PEEK and POKE

Status
Not open for further replies.

Nepheligenous

Technical User
Dec 11, 2002
17
I'm interested in finding out how to use PEEK and POKE. I have searched books and the Internet but cannot find anything but cursory mention of them. Is there somewhere I can find a thorough examination of their use?

Thanks
 
peek and poke... hmmm... look for an old book (circa 1978) on Basic at your local used book store... there may be something on the web; but I haven't seen anything for several years... Setnaffa is an MCP-W2K (working on W2K) with a few other certs, too...
 
Thank you very much for your input. I shall have to get into interrupts, inp and out in that case. I'm writing a program in QBasic that is a Help system but that needs to have an editor for creating and editing help files (for the supervisor).
Being self-taught (and not very good), I'm finding it challenging and exciting at the same time ... and my respect for programmers who create word processors is increasing exponentially!

Thank you once again for your guidance.

Vic
 
[tt]PEEK[/tt] and [tt]POKE[/tt] are for accessing memory directly. On very old systems, like the VIC20, TRS-80, Z80, etc., hardware access was achieved by accessing memory at special locations. The memory access would then be intercepted and translated into a hardware command. This is still done to a much more limited extent with modern architectures such as x86, but for the most part, hardware access is achieved explicitly through commands for accessing the data bus on the motherboard (these are what [tt]INP[/tt] and [tt]OUT[/tt] do).

The BIOS and the operating system provide abstractions and simplifications of the hardware, as well as standardizing different hardware into the same set of API calls. In DOS, API calls are achieved by raising interrupts in software, using register values as arguments for the function. This is actually a bit of a hack; interrupts were designed for receiving events from hardware. The CPU has 8 pins leading into it, and when the voltage on any one of them is dropped, the CPU instantly jumps to an interrupt handler. Each pin maps to the interrupt with value 8 greater than the pin number. The first 8 interrupts are reserved for error handling generated by the CPU. Interrupts 16 through 31 (0x10 through 0x1F) are provided by the BIOS for accessing system hardware such as the video card (int 0x10) and the hard drives (int 0x13). DOS then adds its own functions on interrupts 32 through 47 (0x20 through 0x2F), and from that point up they are hooked fairly arbitrarily by various drivers. The actual mechanism of interrupts is a table at the start of memory. It contains 256 pointers, one for each interrupt, and when an interrupt is raised, the address in this "interrupt vector table" is where the processor starts executing code.

There are references documenting all of this of which the most accessible is probably Ralf Brown's list. It is available on the internet at
 
wow thank you for that reference, logiclrd. I will print it out and use it as a reference. Of course, using it will be a whole different matter.

Thanks again,
Vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top