Fair dinkum this IDE is a crock.
Sketch>Add file... does nothing if it doesn't like the file type, at least have an error message.
It seems to add a .S file but doesn't show it in a tab
I don't normally use the IDE but I want what I'm doing to be available to the general Arduino crowd and most people do I think.
Anyway it's working in a fashion. Some mods to the py script (I've never used Python before, I gather the indenting actually defines the code blocks?)
import sys, os
def asm2include(infile, outfile):
os.remove (outfile)
line = ""
with open(infile, 'r') as IN:
for line in IN:
line = line.strip(' ')
if (line != ""):
line = line.replace(' ',' ')
line = line.replace('SREG','0x3f')
line = line.replace('command','r18')
line = line.replace('temp1','r16')
line = line.replace('temp2','r17')
line = line.replace('addlo','r19')
line = line.replace('addhi','r20')
line = line.replace('ZH','r31')
line = line.replace('ZL','r30')
line = line.replace('PORTB','5')
line = line.replace('PINB','3')
OUT = open(outfile, "a")
if (line.rfind("//") == -1):
OUT.write("asm(\"")
OUT.write(line[:-1])
OUT.write("\");\n")
OUT.close()
print '.',
""" --------------------------------------------------------------
MAIN APPLICATION
"""
print "ASM2include 0.1"
asm2include(sys.argv[1], sys.argv[2])
print "Done"
It deletes the output file and makes a few substitutions, no sanity test for the file delete so a bit dangerous at present.
.equ works on an "rvalue" but not an "lvalue", hense the py script replacements.
.equ PIN_MOSI,3 // this works so don't bother with the replace
#define addhi r20 // .equ addhi,r20 doesn't work, so leave this here just for reference
Leave all comments out, not point having them in the .S version
Then in the sketch
ISR (WDT_vect, ISR_NAKED) {
#include "d:\work\atmon\atmon\atmon_isr.s"
}
So it works but is pretty fugly.
The next step is to get both a C and ASM version working and see if there's much point in the first place
Rob