CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Help: Confused about Assembly listing.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
louarnold



Joined: 13 May 2010
Posts: 42
Location: Ottawa, Canada

View user's profile Send private message

Help: Confused about Assembly listing.
PostPosted: Thu Jul 01, 2010 9:27 am     Reply with quote

I'm not that familiar with the 16F877A. Can someone please explain the following instructions from an assembly listing of a C program.
Code:

....................    output_low(EEPROM_SELECT);
0072:  BSF    03.5  ;0x03=status register; 5 means set RP0 bit to 1.
0073:  BCF    06.4  ;Clear bit4 of register 6 (Port B)
0074:  BCF    03.5  ;Clear RP0 (why?)
0075:  BCF    06.4  ;Clear bit 4 of register 6 again?

where EEPROM_SELECT is pin B4. This code comes from a 9356 EEPROM chip I/O utility in C.
I tried reading the data sheet, but I can only guess to the following explanation:
At 72, RP1 and RP2 of the status are set to do a bank select (bank1). (Why??)
At 73, it clears the bit B4 of the PORTB register.
At 74, the RP0 and RP1 are cleared to select bank 0, but again, why?
At 75, the PORTB register is set to zero again. Why?
louarnold



Joined: 13 May 2010
Posts: 42
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Thu Jul 01, 2010 10:07 am     Reply with quote

OK, I worked it out after finding the TRISB register:
At 72, RP0 (reg 3,bit 5) in the status register is set to 1. This switches access to register bank 1. This bank has the TRISB register in it.
At 73, bit 4 of the TRISB register(reg 6) is set to zero. This sets the PORTB register for output.
At 74, RP0 (reg3, bit 5) of the status register is set to zero. This switches back to register bank 0 and gives access to the PORTB register itself.
At 75, bit 4 of the PORTB register (reg 6) is set to zero (low).

At 20Mhz (xtal), that's at least 4 x 0.2uS = 800nS.

Let me know if I missed something.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Jul 01, 2010 1:14 pm     Reply with quote

Consider changed your first topic subject to include [SOLVED] so people know you got it.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group