Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 6th September 2007, 09:15 AM   (permalink)
Default Quick code question

Just checking to see if it is ok to do this, i have stored data into STORE1 and want to check it more than once to see what character it has stored in it. So is this ok the way i am testing the same location for different data?

MOVF STORE1, W
SUBLW D'13'
BTFSC STATUS, Z
RETURN
MOVF STORE1, W
SUBLW D'10'
BTFSC STATUS, Z
RETURN

I was wondering that by calling the same STORE1 again after the sublw, the data held will have changed from the previous sublw? or does it not store the new value after the first sublw?

Hope this makes sense to you guys

Thanks

Last edited by imhereithink; 6th September 2007 at 09:23 AM.
imhereithink is offline  
Old 6th September 2007, 09:32 AM   (permalink)
Default

Quote:
Originally Posted by imhereithink
Just checking to see if it is ok to do this, i have stored data into STORE1 and want to check it more than once to see what character it has stored in it. So is this ok the way i am testing the same location for different data?

MOVF STORE1, W
SUBLW D'13'
BTFSC STATUS, Z
RETURN
MOVF STORE1, W
SUBLW D'10'
BTFSC STATUS, Z
RETURN

I was wondering that by calling the same STORE1 again after the sublw, the data held will have changed from the previous sublw? or does it not store the new value after the first sublw?

Hope this makes sense to you guys

Thanks
hi,
As you are not writing W back into the STORE1 after each test, the original STORE1 is not changed.
Also you are reloading W with STORE1 before each new test, its OK.

How many tests are you planning to do on STORE1?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now  
Old 6th September 2007, 09:35 AM   (permalink)
Default

It is fine to do it that way.

There is a better way and that is to use xor. Because xoring the same value twice results in the original value, you can use this to your advantage.

Code:
	MOVF	STORE1, W
	xorlw	D'13' 		; is it 13
	BTFSC	STATUS, Z
	RETURN
	xorlw	D'13'^D'10'	; is it 10
	BTFSC	STATUS, Z
	RETURN
	xorlw	D'10'^'A'	; is it "A"
	BTFSC	STATUS, Z
	goto	CommandA
The ^ symbol tells the assembler to xor the values together.

BTW, when you do any operation with a literal (sublw) the answer always goes in W.

Mike.
Pommie is offline  
Old 6th September 2007, 09:48 AM   (permalink)
Default

Thanks for clearing that up guys

Eric i am planning on testing STORE1 four times, since i seem to be having sychronisation problems when reading in the received data, so i am wanting to test each bit stored for CR, LF, O, K. That way i should pick up what i am looking for even if it is out of sync.

Thanks again
imhereithink is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Quick Question About sharing programming pins on a PIC 2camjohn Micro Controllers 4 5th May 2007 05:39 AM
Quick question about logic switching FET's.. Blueteeth General Electronics Chat 12 16th February 2007 07:43 PM
Quick Newbie Question stcogolin General Electronics Chat 8 21st December 2003 05:50 PM
Quick Question, DC motors flight1060 General Electronics Chat 2 12th May 2003 12:36 AM
quick question droid Micro Controllers 1 25th April 2003 06:14 PM



All times are GMT. The time now is 06:47 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker