EASy68K  
It is currently Tue Nov 21, 2017 9:24 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun May 18, 2014 8:24 pm 
Offline

Joined: Wed May 07, 2014 11:16 pm
Posts: 5
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:

Code:
mainLoop
    IF d2.b <eq> #255 THEN
        bsr mouseClick    ;Do stuff
        neg.b   d2          ;Turn the flag back off <---------
    ENDI
       
    bsr     doStuff
    bra     mainLoop
   
mouseIRQ
    bsr     parseMouseClick
    neg.b   d2        ;Turn the "flag" on <---------
    rte



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.


Top
 Profile  
 
PostPosted: Wed May 21, 2014 2:26 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1049
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.

_________________
Prof. Kelly


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group