Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 340

The Zilog Z80 microprocessor. Prefer [game-boy] instead for questions about the Game Boy CPU nicknamed the ‘GBZ80’.

38 votes
Accepted

Why did the Z80 break 8080 compatibility?

The designers of the Z80 thought it would be useful for code to quickly determine whether signed arithmetic operations overflowed. … Have a "compatibility mode" flag which switches some instructions between perfect 8080 emulation and enhanced Z80 operation, along with instructions to turn it on and off. …
supercat's user avatar
  • 39.2k
31 votes

What languages are better fit for generating efficient code for popular 8-bit CPU's than C?

C can be greatly improved as a language for the 6502 and Z80, as well as micros like the PIC and 8051, if one abandons the notion that implementations must provide for recursive subroutine calls, and adds … qualifiers for things in zero page or pointers that are limited to accessing such things, and (for the Z80) adds qualifiers to identify objects that are known not to cross 256-byte boundaries. …
supercat's user avatar
  • 39.2k
28 votes

Use of undocumented opcodes

In many cases, undocumented opcodes were not deliberately created, but are merely the result of designers including the minimal circuitry necessary to create a specified set of opcodes. On the 6502, …
supercat's user avatar
  • 39.2k
23 votes
Accepted

How can a Z80 assembly program find out its own memory address?

If there are two consecutive bytes of RAM one can write at a known address, one could store the byte values E1h, E9h [POP HL / JP (HL)] at that address and then CALL it to place the address following …
supercat's user avatar
  • 39.2k
22 votes

Can the Z80 Bus Request be used as an NMI?

The purpose of NMI is to cause the Z80 to execute code located at the NMI handler. … The purpose of Bus Request is to prevent the Z80 from executing any code until whatever wanted the bus is done with it, but not affect the sequences of instructions and memory operations performed by Z80
supercat's user avatar
  • 39.2k
14 votes

Z80: asymmetric use of B in DJNZ (B is a low byte) vs. BC in LDIR (where B is a high byte)

Both memory and I/O instructions that use C as part of an address output C on the lower part of the address bus and B on the upper part (which will often be ignored by the outside system, but is outpu …
supercat's user avatar
  • 39.2k
13 votes

Why do C to Z80 compilers produce poor code?

While the Z80 is definitely an 8-bit processor rather than a 16-bit one, the instruction set makes some operations easier with 16-bit values than 8-bit values. …
supercat's user avatar
  • 39.2k
12 votes

How costly is it to put things on the stack with the Z80?

Putting automatic objects on the stack is a horribly inefficient way of handling them on the 8080 and Z80 unless it is necessary to support recursion or reentrancy. … Copying the stack pointer to IX on function entry and then using IX to access automatic objects is somewhat reasonable from a code-size perspective, but the Z80's 4-bit ALU makes it very slow to process …
supercat's user avatar
  • 39.2k
11 votes
Accepted

Why does the Z80 JP (absolute) instruction always take 10 states to execute?

If the branch is skipped, the Z80 will skip those additional calculations. When processing a JP instruction, the Z80 fetches the next two bytes and increments the program counter while doing so. … Since the Z80 isn't performing any arithmetic with the target-address bytes, making use of them once they're fetched is no more expensive than discarding them. …
supercat's user avatar
  • 39.2k
10 votes

Comparing raw performance of the Z80 and the 6502

Many operations on the 6502 take fewer cycles than corresponding operations on the Z80; the ratio tends to be somewhere between 2:1 and 4:1. … On the Z80, if the table is page-aligned, and if the address of "index" happens to be in HL--rather favorable assumptions--one may be able to get by with something like: ld d,tableH ld e,(HL) ld a,( …
supercat's user avatar
  • 39.2k
5 votes

Better way to do Z80 "bank switch & call"?

The normal way to handle cross-bank calls is to use a springboard which is either in an unbanked area of memory or appears identically in both old and new areas. If one doesn't mind using a different …
supercat's user avatar
  • 39.2k
5 votes

Does the Z80 allow interrupts after processing and ignoring a 0xdd prefix?

The Z80 increments the program counter while it is performing an opcode fetch. … As a consequence, by the time an opcode byte is fetched, the Z80 will be committed to completing the instruction before any interrupt may occur. …
supercat's user avatar
  • 39.2k
5 votes

Z80 to 68000 translator for CP/M

In addition to issues with self-modifying code, many instructions on the 68000 affect flags differently from their Z80 counterparts. … If a Z80 program does something like: ADD B LD B,A LD A,(456) RET and calling code performs a jump based on the "Z" flag, that flag would need to be set based upon whether the result …
supercat's user avatar
  • 39.2k
5 votes

Why does the Z80 include the RLD and RRD instructions?

. (*) Since writing the above, I've discovered that the Z80 uses a 4-bit ALU, and has steering logic to load/store its value from/two the upper or lower half of either half of any 16-bit register pair, …
supercat's user avatar
  • 39.2k
4 votes

Z80 string iteration failing

A handy way of outputting a string on the Z80 is to use something like: primm: ex (sp),hl primmlp: ld a,(hl) call putchar inc hl ld a,(hl) or a jr nz,primmlp ex (sp),hl ret The message …
supercat's user avatar
  • 39.2k

15 30 50 per page