6809 Assembly programming for the Fujitsu FM-7

The FM-7 is one of a series of Fujitsu computers released in Japan

With a pair of 6809 CPU's it was widely popular in Japan, and is one of the few 6809 computers released.

In these tutorials we'll learn the about the FM7, and write some simple programs for it

Cpu Main: 2mhz 6809
Sub:  2mhz 6809 for GPU
Ram 64k Ram
48k VRam
Max Resolution 640 x 200 @ 8 colors (RGBCMYBW)

The FM-7

Hello World Example

Here is a sample file...

We've provided a Header, containing the Length and destination load address...

There is also an Exec address in the footer, however this does not actually have any effect!

The hello world example uses the PrintChar routine in the basic rom at $D08E of the FM-7 OS

StartUp File

To make our disk automatically start, we need a basic launcher.

Here we've written a BAS file, it will load machine code program "PROG" (which has a built in destination address of &H2000)

Next we execute it with an EXEC command

We need to save this as "STARTUP" (Case Sensitive)

Building our program to the disk

We need to create a binary file (with a 2b0 extension)

We use ASW to compile the program, and P2Bin to convert it to a binary.

To add a file to a disk we'll need the Ftools kit

We'll use a template disk (with our STARTUP bas) and attach the 2b0 file to it

Sending Data to the Sub CPU

The Sub CPU handles graphics drawing and key input - it's a second 6809

To control it we have to send data to it via a 128 byte shared memory block, between $FC80-FCFF ($D380-D3FF on the Sub CPU side)

To do this, we have to:
1. Wait for the Sub Cpu to not be busy (wait for Bit7 in $FD05 to equal 0)
2. Halt the Sub Cpu (set Bit 7 of $FD05 to 1)
3. Copy command data to $FC80-FCFF
4. Resume the Sub CPU (write 0 to $FD05)

The command will then be processed by the sub CPU

Commands that can be sent to the Sub CPU

There are a variety of commands that can be sent to the Sub CPU, there are some special 'secret' ones called the YAMAUCHI calls,
These allow data to be direct copied to the SubCPU and allows for execution

Yamauchi Commands Name
Purpose Data (Load into #$FC80) Returns
01 INIT Init Console DC.B unused,unused
DC.B $01,Background
DC.B Widh,Hei (80/40,25/20)
DC.B ScrollStart,ScrollEnd
DC.B SHowFunctions,ClearScreen,GreenScreen

02 ERASE Clear screen DC.B unused,unused
DC.B $02,Mode (0-3),Color

03 PUT

04 GET


06 Get Character Block 1

07 Put Character Block 1

08 Get Character Block 2

09 Put Character Block 2

0A Get Buffer Address

0B Tab Set

0C Console Control

0D Erase 2

20 Character Line

15 Line
dc.b unused,unused
dc.b $15,color,operation
dc.w StartX,StartY,EndX,EndY
dc.b mode (line,square,filled)

16 Chain

17 Point

18 Paint

19 Symbol

1A Change Color

1B Get Block 1

1C Put Block 1

1D Get Block 2

1E Put Block 2
dc.b unused,Multiblock (128=Y)
dc.b $1E
dc.w StartX,StartY,EndX,EndY
dc.b Unused, Function, Bytes
dc.b pixel,pixel,pixel....

1F Graphics Cursor

29 Inkey
DC.B unused,unused
DC.B $29,Option(Bit0=Wait,Bit1=Reset)
DC.B ErrorCode,Unused,Unused
2A Define String of PF

2B Get String of PF

2C Interrupt Control

3D Set Timer

3E Read Timer

3F YAMAUCHI END End command sequence DC.B unused,unused

3F YAMAUCHI CALL Call program in sub cpu ram DC.B unused,unused
DC.W {address}
DC.B $90

3F YAMAUCHI MOVE transfer data in sub cpu DC.B unused,unused
DC.W {FromAddrInSub}
DC.W {ToAddrInSub}
DC.W {LengthInBytes}
DC.B $90

75 Continue Send more data (Put Block) dc.b unused,Multiblock (128=Y)
dc.b $64;Continue
dc.b pixel,pixel,pixel....


View Options
Default Dark
Simple (Hide this menu)
Print Mode (white background)

Top Menu
***Main Menu***
Youtube channel
ASM Programming Forums
Dec/Bin/Hex/Oct/Ascii Table

Z80 Content
***Z80 Tutorial List***
Learn Z80 Assembly
Hello World
Advanced Series
Multiplatform Series
Platform Specific Series
ChibiAkumas Series
Grime Z80
Z80 Downloads
Z80 Cheatsheet
DevTools kit
Z80 Platforms
Amstrad CPC
Elan Enterprise
Gameboy & Gameboy Color
Master System & GameGear
Sam Coupe
ZX Spectrum
Spectrum NEXT
Camputers Lynx

6502 Content
***6502 Tutorial List***
Learn 6502 Assembly
Advanced Series
Platform Specific Series
Grime 6502
6502 Cheatsheet
DevTools kit
6502 Platforms
Apple IIe
Atari 800 and 5200
Atari Lynx
BBC Micro
Commodore 64
Commander x16
Super Nintendo (SNES)
Nintendo NES / Famicom
PC Engine (Turbografx-16)
Vic 20

68000 Content
***68000 Tutorial List***
Learn 68000 Assembly
Platform Specific Series
Grime 68000
68000 Cheatsheet
DevTools kit
68000 Platforms
Amiga 500
Atari ST
Neo Geo
Sega Genesis / Mega Drive
Sinclair QL (Quantum Leap)
X68000 (Sharp x68k)

8086 Content
Learn 8086 Assembly
8086 Cheatsheet
DevTools kit
8086 Platforms

ARM Content
Learn ARM Assembly
ARM Downloads
ARM Cheatsheet
DevTools kit
ARM Platforms
Gameboy Advance
Risc Os

Risc-V Content
Learn Risc-V Assembly
Risc-V Downloads
Risc-V Cheatsheet
DevTools kit

PDP-11 Content
Learn PDP-11 Assembly
PDP-11 Downloads
PDP-11 Cheatsheet
DevTools kit

My Game projects
Chibi Aliens
Chibi Akumas

Work in Progress
Learn 6809 Assembly
Learn 65816 Assembly
Learn 6809 Assembly
Learn TMS9900 Assembly
Dragon 32/Tandy Coco
Fujitsu FM7
Ti 99

Misc bits
Ruby programming

Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!

Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!

Buy Chibi Akuma(s) from PolyPlay
Buy ChibiAkuma(s) games now!