On 10. 01. 2013 18:09, Raphael Neider wrote:
> Hi,
>
>> sfr16 keyword exist for pic16.
>
I> t does? Well, that would be news to me ... Does it work?!?
Yes, and works fine. As pic14 with patch from my previous post.
...
> I agree that this feature would be nice. However, this needs support
> in the code generator and (equally important) in the linker (gputils'
> gplink): Currently gputils do not like two symbols (TMR1 and TMR1L)
> occupying the same memory location (0x000F).
> Unless someone volunteers to implement both sides (or multiple
> volunteers step forward, together covering both sides ...), I do not
> see this being implemented any time soon.
> It is not sufficient to just "allow" the keyword and hope that
> everything else just magically falls into place.
>
> Sorry to disappoint you.
>
No problem, for me it work well with only allow the keyword.
Just want to share.
See:
----------------------------file flash.c -----------------------------
#include <stdint.h>
#define Nop() __asm NOP __endasm
extern __at(0x018E) __sfr16 PMADR;
extern __at(0x0190) __sfr16 PMDAT;
typedef struct
{
unsigned RD : 1;
unsigned WR : 1;
unsigned WREN : 1;
unsigned : 1;
unsigned : 1;
unsigned : 1;
unsigned : 1;
unsigned : 1;
} __PMCON1bits_t;
extern __at(0x018C) volatile __PMCON1bits_t PMCON1bits;
uint16_t read_flash(uint16_t addr)
{
PMADR = addr;
PMCON1bits.RD = 1;
Nop();
Nop();
return PMDAT;
}
--------------------------------------------------------------------------------------
and result compiled from patched last SVN version:
(no errors or warnings)
xxx> sdcc --use-non-free --opt-code-size -mpic14 -pp12f752 -c flash.c -o
flash.o
---------------------------flash.asm
---------------------------------------------------------------------
...
code_flash code
;***
; pBlock Stats: dbName = C
;***
;entry: _read_flash ;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
; STK00
;; Starting pCode block
_read_flash ;Function start
; 2 exit points
; .line 21; "flash.c" uint16_t read_flash(uint16_t addr)
BANKSEL _PMADR
MOVWF (_PMADR + 1)
MOVF STK00,W
MOVWF _PMADR
; .line 25; "flash.c" PMCON1bits.RD = 1;
BSF _PMCON1bits,0
NOP
NOP
; .line 28; "flash.c" return PMDAT;
BANKSEL _PMDAT
MOVF _PMDAT,W
MOVWF STK00
MOVF (_PMDAT + 1),W
RETURN
; exit point of _read_flash
...
--------------
Albert
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user