Resource centre for ZX Spectrum games
      using Manic Miner and Jet Set Willy game engines

 

Archive of the

Manic Miner & Jet Set Willy Yahoo! Group

messages

 

 

 

Message: 4405

Author: andrewbroad

Date: 21/08/2004

Subject: Re: Machine-Code

 

Alexandra wrote:

>
> Thanks for the pointers guys, though most of it is still over my
> head. I think I need to learn about opcodes, or something.

Each machine-code instruction has a mnemonic, such as LD A,n (where
n is a literal byte), and an operation-code. The op-code for LD A,n
is 62, so LD A,8 assembles to the byte-sequence 62,8.

The op-codes and their mnemonics are listed in numerical order in
the Spectrum manual, and I am lucky enough to have a book
_Introducing Spectrum Machine Code_ (Ian Sinclair, Granada
Publishing Ltd, London, 1983, ISBN 0-246-12082-7) which lists the
mnemonics and their op-codes in alphabetical order, as well as being
a good introduction to Z80 machine-code programming.

I have never used a Z80 assembler myself. I've always done it by
writing the assembler-code on paper, then looking up the op-codes in
the aforementioned book! I've never written a large machine-code
program, just little routines for MMSE and JSW CK (routines that
would be very slow in BASIC), and my hacks to the MM/JSW/JSW128 game-
engines.

RealSpectrum has a built-in disassembler, which I have found to
complement John Elliott's annotated MM & JSW disassemblies when it
comes to working out the addresses for POKEs.

It looks like I'll have to learn x86 assembler (MASM) for a project
I've been employed to work on. Frightful stuff, full of segments,
macro-definitions and suchlike monstrosities that I've never had to
worry about for Z80 machine-code! ;-)


> Basic stuff like how to PEEK and POKE in machine code etc,,..

PEEK 41983 would be written as:

LD HL,41983 ; loads the literal value 41983 into the HL register-pair
LD A,(HL) ; loads the byte addressed by HL into the Accumulator

POKE 35899,0 would be written as:

LD HL,35899
LD (HL),0

Further information:
http://www.madhippy.com/8-bit/sinclair/zxspecman/
http://www.worldofspectrum.org/Z80.html
http://makeashorterlink.com/?E2E252B19

Annotated machine-code samples can be found in the documentation for
JSW:LOTR, Goodnite Luddite, Party Willy and MM:Allana Truman.

--
Dr. Andrew Broad
http://www.geocities.com/andrewbroad/
http://www.geocities.com/andrewbroad/spectrum/
http://www.geocities.com/andrewbroad/spectrum/download/

 

 

arrowleft
arrowright