|Best practice for writing an "action listener" (or a "flag")
|Page 1 of 1|
|Author:||skiingxmoose [ Sun May 18, 2014 8:24 pm ]|
|Post subject:||Best practice for writing an "action listener" (or a "flag")|
I am making a program that has a main loop and an IRQ (An iterrupt request that is called when the mouse is clicked). I would like to have the IRQ only change a "flag", or a boolean, that can be checked before each loop to check and see if a mouse was clicked. The following code shows my current implementation:
IF d2.b <eq> #255 THEN
bsr mouseClick ;Do stuff
neg.b d2 ;Turn the flag back off <---------
neg.b d2 ;Turn the "flag" on <---------
I am wondering however if there is a more intuitive manner to do this. Is there for example, a method to use less space in a register, a method that doesn't require as demanding a check (Is there an alternative to if <eq>)? Is this the standard practice for writing an "action listener"?
EDIT: I just found out that I can declare flags in memory if I wanted to have a lot of them! I can use ds.b to define a byte sized "flag". This is helpful. I am curious however if there are downsides to using flags in memory vs. flags in a register.
This is a very open ended question, so if anyone has any comments on how I should generally go about this I would love to hear your thoughts.
|Author:||profkelly [ Wed May 21, 2014 2:26 pm ]|
|Post subject:||Re: Best practice for writing an "action listener" (or a "fl|
I always place the flags in memory. We do not know when an interrupt may occur so we don't want the interrupt handler to change any of the registers that might be in use by another routine.
|Page 1 of 1||All times are UTC|
|Powered by phpBB® Forum Software © phpBB Group