Recent

Author Topic: PicPas, Pascal compiler for Microchip PIC  (Read 114876 times)

FPK

  • Full Member
  • ***
  • Posts: 118
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #15 on: May 01, 2017, 09:37:56 pm »
1. and 2. are not an issue, FPC can build already for ram-less AVRs like the ATtiny28, smaller is basically not possible :) :

ppcavr empty -Wpattiny28 -Cpavr25 -vi -O4
Target OS: Embedded
Compiling empty.pp
Assembling program
Linking empty
2 lines compiled, 0.1 sec, 42 bytes code, 0 bytes data

The 42 bytes are mainly overhead for interrupt vector handling.

3. is a small issue, but there are normally enough tools out there already.

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #16 on: May 01, 2017, 10:18:20 pm »
Uhm ATyny48. It has 2K of flash.

How about working with a 0.5K flash memory device? PicPas can  :D, and is as efficient as assembler.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

FPK

  • Full Member
  • ***
  • Posts: 118
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #17 on: May 02, 2017, 09:50:22 pm »
Uhm ATyny48. It has 2K of flash.

How about working with a 0.5K flash memory device?

Did you see the output of FPC? 42 bytes for a minimal program on avr, a simple blink example is 60 bytes. Extract of inner loop:

Code: Pascal  [Select][+][-]
  1. pacr:=$4;
  2.   tccr0:=$05;
  3.   while true do
  4.     begin
  5.       porta:=porta or 4;
  6.       delay;
  7.       porta:=porta and not(4);
  8.       delay;
  9.     end;
  10.  

Assembler:


# [14] pacr:=$4;
   ldi   r18,4
   out   26,r18
# [15] tccr0:=$05;
   ldi   r18,5
   out   4,r18
.Lj11:
   sbi   27,2
# [19] delay;
   rcall   PsPROGRAM_ss_DELAY
   cbi   27,2
# [21] delay;
   rcall   PsPROGRAM_ss_DELAY
# [16] while true do
   rjmp   .Lj11
# [23] end.

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #18 on: May 03, 2017, 01:03:07 am »
Did you see the output of FPC? 42 bytes for a minimal program on avr, a simple blink example is 60 bytes. Extract of inner loop:

Code: Pascal  [Select][+][-]
  1. pacr:=$4;
  2.   tccr0:=$05;
  3.   while true do
  4.     begin
  5.       porta:=porta or 4;
  6.       delay;
  7.       porta:=porta and not(4);
  8.       delay;
  9.     end;
  10.  

Yes, I saw the 60 bytes size.  It's just you said " ... like the ATtiny28, smaller is basically not possible". So I assume it is not possible to use FPC in a 512 cells memory device.

60 bytes looks Ok, although I don't know so much about AVR programs size.

PIC architecture is some problematic, because of the banking for RAM and paging for flash or EEPROM. That's why it is so problematic doing a decent compiler for PIC.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #19 on: May 03, 2017, 02:49:20 pm »
PIC architecture is some problematic, because of the banking for RAM and paging for flash or EEPROM. That's why it is so problematic doing a decent compiler for PIC.
And don't forget about the read-modify-write probs :)
Interesting project though!
« Last Edit: May 03, 2017, 02:51:59 pm by eny »
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

FPK

  • Full Member
  • ***
  • Posts: 118
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #20 on: May 03, 2017, 09:38:06 pm »
It's just you said " ... like the ATtiny28, smaller is basically not possible". So I assume it is not possible to use FPC in a 512 cells memory device.

Flash is normally not the issue, it is more about the ram :) And this is what I wanted to emphasis: the ATtiny28 has no RAM.

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #21 on: May 03, 2017, 11:49:35 pm »
And don't forget about the read-modify-write probs :)
Yes. Fortunately, it's some problem easily avoided, by hardware or software.
Other of the problems is the small size of the stack. Just 2 levels in some devices of the serie 12F.

