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

Why using char type as index for looping gives unexpected results?

Bear in mind this is an old version of the C compiler: CP/M for Z80. #include main() { char i = 0; do { printf("0x%04x | ", i); } while (++ i); } Expected: 0x0000 | 0x0001 | 0x0002 | 0x0003 | 0x0004 |…
vDom
  • 53
  • 3
3
votes
1 answer

What algorithms and/or patterns to use for an In-Circuit Processor Emulator (Z80)

For my electronics hobby where I make a Z80 computer system, I am building a Z80 in-circuit emulator. The idea is that the physical Z80 chip is removed from the circuit and the emulator is inserted in its socket and emulates the Z80 precisely.…
obiwanjacobi
  • 2,413
  • 17
  • 27
3
votes
1 answer

Z80: Copying from Top of Stack to HL

This can be accomplished by: 11 pop hl 10 push hl in 21 cycles. The only alternative I have found is ex (sp),hl, which takes 19 cycles. The downside is that the contents must be exchanged to their original values once I'm done with them, so in…
user8277088
3
votes
1 answer

Z80 register pairs

I am fairly new to the Z80 and machine code, so please don't assume I know anything. Basically, what I want to know is this: If you load register H with a value (I'll call it y), will HL then be 0xy0? e.g. if H was loaded with 0xAF would HL be…
Jachdich
  • 782
  • 8
  • 23
3
votes
4 answers

Too many types conversions in a Z80 emulator in Ada

I am doing a Z80 emulator in Ada. I am implementing the JR (Jump relative) family, But I am not satisfied with my code: with Ada.Text_IO; procedure main is type UInt16 is mod 2 ** 16; type UInt8 is mod 2 ** 8; type Int8 is range…
ols
  • 173
  • 7
3
votes
1 answer

How Do I Create a Variable In Z80 Assembly?

I'm trying to create a simple variable containing the hex value 0xffff. I've been able to do it as a macro with SET, but I haven't been able to get it working with something like ld _time,$ffff. How do I load a value into _time?
user6238236
3
votes
3 answers

Are bytes/words/addresses signed or unsigned in Z80 assembler/machine code?

I am making an emulator for Z80 binaries but I cannot find out whether all the integer data types are signed or unsigned from the manual or from google. So are the numbers from registers A,B...HL,BC etc signed or not? Also, in machine code are the…
Callum Rogers
  • 15,630
  • 17
  • 67
  • 90
3
votes
2 answers

How do I do bcalls in hex?

So I have a TI-84 Plus C Silver Edition. I just started working on writing assembly programs on it using the opcodes. I found a good reference chart here, but was wondering how to do bcalls, specifically how to print a character to the screen. It…
fuzzything44
  • 701
  • 4
  • 15
3
votes
1 answer

Multiplying two bytes representing a short by 1.5

I was looking at some assembly code and came across the following (which I've converted for ease of the reader). All registers are 8 bits, and pointers are 16 bits. So (q) loads 8 bits. (q+1) = (q+1) = rr(q+1) where (q) dereferences q and rr(q) is…
Jason
  • 1,297
  • 12
  • 24
3
votes
2 answers

Bug with power-of-two multiplication in GBDK compiler

I'm currently developing a gameboy emulator and to test the correctness of my emulator I'm using GBDK to compile c programs for my emulator. I noticed that the compiler (as expected) optimizes multiplications with constants that are a power of two…
monoceres
  • 4,722
  • 4
  • 38
  • 63
3
votes
9 answers

Equivalents to Z80 DJNZ instruction on other architectures?

First a little background. The z80 CPU has an instruction called DJNZ which can be used in a similar manner as a for loop. Basically DJNZ decrements the B register and jumps to a label if not zero. For example: ld b,96 ;…
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
3
votes
2 answers

Z80 Overflow in with DAA

I'm writing a Z80 emulator and am stuck trying to understand what the decimal adjust instruction does for certain operands. What is the result (in registers A & F) of these opcodes on a real Z80? LD A,1h ADD A,99h DAA My code currently finished…
axle_h
  • 553
  • 1
  • 5
  • 16
3
votes
3 answers

Dereferencing C vs Assembler

Studying pointers: Can we say that asterisk operator * in C is analog to parenthesis in assembler of Z80? In other words, are this two sentences have similar meaning: LOAD (HL),a; VS *HL=a;
Ilan
  • 401
  • 1
  • 8
  • 21
3
votes
1 answer

Z80 DAA flags affected

In the following link, http://www.z80.info/z80syntx.htm#DAA I got confused over the condition for setting H flag. The description says to look at the table but unlike C where there is the column C after DAA, for H there is only H before DAA... So,…
kofhearts
  • 3,607
  • 8
  • 46
  • 79
3
votes
2 answers

Designing a boot loader for simple Z80 system via UART, Where To Load the Program

I've started writing a boot loader for my z80 system. So far the program can accept hex via serial and load it to a location in the memory. The problem I have though is the boot loader is at the start of memory and uses the interrupts, How can I…