Z80 Assembly - Index
 

Introduction

This document is intended for everyone who wants to learn Z80 programming in its depth. If you already know the basics of programming, you should just keep reading, I will explain everything from the very beginning. However, if you have no programming experience whatsoever, assembly is surely not for you. Start out with a high-level language, it is much easier, and will help understanding assembly later a great deal. But if you still decide to go on, read everything very carefully.

This guide is not yet finished. I decided to release it, however, to receive feedback about it as early as possible. So don’t hesitate to share your opinion with me at patai.gergely@freemail.hu. I will consider every idea for the next release.

About the author

I’m Patai Gergely (to make things clear, Patai is my family name), a Hungarian university student at the time of writing this guide. I was born in 1982, and started out with a C64 at the age of 8. I used it mostly for gaming, and never went beyond learning Basic. After obtaining a PC, I started programming in Pascal, and at the age of about 12 I got to know the very basics of assembly. Since those times I wrote several megabytes of useless source, like 3d engines, MOD players and loads of other crap for my own pleasure. As I became an international baccalaureate student, I had to buy a TI-83, which opened my way into the Z80 world. I learnt Z80 assembly in about two days (based on my previous knowledge), and wrote Traz in a couple of hours as a CAS (Creativity-Activity-Service, not “Computer Algebra System”) project. Currently it seems that I’m to become an informatics engineer in 2005... I just hope you will find this guide useful.

You can find my homepage at http://eclipse.sch.bme.hu/~cobb. If the link does not work (it is likely to be unavailable during summer), you will find a mirror at http://cobb.host.sk as well.

References
 

Books
 

Ligeti Gábor – Szervánszky György: A ZX Spectrum programozása (ZX Spectrum Programming), Budapest, 1985

Agárdi Gábor: Gyakorlati Assembly (Assembly in Practice), Budapest, 199?

Gál Tibor: Digitális rendszerek II. (Digital Systems), Budapest, 2002
 

On-line materials


James Matthews: ASM83 Guru
Greg Parker: TI-85 Assembler Programming
Devin Gardner: The Complete Z80 OP-Code Referece
Zilog: Z380 Microprocessor – Product Specification
The whole ticalc.org archive

The Basics


Read this first!!!

Assembly in general
Compiling programs
Data and numbers
Registers
Variables in assembly
The LD instruction in detail
Stack operations

Simple Structures


Working with arrays
Conditional branches
Relative and absolute jumps
Subroutines

Simple Tasks


Working with data
Summing one-byte numbers
Adding large numbers
Moving data blocks
Manipulating data blocks (selection, sorting, searching)

Multiplication and Division


First approach
Shift instructions
Fast 8-bit multiplication
Fast 8-bit division
Fast 16-bit multiplication
Other aspects


Appendices


Z80 instructions explained