Pito, > The example could be the timer int routine: > : tick_isr _one timer 2@ d+ timer 2! ; > which does "timer = timer + 1" where timer is double integer. I've > seen usart routines and Lubos' routines in asm, however generaly the > Q: > > 1. is there any recommended structure or frame for writing assembler > words
Just look at Lubos' examples. He has written quite a lot (e.g. for sd card access via SPI or optimized bit level access) > 1a. is there any recomemnded structure or frame for writing > assembler interrupt handlers A definition starts with "code", which creates the dictionary entry. Everything else need to compile real machine code, the last instruction has to be end-code, which compiles the jump instruction back to forth. Everything in between is yours, completly. > 2. how the data from data stack (or from return stack) are passed to > assembler > 3. how the data are passed from asm. back to data stack or return > stack > 4. how the external variables (defined as words) are accessed from > assembler > 5. how the data stack is duped or droped from assembler The assembler has full control once the code is started. And the full responsibility to keep everything intact. If you modify vital registers, you may crash the system easily. > 6. what shall be poped and pushed in asm. routine (when entering and > leaving it) > 7. how the asm return stack is handled (imagine we need nested calls > in asm) > 8. how the ram, eprom can be accessed from asm RAM is easy: there are machine instruction like ld and st (with variants). I'd recommend studying the atmel assembler document (doc0856.pdf) from there website. There are >>100 different instructions available. Everything else is increasingly complex, you can read (and duplicate) the code from the words/*.asm files, there are some code words. > 9. how the asm code shall be compiled (? via LP's asm or via > avrasm.) I use the avrasm. Lubos' assembler has been checked to work correctly so I think its a matter of taste: flashing a completly new hex image or using the terminal prompt. YMMV Matthias ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ Amforth-devel mailing list Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel