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
4
votes
1 answer

GBZ80 - ADC instructions fail test

I've been running Blarggs CPU tests through my Gameboy emulator, and the op r,r test shows that my ADC instruction is not working properly, but that ADD is. My understanding is that the only difference between the two is adding the existing carry…
Triforcer
  • 127
  • 9
4
votes
1 answer

Gameboy Processor LR35902 Opcode 0x08 Meaning

Could someone please explain what the opcode 0x08 does on the LR35902 processor. The mnemonic is LD (a16),SP. I'm confused because the stack pointer is a 16-bit value but (a16) is an address to somewhere only capable of storing 8 bits (I think!). I…
user2674487
  • 113
  • 4
4
votes
1 answer

Writing memory with assembly (Z80 / Gameboy)

I'm trying to programmatically write characters into memory such that I can then display it on screen. How do I take a value (say 65) and write it into memory with Z80 assembly for the Gameboy? From what I've read this is simply a case of loading a…
Paul
  • 1,874
  • 1
  • 19
  • 26
4
votes
2 answers

Problems with Z80 Assembler

I trying to write in Z80 Assembler in a CP/M 2.2 Emulator (z80pack) in Debian: A>dir A: DUMP COM : SDIR COM : SUBMIT COM : ED COM A: STAT COM : BYE COM : RMAC COM : CREF80 COM A: LINK COM : L80 COM : M80 …
Rafa_Asp1
  • 89
  • 2
  • 8
4
votes
0 answers

I wired up a z 80 using telephone wire and put a jump to 0000 0000 0000 0000

I put 1100 0011 0000 0000 0000 0000 in the 2764 eprom --- this is supposed to test the z80 -- I have a 555 timer running at 500 khz. Can this small program work with the z80 ? I looked at the address pins on a m465 oscilloscope. The address…
john
  • 41
  • 1
4
votes
2 answers

GameBoy compiler with system registers and interrupts

I have been spending a lot of time learning GameBoy programming, as I was already familiar with Z80 Assembly I wasn't afraid of jumping into using it. I would (of course) find it much more productive to program in C or C++ however cannot find a full…
Lee Fogg
  • 775
  • 6
  • 22
4
votes
2 answers

Z80 Multibyte Commands in IM0

I'm trying just for the fun to design a more complex Z80 CP/M system with a lot of peripheral devices. When reading the documentation I stumbled over an (undocumented?) behaviour of the Z80 CPU, when accepting an interrupt in IM0. When an interrupt…
Hennes
  • 1,340
  • 1
  • 10
  • 26
4
votes
1 answer

Convert an 8bit number to hex in z80 assembler

I am writing a game for the ZX Spectrum using z80 and have a bit of a problem. I have manipulated a routine to convert a number held in the “a” register to a hex value held in “de”. I’m not sure of how to convert the other way, EG pass in a hex…
Retrocoder
  • 4,483
  • 11
  • 46
  • 72
4
votes
1 answer

Z80 Status Flag registers

This will very likely look like a very simple question to some, but when looking at the following register schema: and considering that the 'general' flag register is an 8-bit representation of the flag bits, I'm wondering: Does the 'alternate' F'…
ChristopheD
  • 112,638
  • 29
  • 165
  • 179
4
votes
3 answers

Why emulate for certain number of cycles?

I have seen in more than one places - the following way of emulating i.e cycles is passed into emulate function int CPU_execute(int cycles) { int cycle_count; cycle_count = cycles; do { /* OPCODE execution here */ }…
kofhearts
  • 3,607
  • 8
  • 46
  • 79
3
votes
1 answer

SDCC assign memory address to pointer, no effect

I've been mulling over this for the last couple of days, and i cant see what is wrong with my code. Really just looking to assign two memory addresses to two pointers. ROM at 0x0000 and RAM at 0x7000. The program compiles, but instead of writing…
eJm
  • 109
  • 2
  • 9
3
votes
1 answer

Getting "label redefined" error using local label inside an inline/einline block in VASM

First of all, this is my very first question on assembly, and I am still at the very beginning of my (hopefully long) learning journey, so forgive me if some terms are completely wrong (I hope my question at least makes some sense). I am using VASM…
umbe1987
  • 2,894
  • 6
  • 35
  • 63
3
votes
2 answers

Trying to figure out why a certain Pokemon Red/Blue glitch occurs. Why do the programmers use the sbc instruction here?

I'm trying to understand a strange bug that happens in Pokemon Red/Blue where if you try using the move Recover when you're exactly 255 hp below your max HP, the move will fail. The code I am looking at is a disassembly that can be found here. The…
Gummysaur
  • 96
  • 7
3
votes
5 answers

Quick divisibility check in ZX81 BASIC

Since many of the Project Euler problems require you to do a divisibility check for quite a number of times, I've been trying to figure out the fastest way to perform this task in ZX81 BASIC. So far I've compared (N/D) to INT(N/D) to check, whether…
vipirtti
  • 1,058
  • 4
  • 15
  • 24
3
votes
1 answer

How do I do a "greater than" jump in Z80 Assembly, rather than "greater than or equal to"?

I'm trying to learn Z80 assembly - and forgive me if this is extremely obvious - but I'm rather new to assembly as a whole. I have familiarised myself with how jumps work after making a comparison with cp and how they equate to things I know, that…
Dylanerd
  • 43
  • 4