@echo off

if exist %1.s goto compile
goto error

:compile
echo --compiling assembler file '%1.s'
as %1.s -m68332 --register-prefix-optional -I%gcc%\include -I%mc%\include -o %1.o

echo --linking
ld -T%mc%\ldfiles\robi-ram.ld -L%mc%\lib -o %1.I %1.o -lmym -lmyc -lmygcc -lrobi

echo --object copy
objcopy -O srec %1.I %1.hex

echo --compessing '%1.s'
srec2bin $1.hex >NUL


if exist %1.o del %1.o
if exist %1.I del %1.I
goto end

:error
echo Error: file '%1.s' not found!

:end
@echo on
