• Please review our updated Terms and Rules here

Programming Altair confusion

falter

Veteran Member
Joined
Jan 22, 2011
Messages
6,577
Location
Vancouver, BC
In addition to other projects I've been proving out my Altair 8800 by running some programs including some famous ones. I'm decently good at it now but I get confused when the author expects you to enter in your own values for something, particularly memory locations. The listings are often in hex and we have to convert for octal, or they're kind of a mixture.

So for example I was wanting to do the Fool on the Hill demo, and in the comments for the original listing it says 'be sure to load the starting address into H&L at address 002 and 003'. This is the first place I get confused, because looking at the listing itself, it has the address of first data entry at 001 and 002. And then the second point of confusion is, lets say I do as the demo does and start my music data at 041. What *is* 041? Is that octal, or decimal or something else? I guess what I'm asking is, what am I actually putting into 001 and 002 or 002 and 003? This is why i find programming so difficult.
 
Yes, in this program, the address of the start of the music should be stored in addresses 1 and 2 of the program. Never rely on documentation!

The key word for your second question is the word 'at'. This would indicate an address. So 041 is an address in the machine.

As to the base of the address 041, I was always taught that if a number begins with 0 it is octal (my C language programming showing). Although this is not a guarantee!

The trouble is, with programming, you should be consistent about what you do and how you specify things, otherwise you cause confusion.

By the way, I hate using a leading 0 for octal. I always prefer:

#define OCTAL( n ) 0##n

And then write:

int X = OCTAL(42);

It makes more sense to people reading that irrespective of their skill level with C!

Dave
 
One of my pet peeves with C--the damned octal shorthand. You'd think this would have been deprecated by now.

Of course, we have all of these modern systems working in octal. On systems where quantities are expressed in multiples of 8 bits, it's insane. (and yes, I've worked in both; sometimes at the same time).

Well you dance with the girl ya brung...
 
And the first note of the first song (Fool on the Hill) is stored starting at address 040 (octal) in this version of the program and not 041 (octal).

Dave
 
Last edited:
I second everything Dave said (and I add my own editorialization that octal is wildly unintuitive for anyone who learned software development after the 70s, for whom multiples of 8 bits is simply a law of nature) but yes, 041 is an octal value, and one way of recognizing that on the Altair is that it's three digits-- one 8-bit byte in octal is represented first by a two-bit value, then two sets of three bits. So you have numbers that are written as a first digit from 0-3, then a second digit that's 0-7, then a third digit also with the range of 0-7. This is not coincidentally how the switches and lights on the front panel are laid out, which is a small blessing I suppose.

(Full 16-bit values can I guess also take the form of 1-3-3-3-3-3? which is nuts, but that's how the panel is laid out? The IMSAI's great UX improvement-- to me-- is that the switches and lights use hex groupings which seems far more sensible for an 8-bit system with 16-bit addresses.)
 
Octal was more of a convenience thing for earlier systems right? To keep the front panel LED numbers and other pieces down?

Yeah the documentation on some of these vintage programs is so confusing. A lot of them seem to treat address 000 (octal) as address 001 in their documentation. It's really confusing for a newbie.
 
(Full 16-bit values can I guess also take the form of 1-3-3-3-3-3? which is nuts, but that's how the panel is laid out? The IMSAI's great UX improvement-- to me-- is that the switches and lights use hex groupings which seems far more sensible for an 8-bit system with 16-bit addresses.)
Work in the DEC world much? 16 bit values are often expressed as 2 3 3 2 3 3. I suppose DEC had an excuse for the PDP-11. The PDP-8 is a 12 bit machine and the PDP-10, 36--both used octal, so why rock the boat?
But octal is largely a holdover from the 6-bit character days. Makes even less sense when you try to represent a string of 4 bit packed BCD digits. At the same time, I used octal (CDC Cyber 70; 60 bit CP words with 12 bit PP words) and hex on STAR (64 bit words). The Cyber 70 words were expressed as 20 octal digits, the STAR as 16 hex digits.
When CDC decided to implement 8 bit ASCII on the Cyber, lots of schemes were proposed (because 20 divided by 8 is 7.5). What I remember was 7.5 characters per word, 6 characters per word, discarding the most significant 12 bits; using 10 bit characters, 7 characters per word, discarding 4 bits.... What was eventually adopted was to stick with 6 bit characters, but have "escape" characters to enable an additional 62 or so characters represented as 12-bit values. DEC WPS running on the PDP-8 architecture reserved some 6 bit characters as "shift" characters, so one could shift to the lowercase set, much like the shift-lock on a typewriter.
 
Last edited:
Yes, in this program, the address of the start of the music should be stored in addresses 1 and 2 of the program. Never rely on documentation!

The key word for your second question is the word 'at'. This would indicate an address. So 041 is an address in the machine.

As to the base of the address 041, I was always taught that if a number begins with 0 it is octal (my C language programming showing). Although this is not a guarantee!

The trouble is, with programming, you should be consistent about what you do and how you specify things, otherwise you cause confusion.

By the way, I hate using a leading 0 for octal. I always prefer:

#define OCTAL( n ) 0##n

And then write:

int X = OCTAL(42);

It makes more sense to people reading that irrespective of their skill level with C!

