Ok, let’s start our Z80 Assembly programming course.
Here is how I plan to organize this course:
Module 1 – Basic Z80 programming
Module 2 – Advanced Z80 programming including peripheral programming
Module 3 – Introduction to game logic
Module 4 – Advanced game logic
So let’s start Module 1 with a quick historical background.
The Z80 was first released in 1976 by a company called Zilog. Its main attractive at the time was being compatible with another CPU called the i8080 made by Intel. The i8080 was probably the first important 8 bit CPU, and because of that an operational system called CP/M was developed for it. CP/M became the first the facto standard OS available for personal computers. But the Z80 wasn’t only compatible, as actually it extended the 8080 in many ways, so by the late 70s it had mostly replaced the 8080 as the CPU of choice for CP/M.
Around the same time (late 70s) the Z80 also became popular with arcade maker, especially in Japan. From 1979 to 1983 the Z80 was by far the dominant CPU in arcades. So it was natural that Coleco decided to use the Z80 in their “arcade quality” video game system.
The Z80 is an 8-bit CPU, meaning it can process 8 bits a time.
Now what is bit, you ask.
Well, you can understand bit as the smallest information unit that a CPU can store or transfer. Still too vague? Ok, a microchip is made of very small structures called transistors. You can understand transistor as a sort of switch, which can be either on or off, so two possible states. Bit is the representation of that, but instead of referring to on/off, we use “0” and “1” to represent the possible bit values. Better now?
Ok, I said the Z80 is an 8-bit CPU. You already know what a bit is. A group of 8-bits is usually referred to as a BYTE (I believe it comes from English acronym for “BinarY TErm”.
Everybody is familiar with the decimal numeral system, where we can use 10 different digits (0 to 9) to represent all sort of quantities. We can do the same with bits, and it is called the binary numeral system, since we only have two different digits to represent quantities.
So let’s see, if we have a byte, which means 8-bits, how many quantities can we represent?
First using two bits. Possible values are:
00, 01, 10, 11. So 4 possible values.
Now using three bits:
000, 001, 010, 011, 100, 101, 110, 111. So 8 possible values, which is twice as many as we could represent with 2 bits. Well, it isn’t too hard to figure out that every extra bit we add doubles the number of values we can represent, so the number of possible values is given by 2^n (2 to the n power), where “n” is the number of bits. Thus, 8-bits can give us 2^8=256 possible values.
Every number in binary system has a correspondent in the decimal system. For example, supposing the 3 bits example. 000 represents 0 in decimal, 001 is 1, 010 is 2, 011 is 3 and so on.
There is an easy way to determine the decimal equivalent of a binary number. Here is how you do that for an 8-bit number:
Starting from right to left, each bit is worth a certain decimal value:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
The rule is to add the decimals for each bit that is “1” in the binary value. For example, the binary number 01100011.
The “1” bits correspond to the 1, 2, 32 and 64 positions, so we add those numbers. 1+2+32+64 = 99. So the binary above corresponds to 99 in decimal.
Very good. So we have just learned about bytes, bits and the binary system.
Ok, so we know the Z80 can deal with 8-bit values, hence 256 possible values.
So does that mean that the Z80 cannot deal with values greater than 255? No, it can deal with values as big as we want, however the value must be broken into smaller 8-bit segments or components.
External memory
Any CPU is usually connected to an external memory or memories. Memory is the structure where the CPU stores data or where it reads the program from. A program is a sequence of commands that says the CPU what to do. Data is stored and read by the CPU while it executes a program. For example, the graphics that are displayed on screen are a type of data.
The ColecoVision has two different types of memory: RAM and ROM. ROM is the memory present inside each cartridge. The CPU can read it, but it cannot change the data or store new data in ROM. ROM means Read Only Memory. So a cartridge usually contains the game program and all the audio and video data.
RAM is the memory inside the ColecoVision. It is used as “work” memory, a place where the CPU can temporarily store the variable data used by the game, like the position of objects on screen, the current score, etc. RAM can be read from or written to and the content is lost once the ColecoVision is turned off.
Each memory cell or address can store an 8-bit value. Now, how does the Z80 access memory?
Even though the Z80 is an 8-bit CPU, it can “address” 16-bits of external memory. The reason is simple, 8-bit would represent only 256 possible memory addresses, and since each address store 1 byte, that would mean 256 bytes maximum. 256 bytes is certainly too little.
So instead the Z80 can address 16-bits memory positions, or 65,536 possible addresses if you do the math. In computer science it is usual to represent a “kilo”(a thousand) as 1,024, not the usual 1,000. The reason is because 1,024 is the closest to 1,000 that can be represented by a power of 2 (2^10). So 65,536 is exactly 64Kbytes.
So just to sum up, the Z80 can manipulate 8-bit data, but can address 16-bits of external memory.
Ok, I think this is enough for now. Sorry for all the technical stuff, but unfortunately we need to go through it if we want to program a video game.
In the next lesson we are going to discuss the Z80 internals.
- AtariAge Forums
- → Viewing Profile: opcode
opcode
Member Since 24 Apr 2002OFFLINE Last Active Today, 12:12 AM
Community Stats
- Group Members
- Active Posts 2,134 (0.6 per day)
- Profile Views 13,947
- Member Title River Patroller
- Age 41 years old
- Birthday December 20, 1970
-
Custom Status
Bringing new life to your ColecoVision!
-
Gender
Male
-
Location
Franklin, MA
Topics I've Started
Z80 Assembly - Module 1 - Basic Z80 programming
Fri Feb 3, 2012 5:42 PM
Interest check on online Z80 Assembly course
Fri Feb 3, 2012 10:45 AM
Anyone interested on an online Z80 Assembly course for beginners?
A friend of mine wrote a top notch online course, but it is in Portuguese. If there is interest I would try to translate the course.
Eduardo
A friend of mine wrote a top notch online course, but it is in Portuguese. If there is interest I would try to translate the course.
Eduardo
Merry Christmas a happy New Year from Opcode Games
Sun Dec 25, 2011 1:06 PM
I would like to wish a Merry Christmas and a very happy New Year to all my friends here at Atari Age.
May 2012 be a great year for you all as well as for all things ColecoVision.
I would also like to apologize for being away for quite a while, but unfortunately personal issues kept away. Anyways, I hope to reopen the website and resume projects soon.
Eduardo
May 2012 be a great year for you all as well as for all things ColecoVision.
I would also like to apologize for being away for quite a while, but unfortunately personal issues kept away. Anyways, I hope to reopen the website and resume projects soon.
Eduardo
The official "Moon Cresta" thread
Thu Aug 18, 2011 6:51 PM
By now it isn't a secret anymore that I am working on a port of Moon Cresta for the ColecoVision (hopefully in time for the 30th anniversary).
Here are the first couple of screenshots, from BlueMSX. The attract sequence is already running, but I want to fine tune it a bit before posting a video.
Moon Cresta was released in 1980 by Nichibutsu in Japan, then got an US release as "Eagle" by Centuri. Eagle has slightly altered graphics compared to the original Moon Cresta though. I am not 100% sure but I think Moon Cresta was also eventually released in the US by Nichibutsu themselves as well as possibly Gremlin/Sega.
Moon Cresta was very influential at the time because it created the concept of docking two "lives" together to increase firepower (something Galaga later also used), as well as being one of the first shooters to introduce the concept of stages with different enemies.
As a bonus I am also posting a picture of something I just received in the mail...
Here are the first couple of screenshots, from BlueMSX. The attract sequence is already running, but I want to fine tune it a bit before posting a video.
Moon Cresta was released in 1980 by Nichibutsu in Japan, then got an US release as "Eagle" by Centuri. Eagle has slightly altered graphics compared to the original Moon Cresta though. I am not 100% sure but I think Moon Cresta was also eventually released in the US by Nichibutsu themselves as well as possibly Gremlin/Sega.
Moon Cresta was very influential at the time because it created the concept of docking two "lives" together to increase firepower (something Galaga later also used), as well as being one of the first shooters to introduce the concept of stages with different enemies.
As a bonus I am also posting a picture of something I just received in the mail...
Opcode Games honored with two Player's Choice Awards 2011
Tue Aug 16, 2011 7:04 PM
The title says it all. Opcode was honored with two Player's Choice Awards 2011.
http://www.getdevious.com/atari/pca/
Awards are:
Favorite Homebrew Artist - Eduardo Mello
Favorite ColecoVision Game - Donkey Kong Arcade
This is a huge boost of encouragement you guys just gave me. Thank you so much for supporting me for the last decade.
Eduardo
http://www.getdevious.com/atari/pca/
Awards are:
Favorite Homebrew Artist - Eduardo Mello
Favorite ColecoVision Game - Donkey Kong Arcade
This is a huge boost of encouragement you guys just gave me. Thank you so much for supporting me for the last decade.
Eduardo
- AtariAge Forums
- → Viewing Profile: opcode
- Guidelines




Send me a message
Find content
Display name history



