C compilers

Official compiler

SunPlus released sources for the C compiler. It doesn't include the assembler and is based on GCC 2.95 so quite hard to compile: https://github.com/vsmile-dev/unsp-gcc

VBCC

Work in progress port of vbcc: http://pulkomandy.tk/gerrit/plugins/gitiles/vbcc/+/refs/heads/unsp

This uses the very latest version of vasm and vlink.

The code generation is unoptimized at the backend level currently. This means the frontend of the compiler can do some general, high level optimizations, but it is not able to make use of any of the CPU advanced features.

See VBCC for info on how to set up a development environment.

Here is a TODO list for optimizations:

  • The code generation often needs to allocate a temporary register for some computation. When there is no other register available, one of the already used ones is PUSHed to the stack and then POPed back at the end. When this happens several times in a row, there can be a sequence of POP R1 (end of a sequence using R1 as a scratch register), then PUSH R1 (start of another seauence), then LD R1, … (actually making use of the register). The POP/PUSH in this case is useless and should be removed. This can be done either at the “peephole” level (after the code has been generated), or by attempting to move “allocreg” and “freereg” ICs (sometimes they are not as close as they should to actual use of the register).
  • Post-increment is not generated directly by the compiler. Instead, there will be separate ICs to dereference the pointer, and then to increment it. These sequences should be identified and replaced with the appropriate instruction.
  • VBCC emits a specific IC “test” when it needs to do a comparison. Sometimes this is useful, but sometimes (especially when testing if a value is 0) the previous instruction loading or storing that value will have already set the compiler flags, and there is no need to do it again. So, the 'test' IC can generate nothing if the previous IC has already set the flags to the right value.

Assemblers

XASM

XASM is the original assembler provided by the µ'nSP IDE. It uses an unusual syntax compared to assemblers for other systems. For example, an addition to a register is written in this form:

R1 += 7

This is the syntax also used in the MAME debugger and some other disassemblers, but it is not convenient to include in other tools. For this reason, other assemblers use a more standardized syntax.

un-asm

un-asm implements the original XASM syntax. It is a very simple assembler (no macros, no expression evaluation) but it is usable when you need to have the XASM syntax.

naken_asm

naken_asm has support for µ'nSP and provides a standard include file for SPG200 registers.

This is a simple assembler that directly provides a binary file. It is not possible to use it to generate multiple object files to feed into a linker. But other than that, it is a well-tested and well documented assembler and works reliably.

vasm

vasm is a retargettable assembler. It is part of the vbcc compiler suite but usable separately.

It can emit binaries directly, or also generate temporary object files (in its custom vobj format) for use with the vlink linker. This allows to use the assembler in the context of a C compiler toolchain. Of course the assembler can be used standalone or together with the linker as well.

Due to the 16-bit-only addressing of the µ'nSP architecture, several changes were needed in vasm to handle it correctly. This will be released in vasm 2.0 when it is fully tested and stabilized. Until then, vasm with µ'nSP support is available:

Others

This early homebrew experiment took an interesting approach of not using an assembler at all.

Emulators

Graphics

development_tools.txt · Last modified: 2024/05/06 16:20 by pulkomandy
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0