• AVR Freaks

HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE

Page: < 12 Showing page 2 of 2
Author
ric
Super Member
  • Total Posts : 27923
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 04:59:05 (permalink)
0
TechDpt
...
I can see any bank selection, but the variable effectively reside into the bssBANK1 so what is wrong?

I assume you meant to type "I can't see any bank selection"
Presumably the compiler has determined that bank 0 is always already selected when this function is called.
It has got better at eliminating unneeded bank selection in recent versions.
You've already been advised that there's little need to use assembler for these trivial functions. The compiler supplied delay routines are very good, and it's possible to write C constructs that will give very clean assembler output.
e.g. using do { } while (--var); for loops will compile to a single DECFSZ var,f instruction and GOTO.
 
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#21
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 05:15:57 (permalink)
0
To complete the comparison, from the old (very good) Hi-Tech v8.05 the Delayctr variable was put into the rbss_0 (bank 0) and the compiler was also able to resolve the defined label from the code:
 
 
void Delay_Tclk(void)
{
 #asm
  movlw DELAY_CLK
  movwf _Delayctr
 Loop_tclk:
  decfsz _Delayctr,f
  goto Loop_tclk
 #endasm

 return;
}

 
and the final code from the listing was:
 
  123 0813 _Delay_Tclk
   124 0813 3006 movlw 6
   125 0814 00A2 movwf _Delayctr ;#
   126 0815 Loop_tclk
   127 ;#
   128 0815 0BA2 decfsz _Delayctr ;#
   129 0816 2815 goto Loop_tclk ;#
   130 ;#
   131 ;i2c.c: 98: return;
   132 ;i2c.c: 99: }
   133 0817 0183 clrf 3 ;select bank 0
   134 0818 0008 return

 
exactly as we expected, with the DELAY_CLK label correctly recognised...
 
So what can be the next try to do in order to get all working also with the newer compiler? It's very sad to see a totally complete different behavior over two different (v9.83 and the XC8 v1.45) release of the same compiler... this make work harder to update the code at every compiler release...
 
Thank for your time!
#22
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 05:17:16 (permalink)
0
ric
TechDpt
...
I can see any bank selection, but the variable effectively reside into the bssBANK1 so what is wrong?

I assume you meant to type "I can't see any bank selection"
 

 
yes ric sorry is a my typo mistake...
Recoding the Delay_Tclk function with the following code:
 
void Delay_Tclk(void)
{
 Delayctr = DELAY_CLK;
 do{
 }while(Delayctr--);
 
 return;
}

 
produce as listing:
 
 11639                           ; Regs used in _Delay_Tclk: [wreg+status,2+status,0]
 11640  0000' 3006                   movlw    6
 11641  0001' 1283                   bcf    3,5    ;RP0=0, select bank0
 11642  0002' 1303                   bcf    3,6    ;RP1=0, select bank0
 11643  0003' 0080'                  movwf    ??_Delay_Tclk
 11644  0004' 0800'                  movf    ??_Delay_Tclk,w
 11645  0005' 1683                   bsf    3,5    ;RP0=1, select bank1
 11646  0006' 1303                   bcf    3,6    ;RP1=0, select bank1
 11647  0007' 0080'                  movwf    _Delayctr^(0+128)
 11648  0008'                    l7052:    
 11649                           ;i2c.c: 91: do{
 11650                           
 11651                           
 11652                           ;i2c.c: 92: }while(Delayctr--);
 11653  0008' 30FF                   movlw    255
 11654  0009' 1283                   bcf    3,5    ;RP0=0, select bank0
 11655  000A' 1303                   bcf    3,6    ;RP1=0, select bank0
 11656  000B' 0080'                  movwf    ??_Delay_Tclk
 11657  000C' 0800'                  movf    ??_Delay_Tclk,w
 11658  000D' 1683                   bsf    3,5    ;RP0=1, select bank1
 11659  000E' 1303                   bcf    3,6    ;RP1=0, select bank1
 11660  000F' 0780'                  addwf    _Delayctr^(0+128),f
 11661  0010' 0A00'                  incf    _Delayctr^(0+128),w
 11662  0011' 1903                   btfsc    3,2
 11663  0012' 0008                   return
 11664  0013' 2800'                  goto    l7052
 11665  0014'                    __end_of_Delay_Tclk:    
 11666                           ;i2c.c: 94: return;

 
XC8 in free mode produce a giant code!!!!
May only be a matter of optimisation now my v1.45 is working in Free mode because I've not a license to test it in Pro mode. At this purpose is possibile to activate the trial Pro mode without need to reinstall the XC8 compiler (during the installation, on the finish I've choosed the Free mode...)?
 
