MSX Page

Avelino Herrera Morales



By this page i want to offer my MSX projects to the community. Sorry about my poor english writting. I am spanish :-)

SDCC backend for MSXDOS

The SDCC is a cross-compiler for small devices that runs in Windows and in Unix/Linux platforms, that allows you to generate code for a large variety of 8-bit and 16-bit platforms. Among these plataforms we have the Z80 and the Z80 with GameBoy extensions (GBZ80).

The Z80 code that SDCC generates by default is not MSX targeted and the final output is always an IntelHex file with the code. With this backend modification for MSXDOS we will be able to easily convert these IntelHex output files into .COM files. The system requirements for cross-compiling are (for both Windows/Unix/Linux platforms):

Both packages can be installed from binaries or sources. The basic files needed to generate .COM MSXDOS executables are:

First we have to do is to assemble the .s previous files and to compile the .c previous files using the sdasz80 assembler and the sdcc compiler included in SDCC package:

We obtain 11 object files with .rel extension and same name. Let's write a small C sample code for testing ej.c:

#include "conio.h"
#include "dos.h"

void main(void) {
    puts("Hello, world :-)\r\n");

That we compile this way:

$ sdcc -mz80 --code-loc XXXX --data-loc 0 --no-std-crt0 crt0msx_msxdos.rel putchar.rel getchar.rel dos.rel conio.rel ej.c

One notice the --no-std-crt0 parameter, that indicates the compiler that should not use the default startup code for Z80, but we provide by command line. XXXX indicates code location: for crt0msx_msxdos.s XXXX = 0x0107 and for crt0msx_msxdos_advanced.s XXXX = 0x0178. Global variables will be allocated just after code.

If there are no compile-time errors, among the output files we should have the ej.ihx IntelHex file. Now we process this file with the hex2bin tool to obtain a binary code:

$ hex2bin ej.ihx

After this command we should have a ej.bin in the current folder, that we can rename directly to and execute it in our MSX:

$ mv ej.bin
Usage examples
Additional files
Additional info and related sites

SDCC backend for MSX ROMs

The main difference between building COM and ROM files for MSX with SDCC is basically the crt0 code. I recommend to read the previous section.

In the Nerlaska's MSX web there are a lot of info about this topic. Both Alberto Orante and I will contribute with additional code for building ROMs using SDCC. Here this is a modification of the MSXDOS interrupt routines by Alberto.

Additional info and related sites

Moonsound programming

In this section I will publish all the Moonsound related C code builded or adapted by me. All the current published codes are related to two articles appeared in the Call MSX spanish magazine about the MSX scene (numbers 3 and 4). These two articles are about Moonsound programming and all the source codes are spanish commented (sorry for the inconvenience).

Huffman compression

In this section I will put all my work related to Huffman compression implementation for MSX.

huffman.tar.gz contains an ANSI-C implementation of the Huffman compression/uncompression algorithms. This archive also contains an specific MSX implementation of the uncompress algorithm for the SDCC compiler. This MSX targeted version requires:

Read the README at huffman/msx subfolder for further details.


In this section I will put source code, tools and data related to VDP programming.


PSG programming: tools and source code.

Fixed point

Fixed point math related section. For Z80 and/or MSX specific.


Creative Commons License

This work is licensed under a Creative Commons License.

Page maintained by Avelino Herrera Morales