Hacker News new | ask | show | jobs
by jgrahamc 2709 days ago
A good reference for Z80 programming is Rodnay Zaks' Programming the Z80. On page 94 at the start of the chapter Basic Programming Techniques there's a section on 8-bit addition. The program is as follows:

    LD   A,(ADR1)        LOAD OP1 INTO A
    LD   HL,ADR2         LOAD ADDRESS OF OP2 INTO HL
    ADD  A,(HL)          ADD OP2 TO OP1
    LD   (ADR3),A        SAVE RESULT RES AT ADR3
this is the idiomatic Z80 way. That book goes on to show how to do 16-bit and 32-bit arithmetic the Z80 way.

http://www.z80.info/zip/zaks_book.pdf

1 comments

Rodnay Zaks is a name I remember very well from my Spectrum-days. I have a small collection of Z80-books which I've carried around, across countries, for the past 30 years.

I should go dig out an emulator soon! (I usually have a game or two of "Chaos: The Battle of Wizards" every six months or so.)