Thank!
post edited by TechDpt - 2019/07/24 05:37:17
#23
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 05:57:14 (permalink)
0
I've reinstalled the XC8 v1.45 compiler but I get a message:
"Demo License has been delivered previously using the XC installer for the HOST ID."
I've not license at all (please see the attached image) so there is a way to test compilation in a PRO mode and see if this will be able to get back the code similar as my old Hi-Tech compiler?
 
As a side note, on my first testing I've used MPLABX IDE v5.20 and XC8 v2.05, then after see lot of error also into the IDE I've uninstalled the MPLABX v5.20 and XC( V2.05 compiler (always in Free mode) and then I've installed the MPLABX v5.15 and the XC8 v1.45, may be some refuse that I've to remove from previosly XC8 v2.05 installation?
 
Thank!
 
post edited by TechDpt - 2019/07/24 06:02:30

Attached Image(s)

#24
NKurzman
A Guy on the Net
  • Total Posts : 18847
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 06:14:04 (permalink)
0
You do not have to uninstall the compiler or MPLabX to use a different version.
In MPLab just choose the compiler version you want to use in the project settings.
#25
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 09:20:19 (permalink)
0
NKurzman
You do not have to uninstall the compiler or MPLabX to use a different version.
In MPLab just choose the compiler version you want to use in the project settings.

 
Thank but the problem is that I'm unable to get the trial license to test the XC8 v1.45 in PRO mode to see if somethings will change and the code can be compiled succesfully, but the fact also is that with my old Hi-Tech compiler I can compile (is really fast under WinXP) and the final resource occupation is:
 
Total ROM used     6183 words (75.5%)
Total RAM used      297 bytes (80.7%)
 
 for now then I'll stay with my old registered compiler until I'll find a solution to get the trial license for PRO testing with the XC8 v1.45 compiler release inside MPLABX v.5.15. May be I can ask to the Microchip licensing team.
 
Thank!
#26
1and0
Access is Denied
  • Total Posts : 10972
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 09:33:17 (permalink)
+1 (1)
I guess you must have missed my Post #11 in your other thread: https://www.microchip.com/forums/FindPost/1106147
where I suggested replacing your Delay_Tclk() with C code:
void Delay_Tclk(void)
{
    _delay(3*DELAY_CLK+1);
}

#27
NKurzman
A Guy on the Net
  • Total Posts : 18847
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 09:34:02 (permalink)
+1 (1)
If someone used a Trial license on the PC before you can't do it again.
You could try on a different PC.
The New Compiler will be slower since the 9.XX  "OCG" rewrite.
You can Rent the Compiler for $30 a month. 
Since you have a Hi-Tech license, you may get a discount to bring it up to XC8.
 
#28
1and0
Access is Denied
  • Total Posts : 10972
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 09:36:46 (permalink)
+1 (1)
TechDpt
seems correct, from the C assigment the correct bank is selected.
...
 
I can not see any bank selection, but the variable effectively reside into the bssBANK1 so what is wrong?
It is a very strange behavior...

When using C the compiler takes care of the bank select.  When using asm, YOU are responsible for doing the bank select yourself.
#29
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 10:13:19 (permalink)
0
1and0
I guess you must have missed my Post #11 in your other thread: https://www.microchip.com/forums/FindPost/1106147
where I suggested replacing your Delay_Tclk() with C code:
void Delay_Tclk(void)
 
{
    _delay(3*DELAY_CLK+1);
}





Yes missed it thank for the hint!
#30
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 10:21:00 (permalink)
0
NKurzman
If someone used a Trial license on the PC before you can't do it again.
You could try on a different PC.



Nobody use my PC and I'm also in a new PC with fresh installation...
Thank!
#31
NKurzman
A Guy on the Net
  • Total Posts : 18847
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 10:50:10 (permalink)
+1 (1)
A fresh installation does not matter.  It is keyed to the Computer Hardware.
licencing is at: swlicencing @ microchip.com
#32
ric
Super Member
  • Total Posts : 27923
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/24 13:35:43 (permalink)
+1 (1)
1and0
TechDpt
seems correct, from the C assigment the correct bank is selected.
...
 
I can not see any bank selection, but the variable effectively reside into the bssBANK1 so what is wrong?
It is a very strange behavior...

When using C the compiler takes care of the bank select.  When using asm, YOU are responsible for doing the bank select yourself.

Indeed. His first source block in post #20 did the initialisation in C, which did the bank selection for him.
I didn't notice he'd tried to do it in assembler instead in the second example. I thought the change was a different compiler.
As you say, if you do it all in assembler, then its YOUR JOB to handle all the bank selection, which is what the BANKSEL macro is useful for.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#33
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/25 02:46:44 (permalink)
0
NKurzman
A fresh installation does not matter.  It is keyed to the Computer Hardware.
licencing is at: swlicencing @ microchip.com


Thank, I've written...
#34
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/26 02:59:59 (permalink)
0
An update about the XC8 matter, I've got the demo license from Micrpchio (a really big thanks to the Microchip licensing support for the very speed in reply) to test the XC8 in PRO for 60 days. IDE used MPLABX v5.15.
 
By means of the XC8 v1.45 and through the extensively using of the BANKSEL and BANKMASK macro I was able to resolve all the fixup issue and through the optimisation all psect overflow concerning the CODE and then get the code properly compilated (same source as wrtten for the Hi-Tech V8.05PL2 release, the main difference was that with the old compiler most variables coded directly in assembly was set to bank0 so no need to set the bank switch manually instead with the XC8 compiler variables was in bank1 so to be sure about I've to add fro these ones the BANKSEL and BANKMASK macro to properly adress the variables), my final results was these ones:
 
Memory Summary:
    Program space used 15CBh ( 5579) of 2000h words ( 68.1%)
    Data space used 114h ( 276) of 160h bytes ( 78.4%)
    EEPROM space used 38h ( 56) of 100h bytes ( 21.9%)
    Data stack space used 0h ( 0) of 4Ch bytes ( 0.0%)
    Configuration bits used 1h ( 1) of 1h word (100.0%)
    ID Location space used 4h ( 4) of 4h bytes (100.0%)

 
but I can see some discrepancy with the summary tab that is on the left of the page, here I can see:
 
- Data 368 (0x170) bytes / Data Used: 276 (0x114) Free: 92 (0x5C) -> 75%
- Program 8192 (0x2000) words / Program Used: 5.579 (0x15CB) Free: 2.613 (0xA35) -> 68%
 
Program space is approximatively () equal but there is some difference concerning the Data (IDE tell 75%, compiler 78.4%), do you have some idea what should be the reason for this different values?
 
With the old v8.05PL2 we have:
 
Total ROM used     6174 words (75.4%)
Total RAM used      297 bytes (80.7%)
 
so I can see an improvement, nice!
 
Regards!
#35
1and0
Access is Denied
  • Total Posts : 10972
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/26 03:48:34 (permalink)
0
TechDpt
Memory Summary:
    Program space used 15CBh ( 5579) of 2000h words ( 68.1%)
    Data space used 114h ( 276) of 160h bytes ( 78.4%)
    EEPROM space used 38h ( 56) of 100h bytes ( 21.9%)
    Data stack space used 0h ( 0) of 4Ch bytes ( 0.0%)
    Configuration bits used 1h ( 1) of 1h word (100.0%)
    ID Location space used 4h ( 4) of 4h bytes (100.0%)

 
but I can see some discrepancy with the summary tab that is on the left of the page, here I can see:
 
- Data 368 (0x170) bytes / Data Used: 276 (0x114) Free: 92 (0x5C) -> 75%
- Program 8192 (0x2000) words / Program Used: 5.579 (0x15CB) Free: 2.613 (0xA35) -> 68%
 
Program space is approximatively () equal but there is some difference concerning the Data (IDE tell 75%, compiler 78.4%), do you have some idea what should be the reason for this different values?

It is obviously total data space of 160h (352) in the summary is wrong, as your PIC device has 368 bytes.
#36
TechDpt
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2011/06/13 09:29:39
  • Location: 0
  • Status: offline
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/26 04:12:41 (permalink)
0
1and0
It is obviously total data space of 160h (352) in the summary is wrong, as your PIC device has 368 bytes.



Yep, right :-), I didn't pay attention to the real overall memory of my PIC16F876A that is 368 bytes but I've noticed only the dicrepancy between the IDE and the compiler summary, then considering the real RAM amount is more attendible (at least in this case) the value on the IDE panel hence the 75% usage and this one is better than the one achieved with the old compiler v8.05PL2 (that was 80.7%). Great news!
 
Thank!
#37
ric
Super Member
  • Total Posts : 27923
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: HI-TECH v9.83 PIC16F876A ISSUE WITH C FUNCTION CALLING FROM ASSEMBLY CODE 2019/07/26 04:32:02 (permalink)
+1 (1)
1and0
...
It is obviously total data space of 160h (352) in the summary is wrong, as your PIC device has 368 bytes.

The difference is 16 bytes, so I guess one of them is not counting the 16 global locations.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#38
Page: < 12 Showing page 2 of 2
Jump to:
© 2020 APG vNext Commercial Version 4.5