Arduino and Assembler
hi all,
i wanted re-use assembler code (in .s file). after searching forum , not finding how it, came following solution.
i wonder if there's way avoid writing libraries folder.
1. create folder in libraries, let's "routinesasm"
2. inside folder create file "routinesasm.h" containing like:
3. inside folder create file "routinesasm.s" containing assembler routines, like:
4. sketch must include .h file, like:
that's it... won't work if .h , .s files in same folder .pde sketch.
any suggestions?
i wanted re-use assembler code (in .s file). after searching forum , not finding how it, came following solution.
i wonder if there's way avoid writing libraries folder.
1. create folder in libraries, let's "routinesasm"
2. inside folder create file "routinesasm.h" containing like:
code: [select]
extern "c" {
void increment_a_number(void);
}
3. inside folder create file "routinesasm.s" containing assembler routines, like:
code: [select]
#include <avr/io.h>
.extern a_number
.global increment_a_number
increment_a_number:
push r16
lds r16, a_number
inc r16
sts a_number, r16
pop r16
ret
4. sketch must include .h file, like:
code: [select]
/*
program: test arduino , assembler
autor: [iard]
date: 2010-06-09
*/
#include <routinesasm.h>
volatile int a_number;
// load variable ram , not storage register
extern void increment_a_number(void);
void setup() {
serial.begin(9600);
}
void loop() {
a_number = 5; // initial value
serial.print("initial number = " );
serial.println(a_number);
increment_a_number(); // call assembler routine
serial.print("incremented number = " );
serial.println(a_number);
delay(1000);
}that's it... won't work if .h , .s files in same folder .pde sketch.
any suggestions?
hi,
i think problem lies in compiler looks include files. think you'd have modify compile scripts include .pde folder well.
i think problem lies in compiler looks include files. think you'd have modify compile scripts include .pde folder well.
Arduino Forum > Forum 2005-2010 (read only) > Software > Development > Arduino and Assembler
arduino
Comments
Post a Comment