Questions tagged [z80]

The Z80 is an 8-bit CPU designed by Zilog to be a backwards-compatible enhancement of the Intel 8080. It has been in continuous wide use since 1976 and was formerly popular in microcomputers, such as models of the Tandy (Radio Shack) TRS-80 microcomputer and their derivatives, the ZX Spectrum and the MSX standard. Presently its main use is in embedded systems.

Resources on the Internet:

The Zilog Z80 CPU User Manual

Rodnay Zaks wrote a classic book on the Z80: Programming the Z80

See also:

182 questions
40
votes
3 answers

Game Boy: What constitutes a "half-carry"?

The Game Boy Z80 CPU has a half-carry flag, and I can't seem to find much information about when to set/clear it. What I understand so far is that any 8-bit add, subtract, shift, or rotate operation (and maybe others?) set it to bit 4 of the…
Rena
  • 3,923
  • 3
  • 22
  • 19
28
votes
2 answers

Overflow and Carry flags on Z80

I have gotten round to implementing the ADD A,r set of opcodes on my Z80 core. I had a bit of confusion about the carry and overflow flags which I think I've nailed, but I wanted to put it to the community to check that I'm right. Basically, from…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
27
votes
14 answers

What are your favourite ZX Spectrum development tools?

What are your favourite assemblers, compilers, environments, interpreters for the good old ZX Spectrum?
Umber Ferrule
  • 3,358
  • 6
  • 35
  • 38
23
votes
3 answers

Z80: How to add 16 and 8 bit registers?

How do you add a 16 and a 8 bit register with carry (for example, HL, and A)?
xkdkxdxc
  • 511
  • 5
  • 9
21
votes
4 answers

Z80 DAA instruction

Apologies for this seemingly minor question, but I can't seem to find the answer anywhere - I'm just coming up to implementing the DAA instruction in my Z80 emulator, and I noticed in the Zilog manual that it is for the purposes of adjusting the…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
19
votes
7 answers

Where can I find a 8080 to x86 assembler conversion tool?

EDIT, GOOD NEWS! 10 years later, I decided I finally had to sit down and make this happen. I wrote the necessary convert-8080-to-z80-or-x86 and convert-z80-to-x86 tools, converted the Sargon code to x86 code, increased the search depth as I discuss…
Bill Forster
  • 6,137
  • 3
  • 27
  • 27
16
votes
1 answer

TI Assembly: differences between nostub, Ion, MirageOS, and z88dk C

I'm new to the TI programming platform. I hope to get some pointers on what's my best route for this. I'm required to produce a series of arithmetic and graphing functions compatible across TI-83(p) and 84p models. I was delighted to find a wealth…
Anton A
  • 171
  • 5
15
votes
1 answer

Zilog Z80 OP-Code implementation

I'm currently developing an emulator for the good old GameBoy and I'm facing some problems understandig how some basic operation codes have to be implemented. Right now I'm implementing the AND operations; the first few (0xA0 -> 0xA3; 0xA6 & 0xA7)…
Sepultura
  • 997
  • 1
  • 9
  • 28
14
votes
2 answers

What's the purpose of instructions for loading a register to itself?

While looking through the Gameboy's instruction set, I came across instructions such as: LD A, A LD B, B LD C, C LD D, D ... Each of these instructions has it's own opcode in this table, which makes me think they are of some importance due to the…
Spooze
  • 378
  • 1
  • 10
14
votes
8 answers

Writing a graphical Z80 emulator in C or C++

I want to take an interest in writing my own simple emulator for the Z80 processor. I have no experience with this type of programming. I am mostly fine with using C-based languages as they are the ones I know best. What do I need to accomplish…
Bobice M.
  • 159
  • 1
  • 1
  • 5
13
votes
2 answers

Optimizing a bit-manipulating algorithm in GameBoy Z80

This is not a homework problem, it's for a game I'm developing. I have two 16-bit RGB colors, and would like to vary their six channels according to six other four-bit quantities. The algorithm is simple but tedious; I'm looking for a way to…
Remy
  • 401
  • 2
  • 19
13
votes
3 answers

Game Boy: What is the purpose of instructions that don't modify anything (e.g. AND A)?

I've been working on a Game Boy emulator, and I've noticed that there are certain opcodes that exist that would never change any values, such as LD A, A, LD B, B, etc. and also AND A. The first ones obviously don't change anything as they load the…
Zach Brantmeier
  • 716
  • 3
  • 8
  • 23
11
votes
1 answer

What is the behavior of the carry flag for CP on a Game Boy?

On the page 87 of the Game Boy CPU Manual it is claimed that the CP n instruction sets the carry flag when there was no borrow and that it means that A < n. This seems to conflict itself, because the carry flag is set when A > n. An example: If A=0…
Hassedev
  • 621
  • 6
  • 17
10
votes
4 answers

Z80 memory refresh register

Me again with another innocuous Z80 question :-) The way my emulator core is currently structured, I am incrementing the lower 7 bits of the memory refresh register every time an opcode byte is fetched from memory - this means for multi-byte…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
10
votes
1 answer

Length of instruction LD A,(C) in gameboy ~Z80 processor

Hello I'm writing an emulator for Game Boy. I use this reference : Gameboy CPU (LR35902) instruction set This document states that opcodes : 0xE2 LD (C),A and 0xF2 LD A,(C) have a length of 2. The Game Boy CPU Manual says that these instructions…
Demeter Purjon
  • 373
  • 1
  • 12
1
2 3
12 13