Dave
Thanks Dave! So if I'm entering octal 041 into locations 01 and 02 , in terms of what I'm actually entering on the front panel, the first byte is 41, the second byte is 00? That's sort of how I've seen it done elsewhere in the MITS guide.
 
Octal was more of a convenience thing for earlier systems right? To keep the front panel LED numbers and other pieces down?
What Chuck said ^^. Octal is a holdover from earlier systems where different bit widths were common, was benign but confusing on the 8-bit Altair, and very quickly was replaced by standard hex on the IMSAI and the Altair 680. If you have a 6-bit character, you can represent that fully and entirely in two octal digits. When you use 8-bit bytes, you end up with goofy leftover bits.

Work in the DEC world much?

My first tech job was at DEC, but thankfully (?) it was in the NT/VMS era and world. I deeply respect, but do not personally envy regular use of bit widths on older PDPs. :)
 
Thanks Dave! So if I'm entering octal 041 into locations 01 and 02 , in terms of what I'm actually entering on the front panel, the first byte is 41, the second byte is 00? That's sort of how I've seen it done elsewhere in the MITS guide.

Correct. The 8080/Z80 stores 16-bit address and data values as low byte first followed by high byte second.

Dave
 
Octal is also useful on a DEC PDP-11 when entering 'raw' instructions and debugging from the console. The instruction set is largely based on three bits for various fields of the instruction - so octal is natural (despite that the fact that the machine has a 16 bit data bus (not 12)).

Dave
 
Correct. The 8080/Z80 stores 16-bit address and data values as low byte first followed by high byte second.

Dave
Thanks Dave. So just to test my newly acquired knowledge, let's say my data were located at memory address (octal) 123 (I'm not sure if that would be a valid memory address on an altair that only has 768 bytes of ram presently, but just for example sake), then for this program, I'd enter 23 for the first byte, then 01 for the second?

Or I'm just entering 123 octal for first byte followed by 000 for the second byte. The memory address would have to be really high for the high byte to be anything other than zero.

EDIT: the answer must be the second I think.. its just confusing coming from a system that uses hex and has switches set up for binary like the ELF I've been messing around with.
 
Last edited:
Octal is also useful on a DEC PDP-11 when entering 'raw' instructions and debugging from the console. The instruction set is largely based on three bits for various fields of the instruction - so octal is natural (despite that the fact that the machine has a 16 bit data bus (not 12)).
Same for the 8080--the instruction register operands are encoded as 3 bit quantities. But that's a weal excuse. Any programmer worth his salt can make the mental adjustments. Consider the aforementioned STAR. Addresses were bit-granualar, indices could be byte, halfworkd (32 bit) or fullword (64 bit). Now try mentally computing the effective bit address of something with a halfword index.
Wimps. Now get off my lawn! :)
 
I was teaching a junior programmer to debug on our own real-time operating system. We were working in bases 8, 10 and 16 and dealing with quantities of byte and word addresses.

In my notes (and explanation) I was meticulous in specifying the base I was using and the units.

He only noted the numbers down in his notebook...

Later I kept getting emails about my conversions not working. Of course, he was forgetting to change bases and units as necessary because he never noted the important things down!

Needless to say I had to write him a more explicit email for him to follow...

Dave
 
>>> Or I'm just entering 123 octal for first byte followed by 000 for the second byte.

Yes, 123 octal for the first byte and 000 for the second.

This works for addresses up to 0377. After that, the next address is 0400.

This would be stored as 000 in the first byte and 001 in the second byte.

Which is absolutely why hexadecimal is easier for this machine!

Some machines also specified their octal words as 001-000 with each part being individual 8 bits of the address, so you would count from 000-377 to 001-000.

Dave
 
I gave it a go but no luck hearing sound. I verified the program and data contents twice. I tried a little alarm clock radio I had and dialed around AM but couldn't pick up any discernible changing tones. I then tried the only other AM radio I have in our house, a 1973 Sony stereo receiver.. it picked up a couple of radio stations but nothing but perhaps one continuous high pitch squeal from the Altair.

I'm wondering if anything would be different with my Altair vs others as it is not stock.. it has an aftermarket PSU and backplane.

Hmm.
 
Perhaps you should try this removing the lid to improve the radiation.

My first 8800 music was done by toggling the interrupt enable line--viewed as an LED indicator on the front panel. An 0.1µF capacitor coming off that fed an audio amplifier.
 
Last edited:
You should hear some 'random' noise on the radio with the CPU executing any program.

As Chuck says, the shielding of your metal case may be too good.

The position and orientation of the radio relative to the CPU will have an effect as well as the frequency that the radio is tuned to.

I am surprised if you don't pick up anything though. Perhaps a little more patience and experimentation is required?

Dave
 
Well after experimenting with computer on and off, I am hearing a high pitched noise.. but it's not changing or anything. I've checked the program a few times. Last night I changed the listing numbers on the left to reflect what they actually are on the Altair (ie changed 00 to 01, 01 to 02 etc.). Rechecked again to make sure I haven't messed anything up. One question mark was tempo.. the listing expects you to fill that in but doesn't offer an example. I found some 'code critique' site that listed the program and had filled in tempo as hex 20, so I converted to octal and tried that.
 
Back
Top