The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Wednesday, January 31, 2024

I know languages that have support for “read-only memory,” but what about “write-only memory?”

I'm still hacking away on my overengineered 6809 assembler and one feature I've beem mulling over is a form of static access checking. I have byte-level access control when running tests but I'm thinking that adding some form of “assemble time checking” would also be good. I've been writing code hitting the hardware of the Color Computer, and there are semantics around hardware that I don't think many languages (or even assembler) support—write only memory! As the Amiga Hardware Reference Manual states (only referenced here because it's a good example of what I'm talking about):

Registers are either read-only or write-only. Reading a write-only register will trash the register. Writing a read-only register will cause unexpected results.

When strobing any register which responds to either a read or a write, (for example copjmp2) be sure to use a MOVE.W, not CLR.W. The CLR instruction causes a read and a clear (two access) on a 68000, but only a single access on 68020 processors. This will give different results on different processors.

The Color Computer isn't quite as finicky (although the 6809 inside it also does the “read, then write” thing with the CLR instruction), but there is still memory-mapped IO that is read-only, some that is write-only, and some that has different meanings when reading and writing. And while C has some semantic support with volatile (to ensure reads and writes happen when stated) and const (to ensure the read-only nature) it still lacks a “write-only” concept. And I've never used an assembler that had “write-only” semantics either.

I'm thinking something along these lines:

		org	$FF40
DSK.CTRL	rmb/w	1	; write only

		org	$FF48
DSK.CMD		rmb/w	1	; write only
		org	$FF48
DSK.STATUS	rmb/r	1	; read only

DSK.TRACK	rmb	1	; these can be read and written
DSK.DATA	rmb	1

Here, the RMB directive just reserves a number of bytes, with a default access of “read-write.” The /W or /R designates that label as being either “write-only” or “read-only.” And if you look closely, you'll see that both DSK.CMD and DSK.STATUS are defined as the same address. It's just that writing to that address will send a command to the drive controller, while reading from that address give the current status. The only issue I have are hardware registers that can be programmed for input or output. The MC6821 used in the Color Computer has such registers, and the issue I have is how to signify this change in state in a program—that at this point in the program, such-n-such address is “read-write” but afterwards, it's “write-only.”

Discussions about this entry

Obligatory Picture

[“I am NOT a number, I am … a Q-CODE!”]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site:, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.