Simple doubt about assembly use into TIM2 ISR
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2009-05-25 2:37 AM
Posted on May 25, 2009 at 11:37
Simple doubt about assembly use into TIM2 ISR
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:03 AM
Posted on May 17, 2011 at 15:03
Hi All,
Excuse me for my bad english. Moreover sorry for this very stupid question: I'm only newbie! :) I have just noticed that in some STM8S firmware library examples the TIM2 ISR contains this code: #asm xdef _GTimeStamp inc _GTimeStamp + 3 jrne endinc_tbu inc _GTimeStamp + 2 jrne endinc_tbu inc _GTimeStamp + 1 jrne endinc_tbu inc _GTimeStamp endinc_tbu: #endasm Anyone know (and can share with me) the reason why the developer choose to coded it in Assembly? A simple GTimeStamp++; isn't enough? Thanks! Ciao, AlessioOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:03 AM
Posted on May 17, 2011 at 15:03
Hi,
the C version would give the same result, but with a slower execution (because the compiler calls a general function that adds 1 to a long value). I guess the developer wanted this specific operation (increment by 1) to execute as fast as possible because it happens very often... On a side note, note that this kind of variable (long) is not atomic on the stm8 -> every time there is an access to it interrupts should be disabled.