The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 27, 2024, 12:06:23 00:06


Login with username, password and session length


Pages: [1]
Print
Author Topic: CCS & mikroC comparsion indirect addressing  (Read 8918 times)
0 Members and 1 Guest are viewing this topic.
msamar
Newbie
*
 Muted
Offline Offline

Posts: 20

Thank You
-Given: 0
-Receive: 4


« on: November 29, 2009, 05:40:02 17:40 »

Hello every bodyI would like to make comparison between two kind of PIC microcontroller compilers mikroC & CCS as example using pointers indirect addressing

Here  is the code:  mcu /pic 16f877A
//////////////////////////////////////////////////////
1- For mikroC write this C code

Code:
Char cntr =3 absolute 0x121;
char*ptr =&cntr;
void main() {
trisb = 0;
portb = *ptr;
 }
//////////////////////////////////////////////
2- for CCS  write this   C code

Code:
#BYTE  portb= 0x6
#BYTE  cntr=0x121
char*ptr = &cntr;
void main()
{
  
  SET_TRIS_B( 0x00 );
 cntr = 3;
 portb = *ptr:
}
After you compile the code  upload the hex file to mcu  16f877 or you can test it  by  simulator like proteus  the result by CCS hex file is working  fine but  in the contrary  by mikroc hex file , if we check the lst asm file belong to ccs & mikroC  compilers
1- mikroC asm lst file

Code:
;ex1.c,11 :: 		portb = *ptr;
BCF        STATUS, 6
MOVF       _ptr, 0
MOVWF      FSR
MOVF       INDF, 0
MOVWF      PORTB
///////////////////////////////////////////////////////////
2- CCS asm lst file
Code:
....................  portb = *ptr; 
      BCF    03.6
   MOVF   20,W
   MOVWF  04
   BCF    03.7
   BTFSC  21.0
   BSF    03.7
   MOVF   00,W
   MOVWF  06

If we check the data sheet PIC  :

REGISTER 2-1: STATUS REGISTER (ADDRESS 03h, 83h, 103h, 183h)

bit 7 IRP: Register Bank Select bit (used for indirect addressing)
1 = Bank 2, 3 (100h - 1FFh)
0 = Bank 0, 1 (00h - FFh)
////////////////////////////////////////////////////////////
 Conclusion :
I find  that  Mikroc  don’t care of  IRP bit  for  indirect addressing  as you note before .

On other side if we update c file  by adding an asm line of code like this
Mikroc  write this C file :

Code:
char cntr absolute 0x121;
char*ptr =&cntr;
void main() {
trisb = 0;
cntr = 3;
asm   BSF    STATUS, IRP
portb = *ptr;
}
///////////////////////////////////////////////////////
On that we can resolve our problems on mikroC  pointers indirect addressing.
About me I don’t like any one . but I note  that CCS is pro compiler
About mikroC is easy one but if you are professional programmer you don’t prefer it any way .

« Last Edit: November 29, 2009, 10:21:41 22:21 by msamar » Logged

Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC