Research / Megadrive Programming / Basics

Genesis has one CPU called 68000 (68k for short). It understands a set
of 16-bit instructions, which are called machine code (like 4E75, 31FC
etc.). But programming in hexes isn't very easy (well, it's not
impossible... few years ago I programmed only using machine code =P),
so nifty programmers made the assembly language. There is a program
(assembler) which assembles this to machine code. Assembly is a bit
more humanized. It's not BASIC, but it's not hard. I will try to make
you understand this. I can't guarantee that it will be interesting =P


Genesis has 64kb of RAM. You can store everything there. There is a VDP
(graphics CPU) which controls graphics =P It has 64k of RAM (called
VRAM - Video RAM), which can store patterns, sprites atributes, scroll
data etc.



Here's a map of 68k memory:




$000000-$3FFFFF - ROM

$400000-$9FFFFF - Unused


$A00000-$A0FFFF - Z80

$A10000-$A1001F - I/O

$A10020-$BFFFFF - Miscellaneous

$C00000-$C0001F - VDP

$C00020-$DFFFFF - VDP mirrors


$E00000-$FFFFFF - RAM (it repeats each $10000, so $E00000 is the same as $E20000 and $FF0000. Most games use $FF0000-$FFFFFF)



There are three data types. Byte, word (2 bytes) and longword (4
bytes). There is no unsigned or signed types like in C, because each
data type can be treated as unsigned or signed. There are 16 registers
which store temporary data (kinda like variables). Each one is a
longword. There's 8 data registers called D0-D7 and 8 address registers
(A0-A7). You should use A0 to A6, because A7 is the stack pointer (I'll
tell you about it later). Hey, but what's the difference between
address and data registers? Data registers store data, and address
registers usually store pointers to some location in RAM. For example, address registers can be incremented or decremented.


68000 stores data in Big Endian way. So longword $12345678 is stored
$12,$34,$56,$78 in memory, compared to Little Endian $78,$56,$34,$12.
x86 and Z80 use Little Endian. Z80 is for the music stuff... (x86 is
the CPU in your PC)



Don't worry if you don't get something or you forget all this stuff. You will get used to it.

Back | Printer friendly
2. Let's start >>

© 2004, 2005 drx, www.hacking-cult.org. Don't copy without permission yadda yadda yadda.