Flash is normally not the issue, it is more about the ram :) And this is what I wanted to emphasis: the ATtiny28 has no RAM.
I see. But it's relative. AVR has 32 register all mapped in memory, It's almost like the PIC16F83 with 36 bytes of RAM (and only one register).
Anyway, it's a big achievement for FPC, to compile in this small MPU. I would ask, why Cannot  FPC compile to Microchip PIC?

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

PStechPaul

  • Jr. Member
  • **
  • Posts: 76
    • P S Technology, Inc.
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #22 on: May 04, 2017, 05:02:52 am »
I use Microchip PICs for a lot of projects, and a Pascal compiler seems interesting and useful. I posted in the Microchip forum:
http://www.microchip.com/forums/m989713.aspx#989763

And found another PIC Pascal project:
http://www.pmpcomp.fr/smf/
http://www.pmpcomp.fr/

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #23 on: May 04, 2017, 07:27:09 am »
I use Microchip PICs for a lot of projects, and a Pascal compiler seems interesting and useful.

Good. This project is just beginning, PicPas is not intended to be just a compiler, a simulator is coming. Suggestion are welcome.

And found another PIC Pascal project:
http://www.pmpcomp.fr/smf/
http://www.pmpcomp.fr/

PMP was one of the first projects I saw. I must say it is a good compiler, but it depend on Microchip (Assembler, libraries and linker). That's something I didn't liked. It has good IDE, but the code generated is not so optimized. Moreover PMP, is just a compiler (to ASM) and don't think on implement some other feature.
« Last Edit: May 04, 2017, 07:28:54 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

FPK

  • Full Member
  • ***
  • Posts: 118
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #24 on: May 04, 2017, 09:57:42 pm »
I would ask, why Cannot  FPC compile to Microchip PIC?

Because nobody wrote a PIC backend (the part generating code for PIC) for it yet, I decided to go for Z80 first :)

djzepi

  • New Member
  • *
  • Posts: 36
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #25 on: May 05, 2017, 07:10:56 am »
I would ask, why Cannot  FPC compile to Microchip PIC?

Because nobody wrote a PIC backend (the part generating code for PIC) for it yet, I decided to go for Z80 first :)

I recommend it before explore the mps430 microprocessor
(https://en.wikipedia.org/wiki/TI_MSP430).
There is not yet any Pascal compiler.

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #26 on: May 05, 2017, 04:02:49 pm »
Because nobody wrote a PIC backend (the part generating code for PIC) for it yet, I decided to go for Z80 first :)

Z80 ? Good. Many people love this CPU. I prefer the 6502, it's another legend of the 80's.

I have no problem on colaborate for FPC having a Microchip Compiler, according to my free time. But I don't know how.

I don't know is it would be easy to integrate the code generator of PicPas on FPC.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #27 on: May 05, 2017, 07:13:00 pm »
I recommend it before explore the mps430 microprocessor
(https://en.wikipedia.org/wiki/TI_MSP430).
There is not yet any Pascal compiler.
It sounds interesting, but I don't use that MCU. If I would have the necessity, I'm sure, I would write a compiler  :).
« Last Edit: May 05, 2017, 11:19:59 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #28 on: May 06, 2017, 12:12:55 am »
PMP was one of the first projects I saw. I must say it is a good compiler, but it depend on Microchip (Assembler, libraries and linker). That's something I didn't liked.
Pros and cons.
I use the PICBasic compiler and that does the same.
The advantage is that you can make full use of all features of the Microchip assembler when generating intermediate code.
But then again there would also be a dependency on that software and version/features.
I remember Microchip once 'breaking' the PICBasic compiler when they brought out an update.
Was fixed quickly by the producer of the compiler though.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #29 on: May 06, 2017, 12:29:33 am »
There is also MikroPascal, though that orients more towards pic18 and pic24/dspic.

I'm now working on the probably the last board design using the dspic33e series, if all goes well the next iteration will be PIC32mk based. (and PIC32 is supported by FPC, though not this series yet)

 

TinyPortal © 2005-2018