Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
development_tools [2023/04/23 11:32] – [Graphics] pulkomandydevelopment_tools [2024/05/06 16:37] – Update current status of VBCC and VASM pulkomandy
Line 1: Line 1:
 ====== C compilers ====== ====== 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 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
  
-µ'nSP IDE is the official IDE for the CPU used. It can still be downloaded from [[https://www.generalplus.com/1LVlangLNw6SVw7SNservice_n_support_d|GeneralPlus website]] - {{ ::unspide_v4.0.1.zip |local copy}}+  * µ'nSP IDE is the official IDE for the CPU used. It can still be downloaded from [[https://www.generalplus.com/1LVlangLNw6SVw7SNservice_n_support_d|GeneralPlus website]] - {{ ::unspide_v4.0.1.zip |local copy}} 
 + 
 +===== 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. 
 + 
 +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 ====== ====== Assemblers ======
  
-XASM is the original assembler provided by the µ'nSP IDE+===== 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. 
 + 
 +===== naken_asm =====
  
 [[https://github.com/mikeakohn/naken_asm/|naken_asm]] has support for µ'nSP and provides a standard include file for SPG200 registers. [[https://github.com/mikeakohn/naken_asm/|naken_asm]] has support for µ'nSP and provides a standard include file for SPG200 registers.
  
-Work in progress [[http://pulkomandy.tk/drop/0001-Start-work-on-adding-uNSP-support.patch|patch]] to add µ'nSP support in [[http://sun.hasenbraten.de/vasm/|vasm]]. There are problems in vasm handling the pure 16-bit CPU, I have asked the vasm developers for help solving that.+This is a simple assembler that directly provides a binary fileIt 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 ===== 
 + 
 +[[http://sun.hasenbraten.de/vasm/|vasm]] is a retargettable assemblerIt 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: 
 + 
 +- In daily source snapshots from vasm homepage, 
 +- In [http://pulkomandy.tk/gerrit/plugins/gitiles/vasm|PulkoMandy's Git repository] for the latest work in progress (not always already included in vasm source snapshots). To get it using git: ''git clone http://pulkomandy.tk/gerrit/plugins/gitiles/vasm'' and use the unsp branch. 
 + 
 +===== Others =====
  
 This [[https://github.com/vsmile-dev/vsmile-rom|early homebrew experiment]] took an interesting approach of not using an assembler at all. This [[https://github.com/vsmile-dev/vsmile-rom|early homebrew experiment]] took an interesting approach of not using an assembler at all.
development_tools.txt · Last modified: 2024/05/06 18:20 by pulkomandy
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0