Jump to content
Sign in to follow this  
sparkyb

testing pins

Recommended Posts

I would like to know if there is a way, or request there be a way to directly test a pin. Someone has suggested the macro:

 

#define test_pin(port,pin) (port & (1<<pin))

 

This works except the code it generates is very inefficent.

 

As an example,

	if (intcon & (1<<T0IF) ) {
 clear_bit(intcon,T0IF);
}

 

generates:

;;;;;;;; if (intcon & (1<<0x0002) ) {
movf _intcon, W
andlw D'4'
sublw 0
btfsc STATUS, Z
goto label_0018
;;;;;;;; clear_bit(intcon,0x0002);
bcf _intcon, D'2'
label_0018

 

when it would be much simpler to do this:

;;;;;;;; if (intcon[T0IF] ) {
btfss _intcon, 2
goto label_0018
;;;;;;;; clear_bit(intcon,0x0002);
bcf _intcon, D'2'
label_0018

 

Is there anyway to generate this simpler conditional code?

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...