Showing posts with label assembly language. Show all posts
Showing posts with label assembly language. Show all posts

Monday, March 22, 2010

Books I didn't buy

Before there were big book stores like Borders or Barnes & Noble there was The New England Mobile book fair in Newton. This could hardly be considered walking distance from my home growing up in Needham, but I had made the trip on foot a couple of times as a kid with my brother Ernie. Now I made the trip more frequently since I had a car.

This store was really just a big warehouse, poorly lit, and not very well organized. However this was the largest collection of books for sale to be had for miles.

I remember clearly two books that I browsed there that I didn't buy but which left an impression on me.

One was called A Small C Compiler, by James Hendrix. Not the famous musician, of course. ;-) I read just enough of the book to appreciate its biggest idea. Once you write enough of a C compiler in assembly language, you can use that C compiler to write itself! Like I said I didn't buy the book, but I learned important ideas from just browsing through it.

Another book was call Smalltalk-80: The Language and Its Implementation. This was a tan and blue hardcover. I can't say I really understood at that time what I was looking at, but it was interesting enough that I didn't forget it. In more recent years I did find a copy of it used and now am a proud owner. Smalltalk is a terrific language this book explains in wonderful detail how it works. Nowadays the entire contents of this book can be read for free online.

Monday, March 8, 2010

MIX C

Unlike today, in the 1980s most computer magazines like BYTE, Compute!, and PC Magazine had lots of articles about programming and programming languages. BASIC, Pascal, Prolog, Lisp, Forth, assembly language; you name it. In 1987 C was a very popular language and a good C programmer made good money so I decided that I should learn it.

I found an magazine ad for MIX C headlined "C for yourself". They had a very special deal called MIX C Works and this included the compiler, a split screen code editor, and a source level debugger for only $89.90. The ad claimed that the included book would make learning C easy. I paid for this software myself, and it was so exciting to open the package when it arrived in the mail. Nice new crisp books and disks. It all felt very professionally done. It was a great investment.

It was very exciting to dig into the C tutorial and use the editor and the source level debugger. This was really well written software and book was as good as the ad promised. C is a nice, small language and well written C is actually quite pretty to look at with those curly braces.

We had some simple applications in engineering that were perfect for learning a new language. Open a file, translate the information in some way and write it back out to a new file.

Saturday, January 30, 2010

Enhancing Your Apple II

Back in the day friend Richard Stoddart loaned me a book titled Enhancing Your Apple II by Don Lancaster. Mind you, I didn't even own an Apple II but I was very interested in learning, and the book seemed promising so I took it home. The author Dan Lancaster was a popular writer and quite an Apple II guru. My understanding is that he was part of the same computer users group that Steve Wozniak, the creator of the Apple II belonged to. The contents of this book are certainly compatible with the idea that he had an insider's caliber of insight.

The book starts off with some really neat but simple modifications to the motherboard of the Apple II. The kinds of modifications described were things like adding a single wire to connect together circuits that would otherwise not have any knowledge of each other. Then he explains how with this and some simple software tricks you can do multimode graphics and high resolution text. He even shows how to do this from an Applesoft BASIC program by calling some machine code he provides in the book. Very nice.

Later in the book he explains how to disassemble machine code and figure out how a machine language program works so that you can make modifications. What an excellent education!

There is also supposed to be a Volume 2 of this book, but I'm not sure what it contains.

Monday, January 25, 2010

6502 Assembly Language

My brother Ernie is a little more than a year than I. He was ahead of me in the programming department when we were kids, and my first exposure to assembly language was through a book he had on Z-80 assembly language. I never did have an opportunity to try Z-80 assembly, but when I had my VIC-20 I decided to try 6502 assembly language. I didn't find machine language hard at all to grasp because it seemed very similar to the language used to program calculators, especially the HP-67.

I was a regular reader of COMPUTE! magazine, and in one issue they included source code in BASIC for a 6502 machine code monitor. This was a far cry from an assembler, but it was better than nothing. I wanted to try speeding up a side-scrolling video game, so I decided it made sense to write an assembly language routine to move characters from the right to the left by one character. This is how video game graphics were done on the VIC-20. You could program up to sixty four 8x8 pixel custom characters, and you put these on the screen for some crude graphics.

