DEV Community

Lee Jones
Lee Jones

Posted on

Things All Programmers Should Do At Least Once Pt 1


title: Things All Programmers Should Do At Least Once Pt 1
published: true
description:
tags: assembly, career, beginners, coding

Things All Programmers Should Do At Least Once Pt 1

Write a small Program In Assembly Language

The other day I gave my 'uphill both ways in the snow barefoot' / 'back in my day' programming talk and it made me think about the path of fledgling programmers. The challenge I see right now in the programming world is that we are standing on the shoulders of giants who are standing on the shoulders of other giants who are also standing on the.. well.. you get the picture. At the very bottom of that stack of giants is the baddest mother of them all. Faster and stronger than the others by several orders of magnitude. She is the one that whispers unfiltered magic to the CPU. My fear is that she's getting lonely these days. Her time spent having boring conversations with bios engineers, firmware guys and hardware hobbyists. All programmers should spend a little time with her and learn some reverence. They need to know when it comes down to it, how programs really get things done.

Back at the beginning of my journey in 1984, I was writing communications software on the Commodore 64 in BASIC. Due to the small processor and an inefficient language, there were times when the program struggled to keep up with a 300 baud connection. I discovered that the only solution was to write the input and output routines in machine code.
To this end, I spent the first part of my 14 year old summer using a machine code monitor to figure out how to simply output my name to the screen. After a few days I managed this seemingly insignificant task but was then left with a terrible sinking feeling thinking about all would be involved in interfacing with the BASIC language and reading and writing to the serial port. Then it happened.. one weekend during one of our frenzied software trading get togethers, my friend Mike gave me a pirated copy of the Commodore Macro Assembler Development System.This. Changed. Everything. Assembly language gave me a whole new toolset. Now I wasn’t just typing numbers into a box, now I was afforded the ability to write instructions that looked vaguely English into a text file. I could use names for variables and write comments. Amazing! In order to turn this file into the super fast machine code that I needed, I had to learn about compiling and linking, something very foreign to a kid who had until that point only typed instructions into a BASIC interpreter and typed ‘run’.

Since my first encounter with the 6510 assembler, I’ve worked with assembly on x86 and m68k processors plus various embedded chipsets. Each time I do, my mind goes back to that place where I had to do a lot to get very little to happen, but the trade off was that very little thing ran very very…*veeery fast! *Until you have written something in assembly language, you will never know how fast your computer can really go.

I owe a lot to my first experience with assembly.

  • I learned about the individual instructions that processors consume.

  • I learned about registers.

  • I learned the magic of the accumulator.

  • I learned about allocating, accessing and freeing memory.

  • I learned the very core of comparing and branching.

  • I learned about compiling to object code and why linkers exist.

The next big step on my journey was learning the C language. Everything that I learned using the macro assembler gave me a huge advantage because it gave me an understanding of how C works at a very low level.

The most important thing learning to write programs in assembly taught me was how to do something really hard with very little other than a quite shoddy xeroxed manual and a couple of smart friends.

Oldest comments (1)

Collapse
 
computersmiths profile image
ComputerSmiths

One of my favorite filk songs compares assembly to construction work using a toothpick as a tool. 😁

But it really gets you down in the details of the CPU and how it works, and is invaluable (as you noted) when learning other languages.

I kinda miss my Z-80 asssembly days, bank-switched BIOS, LRU disk drive caching, tape drive routines, fiber optic links, invent your own floppy disk format for higher capacity, etc. Ah, the good old days!

Great article, thanks for the memories!