User Tools

Site Tools


compiling_the_midibox_source_on_linux

This is an old revision of the document!


About this document

For all assembler-based applications, MPLAB is needed, that's only available for Windows (or Linux via Wine). But there is a solution, described below, with which you can compile asm code with MPASM, a tool that's available not only for Linux, but as well for Macs! Thanks to svens for sharing this!

Compiling MIOS on Linux

If you ever tried to compile the MIOS source with gpasm on Linux, you've probably got a lot of errormessages like:

svens@deprecated(1033)[0]:./src2$ gpasm main.asm
mios_isr.inc:76:Error [103] syntax error
mios_isr.inc:77:Error [103] syntax error
mios_isr.inc:78:Error [103] syntax error
mios_isr.inc:80:Error [103] syntax error
mios_isr.inc:81:Error [103] syntax error
mios_isr.inc:84:Error [103] syntax error
mios_isr.inc:133:Error [103] syntax error
mios_isr.inc:138:Error [103] syntax error
mios_isr.inc:174:Error [103] syntax error
mios_isr.inc:205:Error [103] syntax error

These errors are caused by a nice Feature from mpasm – you can pass instructions as Macro argument. Unfortunately, gpasm has (at least right now) no support for this, so i wrote a small quick&dirty script, that changes all these MACROs to the appropriate syntax. To use this script, copy the following files in your mios_v_1_x_src dir:

replace-macros.sed:

1i;hey emacs, this is -*- asm -*-
/^[ \t]*;/b #skip commented line
/^\s*\w*\s*MACRO/b #skip macro definitions
s/\<BIFSET\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\([^,]*\)\s*,\s*\(.*\)/btfsc \1, \2, \3\n\t\4/g
s/\<BIFCLR\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\([^,]*\)\s*,\s*\(.*\)/btfss \1, \2, \3\n\t\4/g
s/\<IFSET\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\(.*\)/btfsc \1, \2\n\t\3/g
s/\<IFCLR\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\(.*\)/btfss \1, \2\n\t\3/g
s/\<IFNEQ\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\(.*\)/cpfseq \1, \2\n\t\3/g
s/\<IFLEQ\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\(.*\)/cpfsgt \1, \2\n\t\3/g
s/\<IFGEQ\s*\([^,]*\)\s*,\s*\([^,]*\),\s*\(.*\)/cpfslt \1, \2\n\t\3/g
s/\<rgoto\>/bra/g

fix-gpasm.sh:

#!/bin/sh

for i in src/*.inc src/*.asm src/*.h;do 
    tr -d '\r' < $i|sed -f replace-macros.sed >${i}_ && mv ${i}_ $i
done

Now you can run ./fix-gpasm.sh, which replaces all the problematic macros.

compiling_the_midibox_source_on_linux.1160904901.txt.gz · Last modified: 2007/01/13 14:40 (external edit)