So, since I didn't have an assembler I needed to be my own assembler. The VIC-20 Programmers Reference Guide included all the information I needed to write my first assembly language program. Once I had the code written, I translated the assembly language instructions into machine code. On the 6502 the instructions are in the form of hexadecimal numbers. I typed these into the machine language monitor to try them out. I don't remember if I got this to work the first time.

When using machine code in BASIC on the VIC-20, you would usually convert the hexadecimal numbers into decimal and then put them in a DATA statement. Then READ the numbers and POKE then into memory and call the routine with the SYS statement.

The great thing about the VIC-20 is that anyone can learn to do these things. It's fun!

Stop reading this right now. Go to ebay.com and buy a VIC-20. Go to amazon.com and buy a copy of the VIC-20 Programmers Reference. Try it yourself! Seriously!

Saturday, December 27, 2008

COMPUTE! Magazine

Computer magazines used to be so much fun. First of all most of them had a very strong focus on programming and they would have articles about how to make electronic hardware to plug into your computer. Very much fun indeed.

Since I was the owner of a Commodore VIC-20 I would buy issues of COMPUTE's Gazette which catered specifically to Commodore 8-bit computers.

I remember one issue which included a machine code monitor listing. The program was in BASIC and it would POKE a machine code monitor (in machine code of course) into memory and then it would start up. I experimented with 6502 assembler using this monitor. I would write the assembly code down and then I would translate it myself to hexadecimal numbers and type them carefully in.

This was one of the great things about the computers of those days. A fifteen year old kid could figure this stuff out by reading magazine articles. There's probably no reason why it can't be made relevant to young people today. Why not make a cool and easy game programming tool for the Nintendo DS for example?

Thursday, May 17, 2007

The Home Computer Era

In the early 1980s there were so many kinds of computers before IBM killed off all the diversity with their IBM PC. This was a shame, especially since the microcomputer industry was only 5 years old and there wasn't a rich computer culture yet. The PC stopped the innovation in its tracks. Before the IBM PC small computers were usually called home computers.

It was wonderful that you could usually buy a 250 page book for the computer of your choice. That book would tell you everything... EVERYTHING about the innards of the machine. You could bend the computer to your will. These days you have no idea what's going on in the machine. As a programmer you deal with the Windows API, or with the Java SDK platform.

Sometimes I wonder how hard it would be to create a new computer simple enough to master it all the way down to the bits. The operating system would be very small and simple, and the machine could be programmed in BASIC, Forth, and assembly language. The code for the whole thing could be open sourced. Perhaps there wouldn't be a way to make money with such a product, but it would be fun. :-)

To get a feel for what this time was like, watch this YouTube video of Steve Wozniak relating his experiences growing up and designing the Apple computer. Great stuff! http://www.youtube.com/watch?v=ctGch5ejjT4

Saturday, May 12, 2007

Soldering and machine code

I should probably interject here that a year or so before I really got into programming my brother Neil bought me a kit radio for my birthday. It was a small battery powered AM radio, which did not look like a kit at all when completed. It could easily have passed for a commercial offering you would buy at a department store.

This kit was great fun to put together, and it helped me learn how to solder. I would use this skill as I got older for many purposes, some of them computer related.

I wish there was more of a kit culture today. While you can build robots with Lego Mindstorms and similar systems, it makes sense to learn things as fundamentally as possible.

In a similar way people studying computers should consider learning at least a simple machine code. For example before I had any opportunity to program in machine code I read a book on Z80 machine code. Eventually I had some chance to write 6502 assembly. I never mastered assembly language but it was valuable experience. I suspect that many young people studying computer science today are not exposed to the bare hardware of the machine these days. Universities should be held to account for this IMHO.

Sunday, April 29, 2007

Heathkit H-89

Finally in 1980 my father was awarded a generous bonus for his role in the creation of special radio equipment for use on aircraft carriers. He used this bonus to buy an H-89 kit for Heathkit. http://www.old-computers.com/museum/computer.asp?c=135

We finally had a real computer in the house! It ran CP/M and H-DOS (we use mostly this OS) and we had a couple of different versions of BASIC for it. We had something called Benton Harbor BASIC. The computer had no graphics modes, but it had graphics characters and I remember my brother Ernie was working on a version of Galaxians for it. We wrote a bunch of games. I remember my father also did some assembly language programming for it (or perhaps he just typed in straight machine code).

One thing I remember about the machine was that it used hard sector diskettes, and the floppy drive was loud. It would make clunking sounds. Ka-chunk, ka-chunk!