Thursday, April 5, 2018

Understanding original FORTH


I have guessed that Chuck Moore established a layout for disk blocks used by his first implementation of FORTH, written on an IBM 1130 back in 1968-1970 when he was at Mohasco. FORTH handles access to the disk itself using raw 1130 instructions, not the Disk Monitor System or its utilities. Because of that, he can ignore the conventions used by DMS.

A disk file on an IBM 1130 consists of physical sectors of 321 words, with the convention reserving the first word to contain the sector number. This is a check against errors in reading or writing, since the first word should match the sector number associated with that physical location on disk.

An 1130 disk consists of 203 tracks or cylinders, each is a circular path on the rotating disk surface, the circles arranged concentrically from the outer side to the inner side over a 2" wide span of the 7" disk radius. The track closest to the outside is track 0, also called the home cylinder. The disk drive reports when the positioning arm is at the home position.

The disk is a two sided platter, thus there are two read/write heads, top and bottom. For each track/cylinder, we can access top and bottom separately, doubling the data capacity at that track.
As the disk rotates, it is divided into four segments each of which stores 321 words, one physical sector.

Thus, each side of a platter has four sectors, a total of 8 per track, and the entire disk holds up to 8 * 204 sectors or roughly 512K words. A few of the end tracks are reserved to serve as replacements for a track that may contain a bad spot which won't allow correct reading/writing. These alternate tracks are hidden from the user's accessible capacity, as they replace 1 for 1 any bad track.

We can number sectors starting at 0, with 4 on the top head and the next 4 on the bottom head. Thus, track 0 has sectors 0 to 7, track 1 has sectors 8 to 15, and so it continues. Chuck picked sector 2E0 as the beginning of the area for FORTH user disk data, which is sector number 736 in decimal. That means it begins at track 92 with top head, sector 0.

As formatted by DMS, the disk contains 2E0 in the first word of track 92, top head, sector 0 and each subsequent cylinder contains the relevant sector number. The IBM simulator watches this first word, writing a warning message if a user reads or writes a sector where the first word does not match the sector number.

Chuck instead is using the first word as some kind of integer counter, which is incremented each time the CREATE verb is issued. The verb EMPLACE which seems to accept user input to put it into the buffer, writing back the sector, starts that data at the 30th word into the buffer.

I suspect there are other format constraints as well, but will need to study this further before I fully decode the format and can begin using FORTH correctly. Since at the time this was written, only Chuck Moore used it, there was no need for written documentation or even comments in the code to steer another person towards using it properly. He was the world's sole FORTH programmer. 

No comments:

Post a Comment