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
10
votes
3 answers

Z80 ASM BNF structure... am I on the right track?

I'm trying to learn BNF and attempting to assemble some Z80 ASM code. Since I'm new to both fields, my question is, am I even on the right track? I am trying to write the format of Z80 ASM as EBNF so that I can then figure out where to go from there…
Gary Paluk
  • 1,038
  • 1
  • 14
  • 28
10
votes
3 answers

Writing a Z80 assembler - lexing ASM and building a parse tree using composition?

I'm very new to the concept of writing an assembler and even after reading a great deal of material, I'm still having difficulties wrapping my head around a couple of concepts. What is the process to actually break up a source file into tokens? I…
Gary Paluk
  • 1,038
  • 1
  • 14
  • 28
9
votes
3 answers

Java timing accuracy on Windows XP vs. Windows 7

I have a bizarre problem - I'm hoping someone can explain to me what is happening and a possible workaround. I am implementing a Z80 core in Java, and attempting to slow it down, by using a java.util.Timer object in a separate thread. The basic…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
8
votes
3 answers

Undocumented 16-bit I/O addressing on Z80

I notice from the Zilog datasheet on the Z80 that with the I/O (IN and OUT) group of instructions, the contents of various registers are often placed in the top 8 bits of the address bus (depending on the instruction), with the lower 8 bits…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
8
votes
1 answer

Z80 division algorithm not functioning properly

I am attempting to run the following code: HLDIVC: LD B,16 D0: XOR A ADD HL,HL RLA CP C JR C, D1 INC L SUB C DJNZ D0 D1: RET It's an adaptation of the original code: (found here) HL_Div_C: ;Inputs: ; HL is the…
Shades
  • 667
  • 1
  • 7
  • 22
8
votes
4 answers

How to write two bytes to a chunk of RAM repeatedly in Z80 asm

I'm trying to write two bytes (color values) to the VRAM of my TI-84 Plus CE-T calculator, which uses the Zilog eZ80 CPU. The VRAM starts at 0xD40000 and is 0x25800 bytes long. The calculator has a built in syscall called MemSet, which fills a chunk…
melbok
  • 95
  • 7
8
votes
1 answer

Is the Z80 NMI reentrant?

From what I could gather the Z80 NMI interrupt (0x66) is triggered from an edge detection of the NMI pin. What happens when another edge is detected when still inside the NMI handler code (RETN has not executed yet)? Is NMI reentrant and will the…
obiwanjacobi
  • 2,413
  • 17
  • 27
7
votes
2 answers

GBZ80: How does LD HL,(SP+e) affect H and C flags?

On Gameboy Z80, exactly how does the LD HL,(SP+e) operation affect H and C flags? (Half-carry + carry) Reference: http://www.devrs.com/gb/files/opcodes.html
Johan Kotlinski
  • 25,185
  • 9
  • 78
  • 101
7
votes
1 answer

Z80 assembly: How to add signed 8-bit value to 16-bit register?

I've written a Z80 disassembler that runs from the ROM in my SBC. One of the last things I need to do (as-yet-unspotted bugs aside) is to translate relative addresses and output them as absolute addresses, so that when the disassembler hits one of…
nockieboy
  • 347
  • 1
  • 3
  • 14
7
votes
1 answer

How to setup a mixed C / Z80-assembler toolchain in Visual Studio Code

I want to use Visual Studio Code for writing code for my homebrew Z80 Computer. I use z88dk and its tools to compile C, assemble the Z80 asm files etc. I will write parts in assembler and other parts in C. I also need to edit .m4 files. Would be…
obiwanjacobi
  • 2,413
  • 17
  • 27
6
votes
3 answers

Question about cycle counting accuracy when emulating a CPU

I am planning on creating a Sega Master System emulator over the next few months, as a hobby project in Java (I know it isn't the best language for this but I find it very comfortable to work in, and as a frequent user of both Windows and Linux I…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
6
votes
1 answer

Could anything with a Z80 processor run Gameboy games?

Since the Gameboy's processor, the LR35902, is a hybrid of the Z80 and the Intel 8080, keeping in mind that the Z80 and the Intel 8080 were designed to be mostly cross-compatible anyways, could anything that has a Z80 processor run opcodes that were…
Veecy
  • 63
  • 1
  • 4
6
votes
2 answers

What exactly is a machine cycle?

I'm kinda confused about the exact definition of a "machine cycle". For example, some source online say that it is: The four steps which the CPU carries out for each machine language instruction: fetch, decode, execute, and store. While the book…
Abdelrahman Eid
  • 881
  • 2
  • 13
  • 28
6
votes
2 answers

Z80 Software Delay

I am trying to create a software delay. Here is a sample program of what I am doing: Address Data Opcode Comment 1800 06 LD, B Load register B with fix value 1801 “ “ Fixed value 1802 05 DEC,…
user3178205
  • 65
  • 1
  • 7
5
votes
2 answers

half-carry/half-borrow flag in DAA instruction

Apologies for making this my second Z80 DAA question - I have pretty much implemented this instruction now, but there is one thing I'm not sure about - is the H flag set by this instruction at all? The Z80 manual says 'see instruction', but it only…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
1
2
3
12 13