Motorolla 68k Assembly


Mucking around on the Megadrive learning by doing on linux, starting from zero

No sure how far this will go .... 



- MAME (0.227 debug)
- asmx (2.0b5)
- (megadrive) init.asm from

Assuming you have a build environment for c (e.g build-essentials meta package 
on debian)

Compile asmx
- Download
- Unpack and cd asmx-2.0b5/
- Edit the Makefile and comment out the default TARGET line
- Buld the sources ./make
- cp ./src/asmx to a location in your PATH (e.g /usr/local/bin)

The basic workflow from here on out is pretty simple
- Create the directory structure including init.asm
- Write you Assembly code
- Build a Megadrive ROM with asmx
- Run the rom in MAME with debugger



Basic Movement

The most basic of all operations we can do here is _not_ writing Hello World
to the screen as per every other language. Here we will do very basic data
movement by defining the simplest program we can to update a data register in

Setup the projects directory
- create a project_dir
- download init.asm to project_dir

Create the Assembly source file

; source example
; ----------------------------------------------
; Assembly 68k basic data manipulation
; insert a value into a data register
 include 'init.asm'
  move.b #1, d0         ; put 1 (byte) into data register 0
; ----------------------------------------------

- note: the whitespace before include, when i work out why *** UPDATE THIS***
- save this program as basic_movement.asm in project_dir

Build a Megadrive ROM with asmx
- build the rom
  $ asmx -C 68000 -e -w -b 0 -l basic_movement.lst -o basic_movement.bin -- basic_movement.asm

Run the rom in MAME with debugger
You will now run the built rom in MAME with the debugger enabled to watch the 
data register be updated, there is no fancy graphics here.

$ mame genesis -cart /basic_movement.bin -debug

The rom will load and the debugger will sit idle waiting for an instruction
from you.

Note the pane on the left hand side of the debugger screen, this is the

note the value of d0

Press F5 to run to the end of the current program.

Once the program run has completed you will see a value of 1 against d0

Data Movement with Subroutines