This is something of a followup to How much control of TRS-80 Model III disk drives was possible from its Cassette (ROM) BASIC? but on a more general topic:
I know that PEEK
and POKE
enable direct access the computer's memory (both ROM and RAM) from most BASIC implementations on the early home computers. POKE N,B
and B = PEEK(N)
are, respectively, like *n = b;
and b = *n;
in C and I suppose in either the BASIC case or the C case their exact behavior depends on what memory mapping is set up.
Many platforms expose not just memory, but all of their "peripherals" through special memory addresses. I think the PDP-11 was this way based on all the opcodes I've seen, I understand the Apple ][ may have been this way as well. Even more recently, chips like the MSP430 and the AVR series at the instruction set level all ultimately seem to use a single "memory" address space for accessing anything of the world outside the processor, both actual memory and any other I/O devices.
However, with at least the TRS-80 (were there other examples? was this Z80 family specific?) there is another type of I/O exposed through BASIC: the IN
and OUT
commands.
What did those actually do?
The user manuals say they read/write to "ports". Is that just a higher level abstraction of something also accessible through the memory space, or did some I/O actually happen through a different mechanism?
I did find for example on the Model III a list of Memory Mapped I/O Devices that has some apparent overlap with the Ports list. For example the memory address 37E4h
is listed as the "Cassette drive latch" while FF
is listed as the "Cassette Unit I/O" port. Is OUT 255,42
equivalent to POKE 14308,42
then?
INP
for the input command. I was getting strange ?BS Error results with e.g.?IN(244)
but?INP(244)
works fine — I'm assuming this must be a typo in Ira's site or something!