User Tools

Site Tools


dave_s_zx_spectrum_exploration_notes

Dave's ZX Spectrum Exploration Notes

The ZX Spectrum was a British computer produced by Sinclair Research in the 80's, The processor is a z80 produced by Zilog, still in production and has some interesting features, such as being a Von Neumann architecture it support self modifying code. The ROM on the ZX Spectrum includes a version of BASIC, but the device can also be programmed in assembler.

Registers
high 8bit low 8bit
a f
b c
d e
h l
ix
iy

a is 8 bit accumulator hl is sort of a 16 bit accumualtor (only destination for 16bit add) b conventionally for loops : djnz is “decrement b, jump if not zero”

ld 'loads' right to left:

  • ld reg, 255 ; literal
  • ld reg, reg ; register
  • ld (reg), reg ; dereference reg
  • ld reg, (reg) ; dereference reg
  • ld reg, (ix + 3) ; array lookup

16bit pairs, bc, de, hl, ix, iy

push/pop stack - 16bits, eg:

  • push hl

arithmetic: inc, dec, add, sub, adc, sbc

wierd block processing instructions, ld, as in load, i/d inc/dec, r for repeat. each one uses bc,de and hl - bc is counter, de destination, hl source.

  LD DE,0000h
  LD HL,4000h
  LD BC,0100h
  LDIR

copies 0x100 bytes of data from 0x4000 to 0x0000.

cpir is for searching memory, bc = counter, hl = source and a is the search value

  LD HL,0000h
  LD BC,0000h
  LD A,124
  CPIR
dave_s_zx_spectrum_exploration_notes.txt · Last modified: 2014/06/19 21:50 by davegriffiths