Showing posts with label machine code. Show all posts
Showing posts with label machine code. Show all posts

Sunday, April 4, 2010

My Skunk Works Project

What is a skunk works? A definition from Wikipedia: The designation "skunk works", or "skunkworks", is widely used in business, engineering, and technical fields to describe a group within an organization given a high degree of autonomy and unhampered by bureaucracy, tasked with working on advanced or secret projects.

In order to prototype the multiuser shop floor control system, I needed a real video terminal. The idea would be to take a computer and install one or more multiport RS-232 cards and connect terminals to them from all over the building.

The following work was done more or less under the radar. I wasn't trying to get away with anything, but I hoped to surprise Bob with the results I hoped to achieve. I managed to requisition an old Lear Sieglar ADM-3A terminal on the cheap. This was one of those pastel blue terminals with a "space age bubble" look to it. Needham High School had a few of these connected up to their PDP-11.

In order to make this work with Smalltalk/V I needed a tiny machine code routine so I could make calls to the serial port. I was lucky to find someone on a bulletin board who was kind enough to write this for me. I was even luckier that it worked! The machine code file was only 14 bytes long!

It didn't take me very long at all to create a master monitor, a login routine, a simple command parser, a simple job object, departments that could hold jobs, and the ability to move the work from one department to another and list the contents of each department.

What was absolutely most amazing about what Smalltalk/V made possible is that the system was extensible and debuggable... as it ran! If there was a runtime error while executing some command from the terminal, a debugger opened on the computer screen. I could then fix the bug right there, and the terminal could be restarted without bringing the system down for a recompile.

This was very promising to say the least.

Monday, February 1, 2010

Pocket Computers and Programming

My brother Ernie was a fan of the Radio Shack pocket computers. He started with the original pocket computer. This was a neat little machine with a QWERTY keyboard and a BASIC interpreter. This was a real step up from a programmable calculator. Later on he bought their Pocket Computer 2 model. I think this model had two microprocessors, and you could draw very simple pixel graphics with it. You could save your programs to tape, and there was a printer for it. My brother managed to discover a machine code monitor in that model and he was experimenting with that. This reminds me of what another friend of mine told me about the first model of the HP-41 calculator, that it was possible to program it in machine code in an undocumented way.

Today these pocket computers would seem quite primitive and wanting, but for many purposes even today they would be very useful. Of course nowadays people expect their pocket devices to have Wifi and Internet access. What was great about these machines? They shared the same approachability as home computers like the VIC-20 and TRS-80. Just by reading a simple 100 page manual you could learn how to make the computer do your bidding. Want to be a programmer?

You + pocket computer + 100 pages of reading = programmer

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?

Sunday, June 24, 2007

Microcomputer Trainer

I think one of the best things a budding programmer can do is program in machine code. The absolute easiest way to get your toes wet in this skill is by using a microprocessor trainer. Radio Shack used to sell the simplest trainer I've ever seen, and I even have one of these around the house somewhere. Sometimes you can still get these on ebay (in fact that's where I got mine).  
I know this looks like a toy, and it is. For a toy it's serious business. It has a very simple Texas Instruments microprocessor and you program it in machine code using the hex pad. Easy instructions are included. 
Once you've played with one of these, the next fun thing to do is to write a simulator in BASIC. Not that hard to do actually. ;-)

Monday, May 28, 2007

Ohio Scientific Challenger Series

I remember once while on a family roadtrip I found a magazine in the car. It seems to me that the front and back covers of the magazine were torn off, as can happen easily when a magazine is left on the floor of a car. I think it was an issue of BYTE Magazine, but I'm not sure.

There was an article detailing a single board computer with diagrams. The computer was an Ohio Scientific computer, probably a Superboard. http://oldcomputers.net/osi-600.html

These were very cool machines, and pretty cheap. They used a 6502 processor and had BASIC and machine code monitor in ROM; sort of a poor man's Apple II. For the money it was a better machine. With better marketing and a nicer looking case perhaps they could have given Apple a run for their money.

Thursday, May 24, 2007

Summer Break - My Own Company

When I was about 14 I decided to create my own company to create video games. I didn't even own a computer, but I spent a lot of time at NEECO, and they let me use theirs. The machine I targeted was the Commodore VIC-20, and I thought I was being clever when I came up with the name VinkSoft.

The game I created was a simple simulation of flying through an asteroid field. You needed to shoot the asteroids to destroy them or else they would hit your ship. It probably took a couple of dozen hours to create this game. The graphics on the VIC-20 were all done by creating custom graphics characters. Sound was pretty easy with the computer's built-in 3 voice tone generator and white noise generator. The actual BASIC code for the program wasn't very big because it all had to fit in 3.5K of RAM. The game was fast enough in BASIC that it didn't need any machine code routines.

My plan was to sell the software at NEECO, and the sales guys there agreed to do it. The software would be in a ziplock bag with some artwork and a cassette tape. A lot of software was sold this way back then. My father helped me with the artwork. He's pretty good at drawing sharp graphics, which makes sense because he spent thousands of hours drawing things at a drafting table.

So the sales guys at NEECO put the software on the wall (2 copies) with all the rest of the stuff there. Within a couple of days they had sold one! Unfortunately the owner of the company had not cleared this clandestine operation and when he found out he had my remaining copy pulled. I don't think they even gave it back to me.

The things we kids did during summer break. ;-)

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.

Saturday, May 5, 2007

The VIC-20

In 1980 Commodore introduced a new 6502 based $299 home computer called the VIC-20. http://oldcomputers.net/vic20.html

It was essentially a version of the Commodore PET that plugged into a TV set. For the price there was nothing like it. It had Commodore BASIC built-in, color and sound, a joystick port, and a cartridge expansion slot. It didn't have graphical sprites, but it was still capable of video games and it cost about half the price of an Atari 400.

I wrote a lot of software for this machine at NEECO where I hung out. It didn't have full screen graphics, but you could program the graphics characters on the fly. It did have a very low screen resolution (22x23 text mode, 176x184 graphics mode) and it only came with 3.5K of available RAM out of the box, but we were very used to limited memory back then.

Compute! magazine had some really great software listings for this machine, like a graphics character editor for example and a machine code monitor. Just type it in and go. :-)