Menu

maths functions in interrupt routime

2023-10-26
2023-10-27
  • Bernard Mentink

    Bernard Mentink - 2023-10-26

    I am having trouble with doing a 'mod' instruction in an interrupt routine. It crashes FF without a reset cause being printed to the terminal.
    The code looks like this:

    : my_int
      1 esc.seq.step  +!              \ increment step by 1, next of the seq of 6
        esc.seq.step @ 6 mod esc.seq.step !      \ modular 6 division
      ;i
    

    Any reason why this should not work? The inetrrupt is the comparator int.
    Do you have to disable comp interrupt on entry to the routine?

     
  • Mikael Nordman

    Mikael Nordman - 2023-10-26

    There was a bug in UM/MOD which is the base for all division and MOD routines. It has now been made interrupt safe.
    A fix has been uploaded.
    I recommend using a simple IF statement instead of MOD in the interrupt routine. That is much faster.

    : my_int
      1 esc.seq.step  +!              \ increment step by 1, next of the seq of 6
        esc.seq.step @ 5 > if 0 esc.seq.step ! then
      ;i
    

    If you have to use MOD I recommend using U/MOD or UM/MOD which are faster than MOD.

     

    Last edit: Mikael Nordman 2023-10-26
  • Bernard Mentink

    Bernard Mentink - 2023-10-27

    Many thanks. I had already changed to an IF..THEN
    So latest changes in github I presume. EDIT found it :)

     

    Last edit: Bernard Mentink 2023-10-27

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.