Lazarus

Announcements => Third party => Topic started by: Edson on April 21, 2017, 06:08:39 am

Title: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on April 21, 2017, 06:08:39 am
PicPas 0.5.1 is my new compiler for Microchip small devices (16F PIC microcontrollers)  :D.

https://github.com/t-edson/PicPas

By the moment, there are only limited functionalities. Only the bit, byte and boolean types are supported, and a few operators are implemented.  :-[

A small IDE is included with the compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: avra on April 21, 2017, 08:30:00 am
PicPas 0.5.1 is my new compiler for Microchip small devices (16F PIC microcontrollers)  :D.
Congratulations!

As I see this is just a beginning... You have a lot of work in front of you.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: tr_escape on April 21, 2017, 09:42:07 am
It is very nice project maybe you want to look at that project too:

https://github.com/jallib/jallib (https://github.com/jallib/jallib)

I used once for a project but I think it is not full open source project.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Ñuño_Martínez on April 21, 2017, 10:59:15 am
Cool project.

I'm working on my very own compiler for the Z80 microprocessor (https://github.com/daar/z80-pascal/tree/wirth_compiler), but I didn't tell anything because it only extracts tokens telling what they are, no code generated yet.

I've briefly look at your code and I must to say that it was ingenious to use SynEdit parser.  I'll write it my own.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on April 21, 2017, 06:01:18 pm
Congratulations!
As I see this is just a beginning... You have a lot of work in front of you.

Thanks.
Yes. There is a lot of work in front, and there is a lot of word done: Several libraries, frameworks, design and docs. The design is very important for this kind of projects.

I will be publishing my advances.

It is very nice project maybe you want to look at that project too:
https://github.com/jallib/jallib (https://github.com/jallib/jallib)
I have seen something about the JAL project. There were some things I didn't like of JAL. I will check again.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: majid.ebru on April 21, 2017, 07:25:40 pm
Congratulations ;D ;D
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on April 22, 2017, 03:20:12 am
Congratulations ;D ;D

Thanks. It's really hard to make a functional compiler, especially for a limited architecture like this.

I'm working on my very own compiler for the Z80 microprocessor (https://github.com/daar/z80-pascal/tree/wirth_compiler), but I didn't tell anything because it only extracts tokens telling what they are, no code generated yet.

Good. Z80 is one of my favourites CPU. Although I have worked a lot with the 6502 CPU, in the Commodore 64. I remember, I wrote a very simple, and low level compiler in BASIC, for this CPU. Some routines of this compiler were "compiled" by the same compiler.  %) Sadly, the code has gone with my audio-tapes.  :'( Maybe I can rewrite this, in FPC.

I've briefly look at your code and I must to say that it was ingenious to use SynEdit parser.  I'll write it my own.
Maybe, you can use the lexer of PicPas, and some of its libraries, like T-Xpres (https://github.com/t-edson/t-Xpres) and SynFacilSyn. The code generator is some very complex module, and T-Xpres helps a lot on this case.

This project, really reuse the code, because the same lexer is used for the editor higjlighter and for the completion tool, too.

Tell me if you need some help on your compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Cyrax on April 22, 2017, 03:24:03 am
Cool project.

I'm working on my very own compiler for the Z80 microprocessor (https://github.com/daar/z80-pascal/tree/wirth_compiler), but I didn't tell anything because it only extracts tokens telling what they are, no code generated yet.

I've briefly look at your code and I must to say that it was ingenious to use SynEdit parser.  I'll write it my own.

There is experimental FPC branch for z80 here : http://svn.freepascal.org/cgi-bin/viewvc.cgi/branches/z80/?sortby=date&view=log
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Ñuño_Martínez on April 22, 2017, 02:00:37 pm
Good. Z80 is one of my favourites CPU. Although I have worked a lot with the 6502 CPU, in the Commodore 64. I remember, I wrote a very simple, and low level compiler in BASIC, for this CPU. Some routines of this compiler were "compiled" by the same compiler.  %) Sadly, the code has gone with my audio-tapes.  :'( Maybe I can rewrite this, in FPC.

Maybe, you can use the lexer of PicPas, and some of its libraries, like T-Xpres (https://github.com/t-edson/t-Xpres) and SynFacilSyn. The code generator is some very complex module, and T-Xpres helps a lot on this case.

This project, really reuse the code, because the same lexer is used for the editor higjlighter and for the completion tool, too.

Tell me if you need some help on your compiler.
Thanks for the advices.  I'll work on it.

A C64 compiler would be nice too...

There is experimental FPC branch for z80 here : http://svn.freepascal.org/cgi-bin/viewvc.cgi/branches/z80/?sortby=date&view=log
:o
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: molly on April 22, 2017, 02:14:03 pm
Cyrax was a bit faster about the z80 branch :)

A C64 compiler would be nice too...
Plenty of them in the wild.
- Ruud's commodore site (http://www.baltissen.org/newhtm/pcomp.htm)
- G-Pascal by nick gammon (http://www.gammon.com.au/GPascal/source/)
- Others (https://www.c64-wiki.de/wiki/Pascal)

Do realize that because of the available space (or lack thereof) most of those compilers made heavy use of macro's.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on April 22, 2017, 09:26:53 pm
It would be nice for me, to do compilers for Z80 or 6502 (especially this), but there are, currently, many compilers developed.  Maybe it would be some experimental.

What I see is, the only 8 bits devices, widely used now, are the microcontrollers. And the 8 bits PICs are very used in this part of the world. This is one motivation on doing my compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: CaptBill on April 30, 2017, 09:45:06 pm
Hi Edson,
This is a fantastic choice, the PIC16x86 for a target. As good as it gets, really. This is the bread and butter chip used in most mass produced electronics products. THIS is the best choice for a 16 bit microcontroller for a multitude of reasons.

I am experimenting with an uploader/debugger/logic analyzer combination (for lack of a better term) utilizing the FTDI ft2232h chip. The idea is to enable something like PICPas to have a full Lazarus like "RAD" environment functionality. You will be able to compile/upload in one operation and utilize the integrated logic analyzer in-line as the ultimate debugger. It will enable you to "tap" actual pins on the PIC and map them to the logic analyzer, which is fully controlled by the PicPas GUI app as simple project settings, for example. So no more messing with breadboards. It's all safely done in a hands off fashion.

The FT2232h and the larger FT4232h can also be utilized in a loopback fashion as a stand-alone solution. You configure one serial port for uploading to the target PIC chip and utilizing MPSSE (GPIO functionality of the FT2232h via the D2xx.pas) you set up capture pins. This is all that PICPas really needs. Of coarse, this will require coding the logic analyzer in Pascal.

How about "Pascal hardware components"? The PIC16x86 looks like the perfect target chip for this. An example would be a linear actuator for a CNC. The PIC has properties and functions much like a visual component. You intitalize (create) it, then you pass opcodes as function/method arguments over the serial link for "moveto(300)". The PIC "component" handles things from here on. As far as a "programming style" goes, do a search on "Arduino firmata" to get an idea of the concept.

The logic analyzer I am working with is an amazing little FPGA design that is TOP NOTCH!! This puppy will capture at 200mhz and has a 64Mib buffer and 32 channels. The top of the line Saelae logic analyzer only captures 100mhz and only 16 channels... and will set you back $700.

The FPGA design is fully OpenSource and only use about 10% of the "fabric" on the Pipistrello FPGA board. Driving this board is a piece of cake over serial. It utilizes the SUMP protocol. All that is needed is a good TSignalDrawer component for Lazarus for drawing a nice GUI to round things out.

https://www.sigrok.org/blog/new-better-openbench-logic-sniffer (https://www.sigrok.org/blog/new-better-openbench-logic-sniffer)

I am currently trying to get this same setup going with Professor Wirth's "PICL", which is his little PIC16C86 compiler. Have you seen it? Less than 800 lines of code including the uploading tools!

https://www.inf.ethz.ch/personal/wirth/PICL/index.html

Good luck with this!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 01, 2017, 06:14:36 pm
Hi Edson,
I am experimenting with an uploader/debugger/logic analyzer combination (for lack of a better term) utilizing the FTDI ft2232h chip. The idea is to enable something like PICPas to have a full Lazarus like "RAD" environment functionality. You will be able to compile/upload in one operation and utilize the integrated logic analyzer in-line as the ultimate debugger. It will enable you to "tap" actual pins on the PIC and map them to the logic analyzer, which is fully controlled by the PicPas GUI app as simple project settings, for example. So no more messing with breadboards. It's all safely done in a hands off fashion.

The FT2232h and the larger FT4232h can also be utilized in a loopback fashion as a stand-alone solution. You configure one serial port for uploading to the target PIC chip and utilizing MPSSE (GPIO functionality of the FT2232h via the D2xx.pas) you set up capture pins. This is all that PICPas really needs. Of coarse, this will require coding the logic analyzer in Pascal.


Well. PicPas is just beginning. The objective is to have a full compiler for the MicroChip series 12F, 16F and 18F.

The other objective is to include the control of the programmer and a device simulator. It is to compile, simulate and transfer, all in the same IDE. Including a debug tool is a great idea too.

The simulation is one of the feature I expect to implement first, because the libraries are designed for this. Anyway you are invited to colaborate . There are many things that can be implemented in this project.

I am currently trying to get this same setup going with Professor Wirth's "PICL", which is his little PIC16C86 compiler. Have you seen it? Less than 800 lines of code including the uploading tools!
https://www.inf.ethz.ch/personal/wirth/PICL/index.html

I didn't know about this project. After reading it, I must say, it's very similar to one project I made, a long time ago. I called it The "symbolic compiler", and was targeted to the micro MOS 6510.

It's a very basic compiler, implemented on the limitations of the PIC16C84. It is just a little high-level language for the assembler of this PIC, but probably no so useful for others PIC or more complex programs. Its advantage is to generate a very small code.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: FPK on May 01, 2017, 07:35:18 pm
Why not extending FPC with a PIC backend? FPC has a full featured Object Pascal front end, so no need to bother with this part :D
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 01, 2017, 09:04:26 pm
Why not extending FPC with a PIC backend? FPC has a full featured Object Pascal front end, so no need to bother with this part :D

Well, I have no problem on include PicPas as a FPC backend  :). In fact, it was some sad to me, to see FPC cannot compile to this 8 bits small devices  :'(.

What do you refer with frontend? I don't really know about the design of FPC. :-[

I think, we need to consider that if FPC is going to enter to the embedded world:

1. There are very small devices, with just a few bytes of RAM and EEPROM. The common Pascal language have some limitation on this case.
2. The compiler have to be very efficient. Maybe the more advanced devices can support recursivity, objects or advanced features, but the smaller, cannot even support float numbers.
3. This kind of tools, usually are accompanied with software simulators, hardware debugger, burning software, ...

Anyway, I would love to see a FPC compiler for Microchip PIC  :D.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: FPK 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: FPK 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: eny 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!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: FPK 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson 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?

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: PStechPaul 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/
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: FPK 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 :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: djzepi 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 (https://en.wikipedia.org/wiki/TI_MSP430)).
There is not yet any Pascal compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 05, 2017, 07:13:00 pm
I recommend it before explore the mps430 microprocessor
(https://en.wikipedia.org/wiki/TI_MSP430 (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  :).
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: eny 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.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: marcov 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)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 07, 2017, 05:43:29 pm
Mikro Pascal is a good compiler, although I have doubts about its optimization level. I have used it with the 16F series and works well. But it's not free. The evaluation copy is only for 2K of code.

And don't forget it's only for Windows, like Pic Micro Pascal. They have years announcing their Linux versions. 

PicPas is open source and multi-platform. I have compiled in Win32/Win64/Ubuntu64, I have not  a Mac to test.  If someone can compile it in Mac, I would be thankfull.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Ñuño_Martínez on May 08, 2017, 09:16:15 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 :)
Is everybody making a Z80 Pascal compiler? This is mine. (https://github.com/daar/z80-pascal)  Working in the "wirth compiler" branch now.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 10, 2017, 04:34:52 pm
Is everybody making a Z80 Pascal compiler? This is mine. (https://github.com/daar/z80-pascal)  Working in the "wirth compiler" branch now.

I'm not doing a Z80 compiler, but if you take a long time, more and more Z80 compilers will be appearing.  :P
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: marcov on May 10, 2017, 04:51:56 pm
I'm not doing a Z80 compiler, but if you take a long time, more and more Z80 compilers will be appearing.  :P

I thought one would need an infinite number of monkeys for that :P
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 10, 2017, 08:51:35 pm
PicPas has been updated to the version 0.6.0  :D. All bit operation implemented, more optimization code included, tree syntax improved, parameters of procedures implemented, interfaz modified,  and many other features more.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: majid.ebru on May 26, 2017, 05:07:30 pm
hi
.
i download it from https://github.com/t-edson/PicPas
.
but :
1-the language of program is french(i thnik) can translate to englsh?(i think in older version,it was english)
.
2-when i open it ,error ?!?
.
3- when i extract it ,twice extract zip file?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 26, 2017, 06:02:43 pm
Hi.

PicPas is designed as multi-language (including the compiler messages), but by now, only English and Spanish implemented. The initial messages are in spanish, because the Config file is not yet loaded, so PicPas choose spanish  :-\.

No problem, I have changed it to English. Please update to the version 0.6.5.  There are some messages not translated, but it will be fixed in next versions.

If you have some problem in language, use the Config form.

Tell me if you find some other inconvenients, and thanks for test.

PD: If someone wish to include other languages for PicPas, let me know.  :D
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: majid.ebru on May 26, 2017, 08:20:31 pm
thank you :) :D ;D
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on May 26, 2017, 10:09:45 pm
Hi Edson,
you have quiete a program here,
but have you ever tried i18n ?
http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs (http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs)
or at least put the Language specific code in separate (language specific folders) from where you include the parts for your prog.
This makes the handling and translating to other language much more easy.
If you like, I just do a German translation.
FormPrincipal line 570ff would be:
Code: Pascal  [Select]
  1.  'de': begin
  2.       //menú principal
  3.       mnFile.Caption:='&Datei';
  4.       mnEdit.Caption:='&Bearbeiten';
  5.       mnFind.Caption:='&Suchen';
  6.       mnView.Caption:='&Ansicht';
  7.       mnTools.Caption:='&Werkzeuge';
  8.  
  9.       acArcNuevo.Caption := '&Neu';
  10.       acArcNuevo.Hint := 'Neue Datei';
  11.       acArcAbrir.Caption := '&Öffnen...';
  12.       acArcAbrir.Hint := 'Datei öffnen';
  13.       acArcGuardar.Caption := '&Speichern';
  14.       acArcGuardar.Hint := 'Datei speichern';
  15.       acArcGuaCom.Caption := 'Speichern &unter ...';
  16.       acArcGuaCom.Hint := 'Datei mit unter neuem Namen speichern ...';
  17.       acArcSalir.Caption := '&Beenden';
  18.       acArcSalir.Hint := 'Programm beenden';
  19.  
  20.       acEdUndo.Caption := '&Zurück';
  21.       acEdUndo.Hint := 'Änderung zurücknehmen';
  22.       acEdRedo.Caption := '&Wiederholen';
  23.       acEdRedo.Hint := 'Änderung wiederholen';
  24.       acEdCut.Caption := 'A&usschneiden';
  25.       acEdCut.Hint := 'Ausschneiden';
  26.       acEdCopy.Caption := '&Kopieren';
  27.       acEdCopy.Hint := 'Kopieren';
  28.       acEdPaste.Caption := '&Einfügen';
  29.       acEdPaste.Hint := 'Einfügen';
  30.       acEdSelecAll.Caption := 'Alles &Auswählen';
  31.       acEdSelecAll.Hint := 'Alles auswählen';
  32.       acEdModCol.Caption := 'Block-Modus';
  33.       acEdModCol.Hint := 'Blockmode';
  34.  
  35.       acBusBuscar.Caption := 'Suchen...';
  36.       acBusBuscar.Hint := 'Text suchen';
  37.       acBusBusSig.Caption := 'Weitersuche&n';
  38.       acBusBusSig.Hint := 'Nächste Stelle suchen';
  39.       acBusReemp.Caption := '&Ersetzen...';
  40.       acBusReemp.Hint := 'Text ersetzen';
  41.  
  42.       acViewMsgPan.Caption:='&Nachrichten Panel';
  43.       acViewMsgPan.Hint:='Nachrichten Panel zeigen oder verbergen';
  44.       acViewStatbar.Caption:='&Statuszeile';
  45.       acViewStatbar.Hint:='Statuszeile zeigen oder verbergen';
  46.       acViewToolbar.Caption:='&Werkzeugleiste';
  47.       acViewToolbar.Hint:='Werkzeugleiste zeigen oder verbergen';
  48.  
  49.       acToolCompil.Caption:='&Compilieren';
  50.       acToolCompil.Hint:='Compiliere den Quelltext';
  51.       acToolComEjec.Caption:='Compilieren und Au&sführen';
  52.       acToolComEjec.Hint:='Compilieren und Ausführen';
  53.       acToolPICExpl.Caption:='PIC E&xplorer';
  54.       acToolPICExpl.Hint:='Öffne den PIC Geräte explorer';
  55.       acToolCodExp.Caption:='&Quelltext-Explorer';
  56.       acToolCodExp.Hint:='Öffne den Quelltext-Explorer';
  57.       acToolConfig.Caption := '&Einstellungen';
  58.       acToolConfig.Hint := 'Einstellungs-Dialog';
  59.     end;                                                  
  60.  
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 26, 2017, 11:00:08 pm
Hi Edson,
you have quiete a program here,
but have you ever tried i18n ?
http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs (http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs)
Hi, jc99. I have looked at that, a time ago, but I decided not to use. I don't remember why.  %)

Hi Edson,
or at least put the Language specific code in separate (language specific folders) from where you include the parts for your prog.
This makes the handling and translating to other language much more easy.
If you like, I just do a German translation.

Good. You have looked at an older version. The new version have the translation part at the root folder, in the files: tra_FormPrincipal.pas, tra_FormConfig.pas, ...

I would add more files later.

Please add the translation, to the last parameter of trans():

Code: Pascal  [Select]
  1.  
  2.   mnFile.Caption :=Trans('&File'  , '&Archivo', '','&Datei');
  3.  

Thanks.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: kupferstecher on May 26, 2017, 11:15:07 pm
I18n is not difficult to use. And once its set up the changes are very fast. The translations can also be embedded in the program as resource to achive a standalone binary.

If you have questions, just ask~
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on May 27, 2017, 12:05:23 am

Code: Pascal  [Select]
  1.  
  2.   mnFile.Caption :=Trans('&File'  , '&Archivo', '','&Datei');
  3.  

Thanks.
Exactly that's the problem with that code, (btw. I just checked out trunk, that should be the actual version.) Now you have all languages scattered in one, or lot of separate files,
The old version is not as good as i18n but you could do:
In FormPrincipal Lin 455ff you do:
Code: Pascal  [Select]
  1.  {$define FormPrincipal}
  2.  case lowerCase(lang) of        
  3.     {$I Espaniol.tra.inc};
  4.     {$I English.tra.inc};
  5.     {$I German.tra.inc};
  6.     {$I French.tra.inc} //!
  7.    else
  8.     {$define default}
  9.     {$I english.tra.inc}
  10.     {$undef default}
  11.   end;
  12.  

Language -Directory is part of include-Path
e.G English.tra.inc Look's partly like:
Code: Pascal  [Select]
  1. {$ifndef default}'en': {$endif}begin
  2.     {$ifdef FormPrincipal}
  3.           mnFile.Caption:='&File';
  4.           mnEdit.Caption:='&Edit';
  5.           mnFind.Caption:='&Search';
  6.           // ... rest ...
  7.     {$endif}
  8.     {$ifdef FrmCfgSynEdit}
  9.       Label6.Caption:='&Font:'; // How about lblFont.caption := ...
  10.       Label7.Caption:='&Size:'; // How about lblSize.caption := ...
  11.       Label8.Caption:='Back color:'; // How about lblBlackColor.caption := ...
  12.         // ... rest ...
  13.     {$endif}
  14.     {$ifdef FormCodeExplorer}
  15.       Caption:='Code Explorer';
  16.       mnRefresh.Caption:='&Refresh';  
  17.     {$endif}
  18. // ... other forms and definitions
  19.  end
  20.  
That way you have everything for one language in one file, and you can add as many languages as you like; 

You could even encapsulate the case-part in a separate Include, so you add new languages there and only once.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 27, 2017, 04:17:16 am

Code: Pascal  [Select]
  1.  
  2.   mnFile.Caption :=Trans('&File'  , '&Archivo', '','&Datei');
  3.  

Exactly that's the problem with that code, (btw. I just checked out trunk, that should be the actual version.) Now you have all languages scattered in one, or lot of separate files,

Well, that was the idea. To have all languages in one file, like a help for translation.

There is someone who is helping me on translation to the "quechua" language, and she doesn't speak english (and doesn't speak Pascal), and use the spanish translation like a guide.   :'(
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 01, 2017, 07:16:58 pm
PicPas 0.6.6 is released  :D : https://github.com/t-edson/PicPas

Translation to english improved. New operations in the Code generator are implemented and support for complex expressions are improved. The  ASM blocks are now very completes, including jumps and access to variables.

The control structs are now implemented at the style of Modula-2:

Code: Pascal  [Select]
  1. IF <condition> THEN
  2.   <block of code>
  3. END;
  4.  
  5. IF <condition> THEN
  6.   <block of code>
  7. ELSE
  8.   <block of code>
  9. END;
  10.  
  11. IF <condition> THEN
  12.   <block of code>
  13. ELSIF <condition> THEN
  14.   <block of code>
  15. ELSE
  16.   <block of code>
  17. END;
  18.  
  19. WHILE <condition> DO
  20.   <block of code>
  21. END;
  22.  
  23. REPEAT
  24.   <block of code>
  25. UNTIL <condition>;
  26.  
  27. FOR  <variable> := <start-value> TO <end-value> DO
  28.   <block of code>
  29. END;
  30.  
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on June 01, 2017, 10:58:45 pm
... and here comes a translation-patch

How about putting the tra*.pas files in a "language"-subdirectory ?

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 02, 2017, 12:50:04 am
... and here comes a translation-patch


Good.  :) I'm preparing the next version now. I will be including the patch.
 
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: avra on June 02, 2017, 01:36:47 am
The control structs are now implemented at the style of Modula-2
This is my preference too ::), also found in AvrCo Pascal. Code is easier to look at.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 02, 2017, 04:18:50 pm
This is my preference too ::), also found in AvrCo Pascal. Code is easier to look at.
Yes. Althought AvrCon have the delimiters "ENDWHILE", "ENDCASE", "ENDFOR". It seems me more to Visual Basic syntax, but anyway it's good.

By the way, I was triying to use the PicCo 32, but no success. I compile, but nothing appears, just a beep. It's a very old program, very simple editor and interfaz.

PicPas has a compatibility mode. If you include {$MODE PASCAL}, then PicPas will recognize the old classic syntax of Pascal, for control structs, like:
IF ... THEN
  BEGIN
  END 
ELSE
  BEGIN
  END;

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: avra on June 02, 2017, 07:36:20 pm
By the way, I was triying to use the PicCo 32, but no success. I compile, but nothing appears, just a beep. It's a very old program, very simple editor and interfaz.
Well, PicCo used to work 20 years ago before it was abandoned in favor of AvrCo  :-[. AvrCo is much improved (although editor could be better), and the best thing is it's simulator and visual JTAG/PDI debugger. You can set hardware absolute and conditional breakpoints, exec step by step, or browse locals and watches. Sim can even show graphical, line lcd or 7/14seg, and lots of other drivers. It's worth a look.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: mischi on June 03, 2017, 04:29:38 pm
Dear Edson

Out off curiosity, I had a brief go on macOS. My brief report:

The first barrier was the usage of all your other units. I simply proceeded by missing error message, downloading and compiling. Although i created an app bundle, starting the app through double click or from within Lazarus did not work smoothly, probably because of error messages, but i am not sure. Therefore, I started the app with the open command from the command line, and i got some warnings and errors, all related to paths. The three folders samples, temp, and units were created in the application bundle (PicPas-darwin.app → Contents → MacOS). This might still work, but could be probably be improved. Depending on the usage, the should be placed somewhere else. Next came an error message, that the file PicPas_AsmPic.xml could not be loaded. I tried to put the file at a number of places, but none worked. This is probably the related line Source/FormPrincipal.pas:  hlAssem.LoadFromFile('PicPas_AsmPic.xml');
I do not really know, what the default path of LoadFromFile is and how it could be set.

I got stuck and stopped at this point, but maybe some else can jump in and help.

Michael.

Update: macOS 10.12.5, lazarus 1.6.4, fpc 3.0.2 (from fink), i386-carbon-lcl.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 03, 2017, 05:43:23 pm
The three folders samples, temp, and units were created in the application bundle (PicPas-darwin.app → Contents → MacOS). This might still work, but could be probably be improved. Depending on the usage, the should be placed somewhere else. Next came an error message, that the file PicPas_AsmPic.xml could not be loaded. I tried to put the file at a number of places, but none worked. This is probably the related line Source/FormPrincipal.pas:  hlAssem.LoadFromFile('PicPas_AsmPic.xml');
I do not really know, what the default path of LoadFromFile is and how it could be set.

Thanks @mischi for testing.
Sadly my experience in Mac is NULL, and I don't have where to test.
PicPas require some folders to work. '/samples', '/units' and '/temp'. The two first exist in GitHub, so they are included in the ZIP or repository. Anyway, they have not critical files, and if PicPas doesn't found them, will create them (or try). The folder /temp, wil be created by PicPas. I will include /temp in GitHub too, in next versions.

Yes, the file PicPas_AsmPic.xml, is loaded en TfrmPrincipal.FormCreate(), and it's the highlighter for the ASM visor. It's supposed to be in the same path of the program, that's why it has no information of path. I don't know how it works on Mac, but in Windows/Linux it works right.


Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on June 04, 2017, 09:33:10 am
My solution for those problems is a config-unit that handles configuration-issues (platform depended) and also emits a DataPath to a Directory the user/program has read/write access on.
on Windows-PC it's also not advisable to put Data-Files around the binary. They should be in %APPDATA%\<Vendor>\<AppName>\ ... on unix it's normaly ~/.<appname>/ i think this also counts for Mac.
Common data in Windows should be in %ProgramData%\<Vendor>\<AppName>\

All files have the prefix DataPath+DirectorySeparator+
e.G: for 'Test.dat' it looks like
Code: [Select]
...LoadFromFile(DataPath+DirectorySeparator+'Test.dat');
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: mischi on June 04, 2017, 02:52:54 pm
The linux solution with ~/.<appname> is also possible on macOS, but not really according to the guidelines. The best place for files, which should be exchanged on an update of the program is in the application bundle. Examples are general resources of the program like icons, sounds, texts and so on. Files, which should "survive" an update should better go to ~/Library/Application Support/<appname>. Special alternatives to this are ~/Library/Logs, ~/Library/Caches, ~/Library/Preferences and maybe more. However, taking the guide lines strictly, one should not even use these paths literally, but use the corresponding calls of the system API, (for example the functions CFPreferences* or NSDefaults) although i never went that far.

I'll have a look, whether i can at least manage to load PicPas_AsmPic.xml.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 04, 2017, 06:05:15 pm
I prefer to have all the files in a single path, in order to have a simple portable app. But if this can have problems in Mac, it can be changed using {$IFDEF DARWIN} or something like this. You can make a Pull request in the GitHub, or send me the code to change.   :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 04, 2017, 06:30:06 pm
PicPas is updated to the version 0.6.7.  :D  https://github.com/t-edson/PicPas

Blocks ASM, now includes complete support for labels on instructions GOTO and CALL, and access for WORD variables.
Internal "Type Helpers" are added to the types Byte and Word:

Code: Pascal  [Select]
  1.  
  2.   byte_var.bit0 := 1;
  3.   word_var.Low.bit7 := 0;
  4.  

Thanks to @jc99, now a German translation is included. There are new terms to translate. Translation files are in path: /languages

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: majid.ebru on June 04, 2017, 08:23:19 pm
Very Goooooood ;D ;D
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: mischi on June 04, 2017, 10:57:32 pm
Update for macOS: A s a quick fix specifying absolute paths to files helps.

In addition, there is still an access error. Config is not assigned, when used in the procedure TfraSyntaxTree.ComboBoxEx1Change in file FrameSyntaxTree.pas. I do not really know, how to fix this. I tried to call Config.Inciar, but that failed.

A range check error in FameMessagesWin.pas: timeCnT should be QWord and not Dword.
Changing line 42 to

timeCnt: QWORD;

fixes the range check error.

I just saw, that both issues are fixed in 0.6.7.

MiSchi
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 04, 2017, 11:35:25 pm
Update for macOS: A s a quick fix specifying absolute paths to files helps.

Do you refer to:  hlAssem.LoadFromFile('PicPas_AsmPic.xml');  in FormPrincipal unit? I can specify the full AppPath if it helps.

In addition, there is still an access error. Config is not assigned, when used in the procedure TfraSyntaxTree.ComboBoxEx1Change in file FrameSyntaxTree.pas. I do not really know, how to fix this. I tried to call Config.Inciar, but that failed.

Can you show the stack of calls? It's not supposed to call TfraSyntaxTree.ComboBoxEx1Change() before Config is assigned. Anyway I can add:
Code: Pascal  [Select]
  1. if Config<>nil then ...
to protect.

A range check error in FameMessagesWin.pas: timeCnT should be QWord and not Dword.
Changing line 42 to

timeCnt: QWORD;

fixes the range check error.

Changed in the GitHub.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 07, 2017, 09:53:15 pm
PicPas 0.6.8 released.   :)
Improved the IDE, and the assembler output to be compatible with MPLab.
New options added to the Config Form. Word operations revised, and included the directive ORG in assembler blocks.
FAIK, PicPas have now, the best assembler support of all the PIC Compilers I have seen.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on June 08, 2017, 02:26:22 am
Next patch ...
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 08, 2017, 07:50:23 am
Next patch ...

Updated with the patch. Default language for German is English. So if a german translation is not found, the english will be used.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on June 08, 2017, 09:42:14 am
That's OK most German people learn (kind of) English at school.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Ñuño_Martínez on June 08, 2017, 10:31:24 am
A bit off-topic question.  I didn't use your compiler, but since I'm working on my very own compiler for Z80 I'm interested about how do your compiler deal with calls to BIOS that use registers as parameters and result values.

For example, to call MSX GTSTCK function I can use:
Code: [Select]
  CONST
    GTSTCK = $005D;

  FUNCTION GetStick (CONST aId: BYTE): BYTE;
  BEGIN
    ASM
      LD A, aId;
      CALL GTSTCK;
      PUSH A
    END
  END;

This would generate something like this (pseudo Z80 assembler):
Code: [Select]
; FUNCTION GetStick (CONST aId: BYTE): BYTE;
_fn_$GetStick:
  PUSH SP   ; Local variable address.
  POP IX
; LD A, aId;
  LD A, [IX - 3] ; Not sure it will work.
; CALL GTSTCK;
  CALL h005D
; PUSH A
  PUSH A
; END;
  RET

It is too much code IMO.  Doing some compiler magic:
Code: [Select]
FUNCTION GetStick (aId: __REGISTER_A): __REGISTER_A; BIOSDECL($00D5);

Wich means that parameter is 8bit register A and RESULT is 8bit register A, and routine is at address 0x00D5, so it generates similar (or same) assembler code, except that it may avoid function prologue and epiloge (i.e pushes, pops, check "RESULT" value, etc) resulting in a faster and smaller executables.

What do you think?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: marcov on June 08, 2017, 11:24:13 am
I believe there is something like that for Amiga/m68k?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 08, 2017, 04:46:39 pm
I'm working on my very own compiler for Z80 I'm interested about how do your compiler deal with calls to BIOS that use registers as parameters and result values.

First of all. There is not BIOS in a basic PIC architecture. PIC are usually alone in the world, when they work; or you define your own BIOS.

PIC compilers don't use hardware stacks, because there is not hardware stack for registers in the basic PIC architecture. PicPas, like others PIC compilers, use global variables to pass parameters. However, to return a function result, PicPas use the W register (the only Work register PIC have), some flag, of the STATUS register, and if needed anothers, PicPas define some bytes in RAM, reserved to be used like "Work registers" [1]. 

It is too much code IMO.  Doing some compiler magic:
Code: [Select]
FUNCTION GetStick (aId: __REGISTER_A): __REGISTER_A; BIOSDECL($00D5);

Yes. I think it's ok. It's some like external function definition. If you can do: the compiler make your life easy, well, do it. Maybe the problem here is, How to implement this in the best Pascalish way? I mean, without destroys the conventional and the spirit of the language. One detail, the identifier "__REGISTER" have some C-ish style, for me.

PicPas, have a way to use "Work Registers" like parameters:

Code: Pascal  [Select]
  1. procedure QuickParameterProc(REGISTER regvar: byte);
  2.  

This will force the compiler to use the W register for pass the parameter. In PicPas, there is not need to specify the register, because there is only one (W). When use variables WORD, PicPas, would use W, and some other RAM "Work register".

All functions use the "Work registers" to return results, so there is no need to specify.

By the way, implementing calls to a BIOS, means to me, that the compiler will be restricted to compile only for that BIOS. I recomend to think the Z80 could work too, in other hardware enviroments, without change, too much, the convention for BIOS calls.

[1] Inside PicPas documentation "Work register" is a term to refers to a register always available, and used to make calculations and return operations results, something like A, B, C, D, in Z80. PicPas use the term "RAM register" to refer the other bytes in RAM used like common RAM.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Ñuño_Martínez on June 09, 2017, 09:39:40 am
Thanks for the comments.
I believe there is something like that for Amiga/m68k?
It sould. FPC main page says it has m68k as one of the targets. (https://www.freepascal.org/)  Unfortunatelly I haven't study FPC sources yet.  There are too much files for me. %)

(...) One detail, the identifier "__REGISTER" have some C-ish style, for me.
You're right.  I'm still defining the internal API.  I also like to do it the most Pascalish as possible.

By the way, implementing calls to a BIOS, means to me, that the compiler will be restricted to compile only for that BIOS. I recomend to think the Z80 could work too, in other hardware enviroments, without change, too much, the convention for BIOS calls.
The idea is to do something similar to FPC:  Using some compiler magic (i.e. -T<target> compiler option) combined with RTL units to implement different targets.  I talk about MSX because it is the only one I know but there's people with interest in other platforms (ZX, GameBoy and a custom devices).  Anyway I think version 1.0 will use ASM ... END blocks only, as I show in my first example.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: andersos on June 09, 2017, 10:18:51 am
I recently started to learn developing for PIC microcontroller. As I never used C I looked which other languages could be used and first I found that other Pascal for PIC compiler, but then I thought about Lazarus which I started to use a couple of years ago instead of Delphi, and here we are. It looks great so far. But how long could it be until some of the limitations of PicPas are solved? Arrays, records, float and interruption for example.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 09, 2017, 05:44:20 pm
It looks great so far. But how long could it be until some of the limitations of PicPas are solved? Arrays, records, float and interruption for example.

Well, PicPas has been advancing very fast in the last weeks :) . Al least one version per week. At this speed, records would be implemented in one ot two moths, and other two months for arrays or interrupts.

But I cannot promise I will be maintaining the same speed  :-\. PicPas is developed in my free time. But it's an open source project and everybody can contribute (like some people do on testing and translation). If you have assembler experience, you can implement some operations in the PicPas code generator. Anyway there is differents ways to collaborate.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: andersos on June 09, 2017, 05:49:13 pm
Sounds good. I can contribute, but not with assembler. Do you need Swedish translation for example?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: marcov on June 09, 2017, 06:07:33 pm
Thanks for the comments.
I believe there is something like that for Amiga/m68k?
It sould. FPC main page says it has m68k as one of the targets. (https://www.freepascal.org/)  Unfortunatelly I haven't study FPC sources yet.  There are too much files for me. %)

From rtl/amiga/m68k/doslibf.pas:

Code: [Select]
function Open(fname     : PChar   location 'd1'; accessMode: LongInt location 'd2'): LongInt; SysCall AOS_DOSBase 30;

d1 and d2 are m68k registers.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 09, 2017, 08:05:34 pm
Sounds good. I can contribute, but not with assembler. Do you need Swedish translation for example?

Good  :). You can add the Swedish translation. The translation in PicPas is some different from other programs, but it is easy to add a new language.

You just need to add a new parameter with the Swedish translation (after the German translation), to the function Trans() in all files in the /language folder in: https://github.com/t-edson/PicPas

Then you can generate a Pull request or send me the patch, to update the source. If ypu have problem, you can ask me.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on June 10, 2017, 12:09:21 pm
Next Update:

BTW:
The Converter to im-/and export [edit] po-files (of cause)[/edit] is on my repo:
https://github.com/joecare99/Public/tree/master/Diverses/FPC -> Prj_PicPas2Po.*
https://github.com/joecare99/Public/tree/master/Diverses/Source/PicPas2Po *

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Ñuño_Martínez on June 12, 2017, 01:33:18 pm
Thanks for the comments.
I believe there is something like that for Amiga/m68k?
It sould. FPC main page says it has m68k as one of the targets. (https://www.freepascal.org/)  Unfortunatelly I haven't study FPC sources yet.  There are too much files for me. %)

From rtl/amiga/m68k/doslibf.pas:

Code: [Select]
function Open(fname     : PChar   location 'd1'; accessMode: LongInt location 'd2'): LongInt; SysCall AOS_DOSBase 30;

d1 and d2 are m68k registers.
Thanks. :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: mischi on June 12, 2017, 10:05:09 pm
Hi.

I noticed that Github probably has duplicates of files, which only differ in uppercase/lowercase spelling, like globales.pas and Globales.pas or is this on purpose?

Other candidates are formprincipal.* and  formpicexplorer.*. Maybe clean up the repository.

I needed to start from scratch for macOS, because i had not used GitHub in my first trials. After some adjustments I have the app running again.

MiSchi
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 12, 2017, 10:28:33 pm
I noticed that Github probably has duplicates of files, which only differ in uppercase/lowercase spelling, like globales.pas and Globales.pas or is this on purpose?

Other candidates are formprincipal.* and  formpicexplorer.*. Maybe clean up the repository.

Thanks for the information. I will revise it.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 12, 2017, 11:28:00 pm
Maybe clean up the repository.

OK. Repository is cleaned.  Tell me if you find some strange file, maybe I need to clear my local project.  :-\

Next Update:

Updated.

BTW:
The Converter to im-/and export [edit] po-files (of cause)[/edit] is on my repo:
https://github.com/joecare99/Public/tree/master/Diverses/FPC -> Prj_PicPas2Po.*
https://github.com/joecare99/Public/tree/master/Diverses/Source/PicPas2Po *

I will check it later. I will analyze if it's better to migrate to Po files.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 14, 2017, 06:52:27 pm
PicPas is updated to the version 0.6.9.  :D  https://github.com/t-edson/PicPas

Functions are implemented, at the style of Modula-2:

Code: Pascal  [Select]
  1. procedure MyFunc(par1: byte): byte;
  2. begin
  3.   exit(par1+1);
  4. end;
  5.  

The RAM banking is improved when using procedures, and new Compiler options are added to the Config dialog.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: majid.ebru on June 14, 2017, 10:23:00 pm
Hi and thank you for this program
.
do you make any help file for this program?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 14, 2017, 11:11:27 pm
Hi and thank you for this program
.
do you make any help file for this program?

Hi. There are a technical doc (108 pages) and a User Manual (47 pages) in the /docs folder, but they are in spanish. Maybe someone can help on translation  :-\.
 
PicPas has not some kind of CHM help Files.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 22, 2017, 08:55:22 pm
PicPas, the only one Open-source Pascal compiler for PIC, has been updated to the version 0.7.0.   :) https://github.com/t-edson/PicPas

New configuration options has been added to the interfaz.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 01, 2017, 11:34:31 pm
PicPas has been updated to the version 0.7.1.  :D News:

- Automatic Syntax Checking. While typing!  8-).
- Basic support for interrupts.
- Char literals in ASM blocks
- Code Tool implemented to locate variables declaration.
- Code-completion improved.
- New PIC devices supported
...

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 07, 2017, 08:03:00 am
Thanks for the nice compiler. But I'm still not able to compile the sample-programs, like BlinkLed. The compiler gives error-message "BlinkLed[15,5]Error:";"expected."
If I replace the "while true do begin"-loop by "repeat / until false" it works. What do I'm wrong with the original sample-file, why this error-message?
With best regards
Erni
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 07, 2017, 04:41:35 pm
But I'm still not able to compile the sample-programs, like BlinkLed. The compiler gives error-message "BlinkLed[15,5]Error:";"expected."
If I replace the "while true do begin"-loop by "repeat / until false" it works. What do I'm wrong with the original sample-file, why this error-message?

My fault.  :o I haven't updated the samples since several versions ago. The samples BlinkLed.pas and Compuerta.pas are using the old Pascal syntax for WHILE:

Code: Pascal  [Select]
  1. WHILE ... DO
  2.   BEGIN
  3.     ...
  4.   END;

But the recents versions of PicPas works with the new Modula-2 syntax:

Code: Pascal  [Select]
  1. WHILE ... DO
  2.   ...
  3. END;

PicPas requires the directive {$MODE PASCAL} to work with the old Pascal syntax.

I have updated the samples. Check the GitHub.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 07, 2017, 06:47:40 pm
Thank you very much for the fast response!
Please allow me a very different question:
What do you think about a Pascal-Compiler for the STM8-Microcontroller? There are very cheap and powerful boards with the STM8S103F3P6.
Such a Pascal-Compiler for this board would be very nice!
Again, thank you for the great work for your PIC-Compiler!
Erni
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 07, 2017, 08:58:18 pm
What do you think about a Pascal-Compiler for the STM8-Microcontroller? There are very cheap and powerful boards with the STM8S103F3P6.
Such a Pascal-Compiler for this board would be very nice!
I'm sure STM8 is a good Microcontroller. It's just I haven't had the necessity of this device. In my country we most use Arduino and PIC.  :-[
A STM8 compiler would be interesting, but It's a lot of work. Compilers are not simple programs.  :o
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 08, 2017, 08:10:05 am
Yes, I understand. I can imagine how much time is necessary to write a compiler.
The STM8 is a very different controller-family to the PICs, and working at two compilers at the same time must be confusing.
Thanks for your great work and for sharing it to us!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 08, 2017, 09:33:00 pm
Thanks for your great work and for sharing it to us!

You're welcome.

Recently PicPas has updated to the version 0.7.2. Location of errors in source code is tuned and RAM banking is improved in conditionals.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on July 09, 2017, 10:43:50 pm
German translation:
See pull-request ...
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 10, 2017, 04:31:39 am
German translation:
See pull-request ...

Updated  :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 14, 2017, 08:17:47 pm
Hello, here my first real PicPas application. It works!
Erni
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 14, 2017, 10:53:46 pm
Hello, here my first real PicPas application. It works!
Erni

Excelent. A very good application. Feel free to make suggestion about the compiler.

Quote
This program uses 3 bytes of RAM (4,7%) and 44 bytes of FLASH (4,3%)

PicPas is probably, the most optimized compiler for the Mid-Range PIC.  :D
MikroPascal and MikroC would have used at least, 16 bytes of RAM.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 15, 2017, 09:22:59 am
OK, here is my wishlist:
The black background maybe very hacker-like, but it's hard to read.
At first I had to edit the colors. I like the blue background or the white,
that was in the first versions of PicPas and shown on the Github-Page.
So I wish a few loadable skins :)

A binary notation for numbers, like 01101001B or %01101001.
This makes bit-settings in the registers easyer.

A menu to setup the config-word.
Now I have to set the Config-Word with the programmers menu (WinPicPro),
but it should be stored in the HEX-file by the compiler.

The download button to run the external flash-program (or a batch-file).
It can execute the PicKit2-Commandline-Tool for example
and has to give the parameters for file-path, file-name, file-ext
and the processor.

One of my wishes is allready done: Version 0.72 runs on my old workbench
computer with Win-XP SP3 :).
The first versions of PicPas didn't, needed Win-7.

Thank you!
Erni
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 15, 2017, 06:39:13 pm
So I wish a few loadable skins :)
Yes. It's projected to include themes. It's not so complicated.
By the moment, you can save your "skin" just copying the file "PicPas-win32.xml". It includes all the settings including the appearance.

A binary notation for numbers, like 01101001B or %01101001.
There is a binary notation: %01101001
And hexa notation: $FF

A menu to setup the config-word.
Now I have to set the Config-Word with the programmers menu (WinPicPro),
but it should be stored in the HEX-file by the compiler.

Yes. This is something useful. Easy to implement. Maybe in the next version.  :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 16, 2017, 06:48:20 pm
The download button to run the external flash-program (or a batch-file).
It can execute the PicKit2-Commandline-Tool for example
and has to give the parameters for file-path, file-name, file-ext
and the processor.

I haven't realized that this simple adition can be very useful. This is easy to implement too. Something like "Run External Tool" or something like tihis. I will consider for the next version.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 16, 2017, 07:34:10 pm
Hello Edson,
sorry for not reading the documentation. I tried the wrong binary notation only,
that was stupid.
A "Run External Tool"-menu is a good idea. Please allow more user-entries for
different programs to execute :)
I just finished my second project with PicPas, a speed-controller for my PCB-drill.
It holds the speed stable, also with a PIC 12F629.
I tested it on a breadboard, it works very well.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jc99 on July 16, 2017, 09:05:58 pm
Hi I started to translate the documentation to english ... I started with the Usermanual ...
(also in my repo ... )
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: majid.ebru on July 17, 2017, 07:14:50 am
Hi I started to translate the documentation to english ... I started with the Usermanual ...
(also in my repo ... )

Thank You
 :-* :-* :-*
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 17, 2017, 05:39:09 pm
Hi I started to translate the documentation to english ... I started with the Usermanual ...
(also in my repo ... )

Very good  :). It was something missing in PicPas. Thanks.

A "Run External Tool"-menu is a good idea. Please allow more user-entries for
different programs to execute :)
OK. I will consider it.

I just finished my second project with PicPas, a speed-controller for my PCB-drill.
It holds the speed stable, also with a PIC 12F629.
Do you have some repository for your code? I would like to see it.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 17, 2017, 09:16:33 pm
Hello Edson,
I can upload the project zip-file here, but I have to draw
the schematic and do some documentation before.
To do this, I need the next weekend...

Thanks to jc99 for the translation!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 23, 2017, 01:32:46 pm
Hello Edson,
here the requested documents for the PCB-Drill-Controller uploaded.
Thanks for your interest, please have a look!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on July 23, 2017, 07:22:15 pm
Hello Edson,
here the requested documents for the PCB-Drill-Controller uploaded.
Thanks for your interest, please have a look!

Excelent. Do you have it published in some site?
I would like to include a link in mi GitHub page. Or I can include your project in my GItHub if not.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Erni on July 23, 2017, 08:21:45 pm
Please put it to your PicPas-Project, if you want!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on August 04, 2017, 08:32:49 pm
Please put it to your PicPas-Project, if you want!
OK, It's included in the /sample folder.

Thanks for share your project.  :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on August 07, 2017, 05:48:48 pm
PicPas 0.7.3 has been released.  :D  https://github.com/t-edson/PicPas

News:

- Directives $CONFIG, $INCLUDE, $DEFINE and $IFDEF/$IFNDEF/$ELSE/$ENDIF implemented
- Error location improved for ASM and  DIRECTIVES blocks.
- Macros and conditional compilation implemented  (experimental).
- External Tools configuration implemented.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on August 21, 2017, 05:41:19 pm
PicPas has been updated to the 0.7.4 version:  https://github.com/t-edson/PicPas

News:
- Highlighting of multiples errors.
- Support for themes.
- More setting options.
- New operations implemented.
- New registers for 32 bits operations.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on August 25, 2017, 09:43:07 pm
Picpas has been updated to the 0.7.5 version:  https://github.com/t-edson/PicPas

Support for 32 bits numbers, implemented.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on August 27, 2017, 08:28:46 pm
Recently, I have tested the size of code generated by  several PIC compilers, in comparison with PicPas. The same sample program (a simple light control: https://github.com/t-edson/PicPas/tree/0.7.5/Comparacion%20PicPas-MikroC-CCS) was compiled in these programs:

The result was:

MikroC
======
RAM: 18 bytes   FLASH: 126 words

CCS
=====
RAM: 7 bytes   FLASH: 135 words

JAL
========
RAM: 9 bytes  FLASH: 117 words

Pic Micro Pacal
===============
RAM: 4 bytes FLASH: 104 words   

PicPas
======
RAM: 2 bytes   FLASH: 64 words

And the winner is: PicPas :D
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on September 18, 2017, 10:57:45 pm
Picpas 0.7.7, the unique open-source Pascal compiler for mid range PIC, has been released:  https://github.com/t-edson/PicPas

In this version, support for defining new devices using directives.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jaromir on September 28, 2017, 04:21:10 pm
Hello,
I noticed there are no Linux precompiled binaries in few last releases. I'd compile them on my own, but unfortunately I'm not clear about how to compile it.
Could you, please, clarify how to compile it?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on September 28, 2017, 05:11:28 pm
Hello,
I noticed there are no Linux precompiled binaries in few last releases. I'd compile them on my own, but unfortunately I'm not clear about how to compile it.
Could you, please, clarify how to compile it?

Oh Yes. Most of the users of PicPas just use Windows, so I don't update to much the Linux version.
But building the project is easy. PicPas use just a few libraries:

* SynFacilUtils
* MisUtils
* MiConfig
* PicUtils
* Xpres
* UtilsGrilla

All of them, are availables on my GitHub site. Check the versions used.

These libraries don't include package. They are only files in folders that need to be included when compiling PicPas.

Tell me if you have some problem when compiling.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: jaromir on September 28, 2017, 06:44:43 pm
So I need Lazarus with those libraries, OK I got it now. I looked for a makefile or build script, that is why I was confused.
I'll try it and share results/comments.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on September 28, 2017, 06:54:55 pm
OK I have compiled a version for Ubuntu. It's in the 0.7.8 trunk version: https://github.com/t-edson/PicPas/tree/0.7.8

It's using an old style skin.  PicPas support themes  8-)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on October 03, 2017, 05:14:17 pm
PicPas 0.7.8 has been released: https://github.com/t-edson/PicPas

Implemented the TYPE section:

Code: Pascal  [Select]
  1. TYPE
  2.   my_type = byte;
  3.   TArrBytes = array[5] of byte;
  4.  

Only arrays of bytes supported by now.  :-X

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Sender on October 24, 2017, 11:26:50 pm
Hi Edison, PicPas Cool project.
Change please settings in Main Form (TfrmPrincipal and TConfig dialog):
 
object inspector\Position = poScreenCenter (or TConfig Position = poMainFormCenter)

Thaks
Best regards
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on October 25, 2017, 01:05:29 am
Change please settings in Main Form (TfrmPrincipal and TConfig dialog):
 
object inspector\Position = poScreenCenter (or TConfig Position = poMainFormCenter)

OK. It will be changed in the 0.8.0 version, that is going to be released soon.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on November 04, 2017, 06:16:13 am
PicPas (https://github.com/t-edson/PicPas) the Open Source Pascal compiler for the Middle range Microchip Microcontrollers, is progressing fast. Now in the version 0.8.0. includes a software debugger and simulator. The simulation can be done in real time, for the maximum clock frequency of the device, in a simple PC.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Sender on November 05, 2017, 05:08:29 pm
Hi Edson, very good. The same problem in debug window (bad shoving and TEXT).Look please in all Forms setting.Thx.


Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on November 05, 2017, 05:51:05 pm
I see. The Interfaz is not prepared, in some parts to adapt to the font size. It's sttange. I expected the StringGrid used, would adapt well to the font size. Maybe you have set a big font on your system.

Did you see the same problem in the settings form? Can you send a picture?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Sender on November 05, 2017, 09:09:53 pm
Yes.Problem is system font setting (125%).
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on November 06, 2017, 06:45:55 pm
I see most of the forms are OK, considering the big size of the font. Maybe the simulator window, must be reviewed and resized. I will check.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: boz on November 06, 2017, 07:47:25 pm
Looks very nice. great Work.

I migrated from Mikropascal to MPLABX/XC8 about 6 years ago and these days I mostly use the newer PIC32 and 18F26K42 in my embedded projects.

I do have a current open source project that uses a larger 16F18857 device (http://rodyne.com/?p=844) it would be nice to try making a more complicated project for this (I hate string support in C!) are there any plans to support these newer bigger chips or (as there are so many) are there plans to allow us to configure our own chips?

Boz
Roving Dynamics Ltd
www.rodyne.com


Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on November 06, 2017, 10:24:52 pm
Hi @boz.

Currently PicPas only support the Mid-Range PIC MCU, like PIC16F887 or PIC16F628. One interesting feature of PicPas is that new devices can be defined usign hardware directives. So theoretically, PicPas can support all devices of the Mid-Range core MCU.

The project PicPas is just beginning, it is in a beta status. I have plans to include the Enhanced Mid-Range and the 18F family of MCU. But it depends on my free time, so probably it won't be soon.

Anyway, this is an open source project so collaborations are welcome.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Laksen on November 06, 2017, 10:39:49 pm
I know it's not a good question, but I often wonder why people use PIC controllers. What keeps you using them?

They aren't really cheap, and the architecture is not suited for compilers or humans.
Some say they are great for noisy environments, but anything running that slow will work in a noisy environment.

Creating a compiler for it is a great feat for sure. So kudos for the project  :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: boz on November 06, 2017, 11:06:50 pm
I also use AVR, PIC32, ARM and 8051s in my work. You choose the best fitting and most cost effective for your project and not limit yourself based on an particular bias, at the higher level (C/C++) they all work very similar to me. In this case I have a lot of PIC micros returned by the CM from a previous project so I am using them.

I also drink Pepsi sometimes instead of coke and sometimes drive Japanese cars over European ones, I'm probably too old to worry about being trendy or I probably wouldn't be using Pascal :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Laksen on November 06, 2017, 11:16:00 pm
I also use AVR, PIC32, ARM and 8051s in my work. You choose the best fitting and most cost effective for your project and not limit yourself based on an particular bias, at the higher level (C/C++) they all work very similar to me.
Fair enough, but still I wonder what application you find the PIC saves you time or money?

Quote
In this case I have a lot of PIC micros returned by the CM from a previous project so I am using them.
If you have a bunch of micros in stock that are just going to lose value then and they could be used for something. Sure. But buying new of them? Unless you sell in the 100k region of boards I really wonder how good of a price you can get on them?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: boz on November 07, 2017, 01:22:38 am
Hi @boz.

Currently PicPas only support the Mid-Range PIC MCU, like PIC16F887 or PIC16F628. One interesting feature of PicPas is that new devices can be defined usign hardware directives. So theoretically, PicPas can support all devices of the Mid-Range core MCU.

The project PicPas is just beginning, it is in a beta status. I have plans to include the Enhanced Mid-Range and the 18F family of MCU. But it depends on my free time, so probably it won't be soon.

Anyway, this is an open source project so collaborations are welcome.
Thanks

I see the hardware files in the projects units folder it seems very clean to add another device but it looks like you need to know pic16 assembly which I dont.  I am used to C Headers and libraries being available to abstract a lot of the hardware, I'm very familiar with the control registers on the PIC16 and know how to read the datasheet to get things done but I last used assembly on the 8051 in 1987 so I am not sure I am skilled enough to do this, maybe I will have another look when I get some down-time.

Keep up the great work.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on November 07, 2017, 02:57:12 am
I see the hardware files in the projects units folder it seems very clean to add another device but it looks like you need to know pic16 assembly which I dont.  I am used to C Headers and libraries being available to abstract a lot of the hardware, I'm very familiar with the control registers on the PIC16 and know how to read the datasheet to get things done but I last used assembly on the 8051 in 1987 so I am not sure I am skilled enough to do this, maybe I will have another look when I get some down-time.
No need to know ASM, to add a new device. You can define it in the same source code.

The following example, taking from the User Manual, defines a new PIC16F84 devices, with more FLASH memory:

Code: Pascal  [Select]
  1. program MiPICprogram;
  2. //Defines basic hardware
  3. {$SET PIC_MODEL='MIPIC'}
  4. {$SET PIC_MAXFREQ = 1000000}
  5. {$SET PIC_NPINS = 18}
  6. {$SET PIC_NUMBANKS = 2}
  7. {$SET PIC_NUMPAGES = 1}
  8. {$SET PIC_MAXFLASH = 2048}
  9. //Clear the RAM setting
  10. {$SET_STATE_RAM '000-1FF:NIM'}
  11. //Defines RAM state
  12. {$SET_STATE_RAM '000-00B:SFR, 00C-04F:GPR'}
  13. {$SET_STATE_RAM '080-08B:SFR, 08C-0CF:GPR'}
  14. //Defines mapped RAM
  15. {$SET_MAPPED_RAM '080-080:bnk0, 082-084:bnk0, 08A-08B:bnk0'}
  16. {$SET_MAPPED_RAM '08C-0CF:bnk0'}
  17. //Defines unimplemnted bits in RAM
  18. {$SET_UNIMP_BITS '003:3F,083:3F,005:1F,085:1F,00A:1F,08A:1F'}
  19.  
  20. {$FREQUENCY 4Mhz}
  21. begin
  22.  
  23. end.
  24.  
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on November 14, 2017, 03:08:17 pm
PicPas has done again  :D. It's the best, optimizing the code size for the Mid-Range PIC, according to a new competition, against the best profesional compilers: https://github.com/AguHDz/PicPas-Librerias_y_Programas/tree/master/Compativa%20Compiladores%20II

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: marcov on November 14, 2017, 03:29:31 pm
I also use AVR, PIC32, ARM and 8051s in my work. You choose the best fitting and most cost effective for your project and not limit yourself based on an particular bias, at the higher level (C/C++) they all work very similar to me.
Fair enough, but still I wonder what application you find the PIC saves you time or money?


Compared to what? For me the 144 pins devices and crossbarswitch for peripherals in dspic (dspic33ep512mu814) allows me to make a generic board, and for experiments and test situations do a modular expansion 

I played with PIC32MK this summer, and rejected it. The CPU seems to be slower. (despite being a 120MHz over 70MHz, it feels like 40MHz)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: bigbo on January 10, 2018, 11:58:48 pm
Please reserve two more languages after German, I started to translate to Ukrainian and Russian.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 11, 2018, 05:20:55 am
Please reserve two more languages after German, I started to translate to Ukrainian and Russian.

OK, I will reserve space for Ukrainian and Russian.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 11, 2018, 10:53:23 pm
Space added in the Source for Ukrainian and Russian languages.  :D

You can add the translation after the tags:
#uk=
#ru=

Is someone can add French, Italian or Portugues, please tell me.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: bigbo on January 12, 2018, 01:12:47 pm
Here are the files with UA and RU. It seems the translations are okay, but I think I have to improove them later, during my work with the Compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 12, 2018, 07:14:56 pm
Here are the files with UA and RU. It seems the translations are okay, but I think I have to improove them later, during my work with the Compiler.

Updated.  :D

Now PicPas (IDE and compiler) have translations to English, Spanish, German, Ukranian, Russian and quechua.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: bigbo on January 12, 2018, 11:43:20 pm
This code from examples:

Code: Pascal  [Select]
  1. {Sample program to read a digital input
  2. in PORTB.4 and put the value in PORTB.5}
  3. {$FREQUENCY 4 MHZ }
  4. {$PROCESSOR PIC16F84A}
  5. program BlinkLed;
  6. var
  7.   PORTB : BYTE absolute $06;
  8.   TRISB : BYTE absolute $86;
  9.   //pin: bit absolute PORTB.7;
  10. begin                          
  11.   SetAsInput(PORTB.4);
  12.   SetAsOutput(PORTB.5);
  13.   while true do
  14.    //delay_ms(1);
  15.     PORTB.5 := PORTB.4;
  16.   end;
  17. end.

After I compiled I got this ASM code:

Code: Pascal  [Select]
  1.     list     p=16F84A
  2.     #include <p16F84A.inc>
  3. ;===RAM usage===
  4. PORTB EQU 0x006
  5. ;------ Work and Aux. Registers ------
  6. ;===Blocks of Code===
  7.     0x000 goto 0x001
  8. __main_program__:
  9.     ;SetAsInput(PORTB.4);
  10.     0x001 bsf 0x003, 5 ;Bank set.
  11.     0x002 bsf PORTB, 4
  12.     ;SetAsOutput(PORTB.5);
  13.     0x003 bcf PORTB, 5
  14.     ;PORTB.5 := PORTB.4;
  15.     0x004 bcf 0x003, 5 ;Bank set.
  16.     0x005 bcf PORTB, 5
  17.     0x006 btfsc PORTB, 4
  18.     0x007 bsf PORTB, 5
  19.     ;end;
  20.     0x008 bsf 0x003, 5 ;Bank set.
  21.     0x009 goto 0x004
  22. __end_program__:
  23.     ;end.
  24.     0x00A sleep  
  25. ;--------------------
  26.     END

Clear bit before checking?

Code: Pascal  [Select]
  1.     0x005 bcf PORTB, 5

In case if 1 on PORTB.4, output PORTB.5 will make fast pulsation? Is it right?
I think will be right to make any changes in result only AFTER checking of input value.
Tried to simulate in Proteus, and found my laptop have not enough power to simulate this fast pulsation  :(
Am I right?

PS We can see it in ASM Debugger if we change the string to PORTB.5 := not PORTB.4;
PORTB.5 blinking because there bcf PORTB, 5 before btfss PORTB, 4
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 13, 2018, 05:19:24 am

Code: Pascal  [Select]
  1.     0x005 bcf PORTB, 5

In case if 1 on PORTB.4, output PORTB.5 will make fast pulsation? Is it right?
I think will be right to make any changes in result only AFTER checking of input value.
Tried to simulate in Proteus, and found my laptop have not enough power to simulate this fast pulsation  :(
Am I right?

PS We can see it in ASM Debugger if we change the string to PORTB.5 := not PORTB.4;
PORTB.5 blinking because there bcf PORTB, 5 before btfss PORTB, 4

You are right. The code to copy bit PORTB.4 to PORTB.5:

    0x005 bcf PORTB, 5
    0x006 btfsc PORTB, 4
    0x007 bsf PORTB, 5

Could cause a fast pulse on PORTB.5.
It's usually not important, but It could be problematic in some cases.

This code was generated to be fast and smaller, considering that there are not instructions to copy bits. A more secure code will use more instructions.

But if you have a good proposal, I can include it in the code generator. Or maybe you can modify the source. It's in the method TGenCod.ROB_bit_asig_bit() in the unit GenCod.pas.

I think It can be defined as an additional optimization parameter that in mode "fast" use this algorithm and in mode "slow" can use a more secure code.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: AnthonyTekatch on January 13, 2018, 01:31:59 pm

You are right. The code to copy bit PORTB.4 to PORTB.5:

    0x005 bcf PORTB, 5
    0x006 btfsc PORTB, 4
    0x007 bsf PORTB, 5

Could cause a fast pulse on PORTB.5.
It's usually not important, but It could be problematic in some cases.

...

I think It can be defined as an additional optimization parameter that in mode "fast" use this algorithm and in mode "slow" can use a more secure code.

If that code was in a loop, then there would be a constant "pulsing" which would result in a pulse width modulated output and lower average voltage.

Maybe something like this which only adds one instruction:
    0x001 btfsc PORTB, 4
    0x002 bsf PORTB, 5
    0x003 btfss PORTB, 4
    0x004 bcf PORTB, 5

I think this should be the normal operation. And, an optimization switch could be to enable your original method of speed while sacrificing output consistency.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 13, 2018, 06:12:52 pm
If that code was in a loop, then there would be a constant "pulsing" which would result in a pulse width modulated output and lower average voltage.

Maybe something like this which only adds one instruction:
    0x001 btfsc PORTB, 4
    0x002 bsf PORTB, 5
    0x003 btfss PORTB, 4
    0x004 bcf PORTB, 5

I think this should be the normal operation. And, an optimization switch could be to enable your original method of speed while sacrificing output consistency.

Good code. I will check to include.

Just note that this is a problem only when using bit assigment in external PORT.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: bigbo on January 22, 2018, 07:22:34 pm
Code: Pascal  [Select]
  1. var
  2.   a, b : byte;
  3. begin
  4.   a:=1;
  5.   b:= a div 0;
  6. end.

No error in this case.

Code: Pascal  [Select]
  1. var
  2.   a, b : byte;
  3. begin
  4.   a:=0;
  5.   b:= 1 div a;
  6. end.

No error in this case.

Code: Pascal  [Select]
  1. var
  2.   a, b : byte;
  3. begin
  4.   b:= 1 div 0;
  5. end.

The error is appears. I mean "Cannot divide by zero."
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 23, 2018, 01:18:18 am
The case:

Code: Pascal  [Select]
  1.     var
  2.       a, b : byte;
  3.     begin
  4.       a:=1;
  5.       b:= a div 0;
  6.     end.
  7.  

Must give error in compialtion time. I will fix.

But the case:

Code: Pascal  [Select]
  1.     var
  2.       a, b : byte;
  3.     begin
  4.       a:=0;
  5.       b:= 1 div a;
  6.     end.
  7.  

Is a Runtime error. The compiler doesn't generate Runtime checking routines. The memory of the PIC is too small, and there is not a secure way to inform this error.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 23, 2018, 03:23:33 pm
Fixed the case:

Code: Pascal  [Select]
  1.     var
  2.       a, b : byte;
  3.     begin
  4.       a:=1;
  5.       b:= a div 0;
  6.     end.

Now it generates error in compilation time.   :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: CaptBill on February 14, 2018, 04:36:19 am
PicPas has been updated to the version 0.6.0  :D. All bit operation implemented, more optimization code included, tree syntax improved, parameters of procedures implemented, interfaz modified,  and many other features more.

Very nice!! You've been busy!

What is the graphical emulator you are using in the background? Is that a third party tool?

The debugger is fantastic. What more could you want?

Bravo!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: CaptBill on February 14, 2018, 04:51:44 am
I know it's not a good question, but I often wonder why people use PIC controllers. What keeps you using them?

They aren't really cheap, and the architecture is not suited for compilers or humans.
Some say they are great for noisy environments, but anything running that slow will work in a noisy environment.

Creating a compiler for it is a great feat for sure. So kudos for the project  :)

Probably because, in reality, these chips comprise something like 90% of real world application in actual products. It is your basic, no frills workhorse of a microcontroller. The fact that it is a well established RISC design makes it very easy to fully understand by one person. It's staying power is it's great simplicity.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: CaptBill on February 14, 2018, 07:04:59 am
Hi Edson,
Here is a translation to English of the excellent UART example. Hope it helps.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on February 14, 2018, 05:01:42 pm
What is the graphical emulator you are using in the background? Is that a third party tool?

The debugger is fantastic. What more could you want?

Bravo!
Thanks.

* The emulator is just a front-end to my library: https://github.com/t-edson/PicUtils
* The graphical interfaz is implemented using my library: https://github.com/t-edson/ogEditGraf

All third party libraries used in PicPas are mines, by now.  :-X

PicUtils is a library that define a complete class modeling a PIC device, and some routines to facilitate the compiling, emulation and memory management of the MidRange PIC devices. In fact when compiling using PicUtils, it compiles directly to the FLASH memory of the  model, so emulate the execution is so simple as execute the method pic.Exec().

ogEditGraf is a library that implement a graphical Editor with objects, and the common operations like move, select, delete, highlight, zoom, ... It's more complex that it appears here. The graphical interfaz of the PicPas emulator is still very simple.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on February 14, 2018, 09:52:33 pm
Hi Edson,
Here is a translation to English of the excellent UART example. Hope it helps.

Updated in the GitHub.

Thanks
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: CaptBill on February 15, 2018, 08:37:27 pm
Hi Edson,

Do you plan on implementing the set type or are sets to high level for the PIC?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on February 16, 2018, 04:31:48 am
Hi Edson,

Do you plan on implementing the set type or are sets to high level for the PIC?

Yes it's in my plans. Probably it will take some time. First I have to finish implementing arrays and pointers.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on February 24, 2018, 07:24:01 pm
PicPas, my cross-platform Pascal compiler for Microchip PIC, is growing. Now in the version 0.8.3, it improves the disassembling and includes some adiitonal optimizations in RAM use. https://github.com/t-edson/PicPas
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: AnthonyTekatch on February 25, 2018, 12:52:04 am
PicPas, my cross-platform Pascal compiler for Microchip PIC, is growing. Now in the version 0.8.3, it improves the disassembling and includes some adiitonal optimizations in RAM use. https://github.com/t-edson/PicPas

Looks intriguing.

The README.md describes a file called PicPas-linux, but I could not find that in your github repository.

Compiling from source gives this error:
  FormPrincipal.pas(11,3) Fatal: Cannot find SynFacilHighlighter used by FormPrincipal of the Project Inspector.
Are there dependencies for source compilation?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on February 25, 2018, 04:34:44 am
The README.md describes a file called PicPas-linux, but I could not find that in your github repository.

The linux executable is "PicPas-linux". It's just I work more in Windows, so not always I build a Linux version. But you can find the executable in previous versions, in the same GitHub.

Compiling from source gives this error:
  FormPrincipal.pas(11,3) Fatal: Cannot find SynFacilHighlighter used by FormPrincipal of the Project Inspector.
Are there dependencies for source compilation?

Yes. To compile you need to download all the Third Party libraries:

..\..\_Librerias\SynFacilUtils-1.21;
..\..\_Librerias\MisUtils 0.5;
..\..\_Librerias\MiConfig 0.4b;
..\..\_Librerias\PicUtils-1.2;
..\..\_Librerias\Xpres-1.3.2;
..\..\_Librerias\UtilsGrilla 0.8;
..\..\_Librerias\ogEditGraf 1.6b

All are mine so you can find them in my GitHub.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: AnthonyTekatch on February 25, 2018, 12:22:13 pm
Yes. To compile you need to download all the Third Party libraries:

..\..\_Librerias\SynFacilUtils-1.21;
..\..\_Librerias\MisUtils 0.5;
..\..\_Librerias\MiConfig 0.4b;
..\..\_Librerias\PicUtils-1.2;
..\..\_Librerias\Xpres-1.3.2;
..\..\_Librerias\UtilsGrilla 0.8;
..\..\_Librerias\ogEditGraf 1.6b

All are mine so you can find them in my GitHub.

Thank you. Looking very good so far!

Can you put that text in the READM.md under requirements

A few notes during my compile:

..\..\_Librerias\Xpres-1.3.2;
should be
..\..\_Librerias\t-Xpres-1.3.2;

Problem: MisUtils.pas(435,10) Error: Identifier not found "FileExistsUTF8"
Cause: The function FileExistsUTF8 in the fileUtil it is depreciated.
Solution: Add  LazFileUtils unit to uses in MisUtils.pas


Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on February 25, 2018, 04:54:27 pm
Can you put that text in the READM.md under requirements

It's at the bottom of the text. Maybe it needs to be more specific.  :-\

..\..\_Librerias\Xpres-1.3.2;
should be
..\..\_Librerias\t-Xpres-1.3.2;

You're right. I use a different name for my local copy.

Problem: MisUtils.pas(435,10) Error: Identifier not found "FileExistsUTF8"
Cause: The function FileExistsUTF8 in the fileUtil it is depreciated.
Solution: Add  LazFileUtils unit to uses in MisUtils.pas

Maybe it's because of the version. PicPas 0.8.3 use "MisUtils 0.5". The default version in GitHub is 0.6. You need to select the previous version.

Tell me if you have problems. Maybe I need to update PicPas to "MisUtils 0.6".
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: AnthonyTekatch on February 25, 2018, 07:29:55 pm
It's at the bottom of the text. Maybe it needs to be more specific.  :-\
I should read more, thanks  :-[



Problem: MisUtils.pas(435,10) Error: Identifier not found "FileExistsUTF8"
Cause: The function FileExistsUTF8 in the fileUtil it is depreciated.
Solution: Add  LazFileUtils unit to uses in MisUtils.pas

Maybe it's because of the version. PicPas 0.8.3 use "MisUtils 0.5". The default version in GitHub is 0.6. You need to select the previous version.

Tell me if you have problems. Maybe I need to update PicPas to "MisUtils 0.6".

I have no problems now that I added  LazFileUtils to uses in MisUtils.pas, You will have a problem when you upgrade Lazarus/FPC (I am at 1.8.0/3.04).

Thank you, I'll keep testing it out now.
Title: Nested Cycles do not work
Post by: syrecky on March 29, 2018, 02:47:42 pm
Hi,

PisPac is a very interesting and useful tool.
I tried some examples.
Unfortunately, nested cycles do not work.

Code: Pascal  [Select]
  1. {$PROCESSOR PIC16F877A}
  2. {$FREQUENCY 8Mhz}
  3. {$MODE PICPAS}
  4.  
  5. program NestedCycle;
  6.  
  7. uses PIC16F877A;
  8.  
  9. var
  10.   a, b, c, d: byte;
  11.  
  12. begin
  13.   d := 0;
  14.   for a := 1 to 4 do
  15.     for b := a + 1 to 5 do
  16.       for c := b + 1 to 6 do
  17.         inc(d);
  18.       end;
  19.     end;
  20.   end;
  21. end.

during cycles, the variables A, B and C have bad values
at the end of cycles the variable D has a bad value 16  -  right = 20

I apologize for my English, I am Czech  :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on March 30, 2018, 07:24:55 am
Hi,
PisPac is a very interesting and useful tool.
I tried some examples.
Unfortunately, nested cycles do not work.

You are right. There is a horrible bug here  :'(. The implementation of the loop FOR was recently and it was incomplete by now.

Let me check to see what's the problem.

Thanks for test.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 02, 2018, 10:51:47 pm
PicPas 0.8.5 has released. :D
https://github.com/t-edson/PicPas
Thanks to https://github.com/cuistax, now PicPas includes french translaton and support for almost all the Mid-range PIC models: PIC10F320 PIC10F322 PIC12F609 PIC12F615 PIC12F617 PIC12F629 PIC12F635 PIC12F675 PIC12F683 PIC12F752 PIC16F73 PIC16F74 PIC16F76 PIC16F77 PIC16F83 PIC16F84 PIC16F87 PIC16F88 PIC16F610 PIC16F616 PIC16F627 PIC16F627A PIC16F628 PIC16F628A PIC16F630 PIC16F631 PIC16F636 PIC16F639 PIC16F648A PIC16F676 PIC16F677 PIC16F684 PIC16F685 PIC16F687 PIC16F688 PIC16F689 PIC16F690 PIC16F707 PIC16F716 PIC16F720 PIC16F721 PIC16F722 PIC16F722A PIC16F723 PIC16F723A PIC16F724 PIC16F726 PIC16F727 PIC16F737 PIC16F747 PIC16F753 PIC16F767 PIC16F777 PIC16F785 PIC16F818 PIC16F819 PIC16F870 PIC16F871 PIC16F872 PIC16F873 PIC16F874 PIC16F874A PIC16F876 PIC16F877 PIC16F882 PIC16F883 PIC16F884 PIC16F886 PIC16F887 PIC16F913 PIC16F914 PIC16F916 PIC16F917 PIC16F946
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: x2nie on May 03, 2018, 09:50:40 am
hi ! is it mean that we can compile a program for famous Arduino or Teensy?
Or AtTiny?





(I have no idea of what is "PIC")
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: ccrause on May 03, 2018, 06:22:41 pm
hi ! is it mean that we can compile a program for famous Arduino or Teensy?
Or AtTiny?

The fpc compiler can already compile to AVR, see wiki (http://wiki.freepascal.org/AVR_Programming).

PicPas is a different pascal compiler that targets a different controller family. Note that fpc doesn't support the PIC controller family.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 04, 2018, 05:31:29 pm
hi ! is it mean that we can compile a program for famous Arduino or Teensy?
Or AtTiny?

The fpc compiler can already compile to AVR, see wiki (http://wiki.freepascal.org/AVR_Programming).

PicPas is a different pascal compiler that targets a different controller family. Note that fpc doesn't support the PIC controller family.

Exactly. PicPas doesn't compile to AVR. Free Pascal can do it.

But PicPas is not only a compiler/IDE. It includes a debugger for PIC devices and can do simulation in Real Time. Some experimental by now.

One sustancial difference with Free Pascal, is PicPas use a different Pascal syntax, more at the style of Modula 2:

Code: Pascal  [Select]
  1. if ...  then
  2. ...
  3. end;
  4.  
  5. while ... do
  6.  
  7. end;

And PicPas have some special syntax for bit manipulation. Like a real "bit" type and access to individualy bits for byte/word/dword:

Code: Pascal  [Select]
  1. PORTA.7 := 1;
  2.  
  3. WORD1.high.bit0 := 1;
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 20, 2018, 05:04:47 pm
PicPas 0.8.6 have now experimental support for Baseline PIC (12 bits instructions)  :). This include to the microcontrollers:

PIC10F200 PIC10F200 PIC10F202 PIC10F204 PIC10F206 PIC10F220 PIC10F222
PIC12F508 PIC12F509 PIC12F510 PIC12F519
PIC16F505 PIC16F506 PIC16F526 PIC16F527 PIC16F54 PIC16F57 PIC16F59

Some functionalities have been disabled because of the limited resources this devices have (Some of they have 16 bytes of RAM)  :o.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Kays on May 20, 2018, 05:25:58 pm
[…] (I have no idea of what is "PIC")
in general programmable integrated circuit; but here the short/colloquial name for PIC μController (https://en.wikipedia.org/wiki/PIC_microcontroller)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: xterro on May 23, 2018, 11:23:08 am
Hello, when will be PIC18/24 support? Is there the plans about support this pic families?  ::)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: marcov on May 23, 2018, 11:39:40 am
pic24 and dspic(30/33) are a different (16-bit) architecture.

So is PIC32, but that one is covered by FPC.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on May 23, 2018, 08:26:38 pm
Hello, when will be PIC18/24 support? Is there the plans about support this pic families?  ::)

Currently I'm solving some issues with including the support to Baseline family (12 bit instructions Core).
Including support for this new family was some kind of experiment to redesign the architecture of PicPas to be able to include new compilers in the same IDE.
The support for the Baseline family in PicPas is supported through creating a new compiler (although sharing most of the code).
PicPas has now a new architecture that can support multiple compilers, and the next steps will be create:
* A compiler for the Enhanced 14 bits Core
* A compiler for the 18F family.

All of this families are in the group of 8 bits Micro, and by now I have not plans to include support for 24 or 32 bits Core PIC.

Anyway PicPas is opened to collaborations so if someone want to include support for a new familly, it's wellcome.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: xterro on May 24, 2018, 06:53:47 am
Thank you for your work  :)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on May 24, 2018, 11:00:37 pm
Thanks Edson, for your work ! I love PIC !!
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 03, 2018, 01:53:10 pm
Does PicPas compiler support the ENHANCED MID-RANGE CPU like 16F1825 ?
If yes, I would like to help you and write the description file for this PIC (PIC16F1825.pas)
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 03, 2018, 05:03:00 pm
Thanks Edson, for your work ! I love PIC !!
You're welcome.

Does PicPas compiler support the ENHANCED MID-RANGE CPU like 16F1825 ?
No yet. It's the next step. PicPas have now, the ability to support multiple PIC compilers in the same IDE, so it's not dificult to include a compiler for this family. The hard work would be to update some routines in the Code Generator and in the Real-time simulator.

If yes, I would like to help you and write the description file for this PIC (PIC16F1825.pas)
You can write the description file now and so, you are helping to have support for the Enhanced Mid-range family. It would be better if you write hardware description for: PIC16F1454 PIC16F1455 PIC16F1459 PIC16F1503 PIC16F1507 PIC16F1508 PIC16F1509 PIC16F1512 PIC16F1513 PIC16F1516 PIC16F1517 PIC16F1518 PIC16F1519 PIC16F1526 PIC16F1527 PIC16F15313 PIC16F15323 PIC16F15324 PIC16F15325 PIC16F15344 PIC16F15345 PIC16F15354 PIC16F15355 PIC16F15356 PIC16F15375 PIC16F15376 PIC16F15385 PIC16F15386 PIC16F1574 PIC16F1575 PIC16F1578 PIC16F1579 PIC16F1613 PIC16F1614 and some others.

Then we need ASM routines for some logical and arithmetic operations.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 03, 2018, 05:15:03 pm
Ok, I'll do what I can. It's a good project !
How do you set the config bit for the PIC ? I can't found any example in the sample folder
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 03, 2018, 05:32:54 pm
How do you set the config bit for the PIC ? I can't found any example in the sample folder

You need to use the directive $CONFIG. You can use the value directly:

Code: Pascal  [Select]
  1. {$CONFIG $3FFD}

But it's better to include macros in the description file:

Code: Pascal  [Select]
  1. {$define _CP_ON       =     0x000F}
  2. {$define _CP_OFF      =     0x3FFF}
  3. {$define _WDT_OFF     =     0x3FFB}
  4. {$define _LP_OSC      =     0x3FFC}
  5. {$define _XT_OSC      =     $3FFD}
  6.  

So we can use them in $CONFIG:

Code: Pascal  [Select]
  1. {$CONFIG _CP_OFF, _XT_OSC, _WDT_OFF }
  2. {$CONFIG _CP_OFF _XT_OSC _WDT_OFF }

Check the units in the folder "/device10" or "/device16" as an example.

IIRC in the ENHANCED MID-RANGE CPU we have until two config words. I think we can add a new directive, some like {$CONFIG2}
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 05, 2018, 10:01:29 pm
Thanks for the precisions.
One more question... Did you take in account the ID Locations of the PIC ? I see that it not appear in the description of the 16F877 (for example). If you tell me you ignored it, I will ignore it too.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 06, 2018, 01:13:12 am
PicPas doesn't use the PIC ID. I haven't found a necessity for the device ID. Probably it could be useful when including burning software.

Maybe you can define the ID in some variable, like:

Code: Pascal  [Select]
  1. {$SET PIC_ID  = 0x3027}

Later we can use that information in some application.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 06, 2018, 08:31:35 pm
Ok Edson. I'm too busy at this time, so I go slowly on the description files asked...
In fact, I'm trying to develop a program to automate the task as much as possible from existing include files. :-X
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 06, 2018, 10:26:36 pm
Ok Edson. I'm too busy at this time, so I go slowly on the description files asked...
In fact, I'm trying to develop a program to automate the task as much as possible from existing include files. :-X

No problem. It will take some time to me too, to rewrite the new compiler for the Enhanced Mid-range devices.

Now I'm working on improving the debugger/simulator of PicPas in order to have a fast way to execute the test code. This will help too to test the Enhanced Mid-range compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 08, 2018, 03:36:20 pm
I noticed that in the file PIC16F877.pas (my reference to understand how to declare a pic) there is the line:
Code: Pascal  [Select]
  1. {$SET_UNIMP_BITS '000:00'} // INDF
After some search in the datasheet, I found 'reading the INDF register itself, indirectly
(FSR = '0') will read 00h'. That's why you add this line?

second question: in PIC16F877.pas again, section  Configuration Bits:
Code: Pascal  [Select]
  1. // WDTE : Watchdog Timer Enable bit
  2.   {$define _WDTE_ON      = $13BFF}  // WDT enabled
  3.   {$define _WDTE_OFF     = $3BFF}  // WDT disabled
  4.  
  5.   // FOSC : Oscillator Selection bits
  6.   {$define _FOSC_EXTRC   = $63BFF}  // RC oscillator
  7.   {$define _FOSC_HS      = $43BFF}  // HS oscillator
  8.   {$define _FOSC_XT      = $23BFF}  // XT oscillator
  9.   {$define _FOSC_LP      = $3BFF}  // LP oscillator
  10.  
There are masks on 5 digits but the configuration register is on 14 bits ... is this an error?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 08, 2018, 08:04:27 pm
I noticed that in the file PIC16F877.pas (my reference to understand how to declare a pic) there is the line:
Code: Pascal  [Select]
  1. {$SET_UNIMP_BITS '000:00'} // INDF
After some search in the datasheet, I found 'reading the INDF register itself, indirectly
(FSR = '0') will read 00h'. That's why you add this line?
Well. I haven't written this files. They are part of some collaboration. But I guess the idea of setting 0x000 as "Unimplemented" is because INDF is not implemented as a register.
The information about unimplemented bits, is used for the compiler when find free space.
But it's more useful for the simulator, to know how it will be the result when reading some special bytes.

Anyway it's not a problem in the Baseline, and Mid-range compilers  because they know that reading the INDF address is an indirect addressing.

Actually, I don't know how the PicPas simulator respond when trying to read INDF indirectly. I will test.

Don't forget directive {$SET_UNIMP_BITS} set bits to be read always as 0.
If you need to set bits to be read always as 1, you need to use {SET_UNIMP_BITS1}

PicPas is accurate in defining the state of every bit of the hardware. That's a difference from other simulator like Proteus, what is incapable of simulate the state of unimplemented bits and can give wrong results in some simulations.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 08, 2018, 08:36:49 pm
second question: in PIC16F877.pas again, section  Configuration Bits:
Code: Pascal  [Select]
  1. // WDTE : Watchdog Timer Enable bit
  2.   {$define _WDTE_ON      = $13BFF}  // WDT enabled
  3.   {$define _WDTE_OFF     = $3BFF}  // WDT disabled
  4.  
  5.   // FOSC : Oscillator Selection bits
  6.   {$define _FOSC_EXTRC   = $63BFF}  // RC oscillator
  7.   {$define _FOSC_HS      = $43BFF}  // HS oscillator
  8.   {$define _FOSC_XT      = $23BFF}  // XT oscillator
  9.   {$define _FOSC_LP      = $3BFF}  // LP oscillator
  10.  
There are masks on 5 digits but the configuration register is on 14 bits ... is this an error?
Strange. They seem to be clearly an error. I will ask to the person who made this file.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 08, 2018, 09:06:14 pm
I picked up some file randomly in 'device16' folder and it seems they are other files with the same error, like 16F874.

About the {$ SET_UNIMP_BITS} and {SET_UNIMP_BITS1} directives, it's an elegant way to specify bits !
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 09, 2018, 12:20:28 am
I noticed another problem: I'm working on PIC16F1454.pas as you asked.
This pic has two configuration word located at adresses $8007 and $8008.
The PIC16F877 has only one configuration word located at $2007.
How do you specify the adress of the configuration word ? I don't see it in existing description files.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 09, 2018, 04:55:37 am
I noticed another problem: I'm working on PIC16F1454.pas as you asked.
This pic has two configuration word located at adresses $8007 and $8008.
The PIC16F877 has only one configuration word located at $2007.
How do you specify the adress of the configuration word ? I don't see it in existing description files.

The address for the configuration word is assumed for the compiler. Each compiler know (or must know) the proper address:

* Baseline compiler -> Use $FFF
* Mid-range compiler -> Use $2007

For the Enhanced Mid-range compiler, we need to implement two addresses. No a big problem.
 
In the PicPas syntax, we can add a new directive, some like {$CONFIG2}
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 09, 2018, 08:53:58 am
Thanks for the precision.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 09, 2018, 08:14:33 pm
Hello,
I finished the description file for PIC16F1454 !
Because it is my first, please Edson check it, particularly the 'SET_STATE_RAM' and 'SET_MAPPED_RAM' directive section.

On this PIC, there is the same common GPR block of 16 bytes which is repeated on each bank.
 I declared each of them with the SET_STATE_RAM directive. I do not know if this is good because it may give false information about the amount of RAM available. I don't know how your compiler treat this.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 10, 2018, 08:01:55 am
Excelent!

This is the first hardware description of a Mid-range Enhanced Core CPU PIC.

It seems OK for me.  GPR and SFR are declared right with {$SET_STATE_RAM}

GPR is mapped OK with {$SET_MAPPED_RAM}

But I don't see the mapped section for the 16 lower bytes GPR. They must be mapped too, or the compiler will calculate bad the free RAM and would use this wromg this range of RAM.

A minor detail: Line 777 is:  // -- Bits Configuration Word 1 --
Must be: // -- Bits Configuration Word 2 --

The best test of this unit will be when compiling programs or simulating the execution. Anyway the compiler is still in progress.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 10, 2018, 03:46:21 pm
Excelent!

This is the first hardware description of a Mid-range Enhanced Core CPU PIC.
I'm happy to contribute !

But I don't see the mapped section for the 16 lower bytes GPR. They must be mapped too, or the compiler will calculate bad the free RAM and would use this wromg this range of RAM.
that's what I thought ... Added.


A minor detail: Line 777 is:  // -- Bits Configuration Word 1 --
Must be: // -- Bits Configuration Word 2 --
Corrected

The best test of this unit will be when compiling programs or simulating the execution. Anyway the compiler is still in progress.
Good, Let's go to the other Enhanced Mid-range !

Below, the updated file. Thanks !
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 11, 2018, 06:16:20 am
Hi. I've implemented an experimental compiler for the Enhanced Mid-range, family in PicPas  :). It's not complete by now, but can be used to test the units created. I have compiled the file PIC16F1454.pas and one errors is:

Line 4: {$SET PIC_MODEL    = PIC16F1454}
Must be: {$SET PIC_MODEL    = 'PIC16F1454'}

Other errors are in the lines of type:

{$SET_STATE_RAM '0000-000C:SFR'}

The compiler expect 3 digits for the address:

{$SET_STATE_RAM '000-00C:SFR'}

I don't see the necesity to increase the number of digits for this directive, considering 3 digits can cover all the 32 banks of RAM.

You can use the last version PicPas (in https://github.com/t-edson/PicPas) to test the units. Just set  the compiler to "Enhanced Mid-range", like in the picture:
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 11, 2018, 09:11:44 pm
Hi. The user https://github.com/cuistax confirmed he has created the units for the Enhanced Mid-range family. Maybe we are duplicating the work. Let's wait until I can check his units.
What we are going to need additionally, is "test code" for the compiler and some ASM routines for math operations.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 11, 2018, 09:56:44 pm
Hi, ok I stop the work on the units. Cuistax did a lot of work !
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 12, 2018, 06:51:23 am
Hi, ok I stop the work on the units. Cuistax did a lot of work !

Yes. Cuistax has written more than 200 units for the Baseline, Mid-range and Enhanced Mid-range devices. We have now more devices definitions that the compiler can support.

The new units for the Enhanced Mid-range are now available in the GitHub. I need to finish the compiler PIC17 (Enhanced Mid-range compiler), but by the moment I'm working in automate the testing for the compiler, because  now we have 3 compilers and hundreds of files to test.

The automation of tests I've projected, needs to improve the simulator and that's where I'm working now.  The compiler PIC10 (Baseline compiler) is not well tested.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: piGrimm on June 12, 2018, 02:55:26 pm
cool! BUT
due to the lack of file formats support, I will still use
https://www.freecadweb.org (https://www.freecadweb.org)
because it is simply awesome
https://www.freecadweb.org/wiki/Import_Export (https://www.freecadweb.org/wiki/Import_Export) << files formats
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 12, 2018, 10:05:59 pm
cool! BUT
due to the lack of file formats support, I will still use
https://www.freecadweb.org (https://www.freecadweb.org)
because it is simply awesome
https://www.freecadweb.org/wiki/Import_Export (https://www.freecadweb.org/wiki/Import_Export) << files formats
I think this is not the subject of this topic... Here we discuss about Edson compiler for Microchip PIC microcontrollers !

@Edson, I will take a look at the git

EDIT: are SFR mapped areas (thus declared with {$ SET_MAPPED_RAM 'xxx-xxx: bnk0'}) also to be declared with the {$ SET_STATE_RAM 'xxx-xxx: SFR'} directive?
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 13, 2018, 06:53:20 am
EDIT: are SFR mapped areas (thus declared with {$ SET_MAPPED_RAM 'xxx-xxx: bnk0'}) also to be declared with the {$ SET_STATE_RAM 'xxx-xxx: SFR'} directive?

Yes. It's the secure way to declare a mapped RAM section what is SFR. Currently the compiler doesn't uses the mapping information for the SFR, but it's planned to use this information in the future for optimization features.

Currently, if you only declare a RAM section like mapped but don't define the state, it will be assumed like "Unimplemented" RAM.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 13, 2018, 07:26:15 pm
Thank you for the details. I have checked the file PIC16F1825.pas in 'devices17', and it seems to miss some state definition on mapped SFR areas. The cores registers are repeated in each bank but only the INDF register is declared with SET_STATE_RAM. The SET_MAPPED_RAM section seems to be well defined.
I wrote a message to Cuistax on GitHub.

EDIT: I think it will be useful if the compiler notify an error if an ram adress is defined as mapped and not defined in STATE section.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 13, 2018, 10:13:15 pm
EDIT: I think it will be useful if the compiler notify an error if an ram adress is defined as mapped and not defined in STATE section.
Excellent suggestion. I will check it for the next version and I will see too, if include some new directives to set state or map RAM for all banks. This will reduce the size of units.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 13, 2018, 10:19:05 pm
PicPas 0.8.7 is closed and released now.  :D https://github.com/t-edson/PicPas
Binaries have been updated for Windows, Linux and Mac.

Most of the changes have been done in the debugger/simulator.

Now PicPas can simulate the PIC including some components for input and output:

New changes will be in the trunk version 0.8.8.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Lulu on June 15, 2018, 12:57:48 pm
That's great !
I tryed to add a led on project 'samples\BlinkLed.pas': the led and its resistor appears on the screen but when I right click on the pin 7 of the PIC, it appears an exception SIGSEV in file FramePicDiagram.pas line 1051.

How do you implement the size of the EEPROM ? There isn't a directive for this.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on June 15, 2018, 04:43:09 pm
That's great !
I tryed to add a led on project 'samples\BlinkLed.pas': the led and its resistor appears on the screen but when I right click on the pin 7 of the PIC, it appears an exception SIGSEV in file FramePicDiagram.pas line 1051.

Have you used the last version of PicPas? This happened in 0.8.7 when testing. If teh error persist, please send a screenshot.

How do you implement the size of the EEPROM ? There isn't a directive for this.

EEPROM is considered a peripheral, like Timers and Watchdog, and Picpas does not have support to define (and simulate) pheripherals, by now.

When implemented, we are going to need new directives not only for EEPROM.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: aljunaid on January 10, 2019, 10:49:34 am
Just posting how to compile PicPas for windows-32bit / Lazarus 1.8.4;
sourcd-libraries\ are;
MiConfig-0.4.zip
MisUtils-0.6.zip
ogEditGraf-2.4.zip           (OLD VERSION)
PicUtils-1.6.zip
SynFacilUtils-1.21.zip
t-Xpres-1.3.2.zip
UtilsGrilla-0.8.zip

The patchfile  patch-language_tra_FrameArcExplor.pas  is from ;
https://svnweb.freebsd.org/ports/head/editors/picpas/files/
(I think the author uses a Spanish-localized version Lazarus
library names in language_tra_FrameArcExplor.pas  . This
needs fixing to at least select english function names on english systems.
I also noted that selecting Tools.Settings.IncludeDetailedComments = ticked   causes an exception when compling (on baseline project).
Would be nice if the PicPas IDE would remember type of Compiler
selected for current project instead of defaulting to Midrange all the time.


runme.bat:
-------------------------------------------------

goto libs

- File.Open = PicPas-0.8.8\Source\PicPas.lpr

-Project.OptionsForProject.CompilerOptions ;
   .Debugging.StripSymbols= ticked

-Project.OptionsForProject.CompilerOptions.Paths ;
   -shows that this project is looking for libraries in
    Source\..\..\_Librerias\XXXXXX\
:libs
   cd PicPas-0.8.8\Source
   md ..\..\_Librerias
   cd ..\..\_Librerias
   unzip source-libraries\*.zip
      REM h:\dl\electron\pic\compiler\PicPas\source-libraries\
   ren t-Xpres-1.3.2 Xpres-1.3.2
   cd ..\PicPas-0.8.8\language
   G:\MinGW\bin\patch.exe --strip=1 < compiling\patch-language_tra_FrameArcExplor.pas
      REM h:\dl\electron\pic\compiler\PicPas\compiling\
   cd ..
   copy PicPas-win64.xml PicPas-win32.xml
   goto end

-Run.Compile



:end


Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on January 10, 2019, 07:35:06 pm
Thanks for the information @aljunaid

There're some issues easy to solve.

I'll be revising PicPas later. Currently I'm experimenting with new compilers to translate that experience to PicPas and make it a better compiler.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: parcel on March 12, 2019, 02:11:23 pm
It's interesting project :)

Is future version support word by word multiply calcuation?


Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on March 12, 2019, 07:29:46 pm
It's interesting project :)
Is future version support word by word multiply calcuation?

Hi.
Some aritmethic operation are not implemented. I'm doing a redesign of the compiler.

You can implement a function to multiply Word * Word:

Code: Pascal  [Select]
  1. uses PIC16F84A;
  2.  
  3. procedure Mult(SYS_MATH_NUM_A, SYS_MATH_NUM_B: word): word;
  4. var
  5.   SYSBYTETEMP_01: byte;
  6. begin
  7.   SetBank(0);
  8.   ASM
  9.   ;[W_H] = SYS_MATH_NUM_A * SYS_MATH_NUM_B
  10.  
  11.   ;SYS_MATH_NUM_X = 0
  12.           clrf    SYSBYTETEMP_01
  13.           clrf    _H
  14.   MUL16LOOP:
  15.   ;Si SYS_MATH_NUM_B.0 = 1 entonces [W_H] += SYS_MATH_NUM_A
  16.           btfss   SYS_MATH_NUM_B.Low,0
  17.           goto    ENDIF1
  18.           movf    SYS_MATH_NUM_A.Low,W
  19.           addwf   SYSBYTETEMP_01,F
  20.           movf    SYS_MATH_NUM_A.High,W
  21.           btfsc   STATUS_C
  22.           addlw   1
  23.           addwf   _H,F
  24.   ENDIF1:
  25.   ;STATUS.C := 0
  26.           bcf     STATUS_C
  27.   ;rotar SYS_MATH_NUM_B derecha
  28.           rrf       SYS_MATH_NUM_B.High,F
  29.           rrf       SYS_MATH_NUM_B.Low,F
  30.   ;STATUS.C := 0
  31.           bcf       STATUS_C
  32.   ;rotar SYS_MATH_NUM_A izquierda
  33.           rlf       SYS_MATH_NUM_A.Low,F
  34.           rlf       SYS_MATH_NUM_A.High,F
  35.  
  36.   ;Si SYS_MATH_NUM_B > 0 entonces goto MUL16LOOP
  37.     movf    SYS_MATH_NUM_B.Low,w
  38.     iorwf   SYS_MATH_NUM_B.High,w
  39.     btfss   STATUS_Z
  40.     goto    MUL16LOOP     ; SYS_MATH_NUM_B > 0
  41.    
  42.     movf    SYSBYTETEMP_01,w
  43.   END
  44. end;
  45.  
  46. var
  47.   a, b, c: word;
  48. begin
  49.   a := 100;
  50.   b := 200;
  51.   c := mult(a, b);
  52. end.

This routine uses only 23 cells of memory.
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: parcel on March 13, 2019, 12:13:33 pm
It's interesting project :)
Is future version support word by word multiply calcuation?

Hi.
Some aritmethic operation are not implemented. I'm doing a redesign of the compiler.

You can implement a function to multiply Word * Word:

Code: Pascal  [Select]
  1. uses PIC16F84A;
  2.  
  3. procedure Mult(SYS_MATH_NUM_A, SYS_MATH_NUM_B: word): word;
  4. var
  5.   SYSBYTETEMP_01: byte;
  6. begin
  7.   SetBank(0);
  8.   ASM
  9.   ;[W_H] = SYS_MATH_NUM_A * SYS_MATH_NUM_B
  10.  
  11.   ;SYS_MATH_NUM_X = 0
  12.           clrf    SYSBYTETEMP_01
  13.           clrf    _H
  14.   MUL16LOOP:
  15.   ;Si SYS_MATH_NUM_B.0 = 1 entonces [W_H] += SYS_MATH_NUM_A
  16.           btfss   SYS_MATH_NUM_B.Low,0
  17.           goto    ENDIF1
  18.           movf    SYS_MATH_NUM_A.Low,W
  19.           addwf   SYSBYTETEMP_01,F
  20.           movf    SYS_MATH_NUM_A.High,W
  21.           btfsc   STATUS_C
  22.           addlw   1
  23.           addwf   _H,F
  24.   ENDIF1:
  25.   ;STATUS.C := 0
  26.           bcf     STATUS_C
  27.   ;rotar SYS_MATH_NUM_B derecha
  28.           rrf       SYS_MATH_NUM_B.High,F
  29.           rrf       SYS_MATH_NUM_B.Low,F
  30.   ;STATUS.C := 0
  31.           bcf       STATUS_C
  32.   ;rotar SYS_MATH_NUM_A izquierda
  33.           rlf       SYS_MATH_NUM_A.Low,F
  34.           rlf       SYS_MATH_NUM_A.High,F
  35.  
  36.   ;Si SYS_MATH_NUM_B > 0 entonces goto MUL16LOOP
  37.     movf    SYS_MATH_NUM_B.Low,w
  38.     iorwf   SYS_MATH_NUM_B.High,w
  39.     btfss   STATUS_Z
  40.     goto    MUL16LOOP     ; SYS_MATH_NUM_B > 0
  41.    
  42.     movf    SYSBYTETEMP_01,w
  43.   END
  44. end;
  45.  
  46. var
  47.   a, b, c: word;
  48. begin
  49.   a := 100;
  50.   b := 200;
  51.   c := mult(a, b);
  52. end.

This routine uses only 23 cells of memory.

Thank you.

But I guess result is dword. Sometimes it is needed for 10 bit adc multiplication for power checking. It may be useful.

Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: Edson on March 14, 2019, 03:59:21 am
But I guess result is dword. Sometimes it is needed for 10 bit adc multiplication for power checking. It may be useful.

I don't know if it's really needed so much precision when working with ADC but you can get 32 bits math routines here: https://github.com/AguHDz/PicPas-Librerias_y_Programas/blob/master/Math_Code/Math_32bits.pas
Title: Re: PicPas, Pascal compiler for Microchip PIC
Post by: parcel on March 14, 2019, 08:37:19 am
But I guess result is dword. Sometimes it is needed for 10 bit adc multiplication for power checking. It may be useful.

I don't know if it's really needed so much precision when working with ADC but you can get 32 bits math routines here: https://github.com/AguHDz/PicPas-Librerias_y_Programas/blob/master/Math_Code/Math_32bits.pas

Thank you  :)

I have small project for solar panel MPPT. 
It uses 12F675 and it need word multiplication.
I already finished by other PIC compiler and I try to porting to PICPAS.

 https://github.com/rasberryrabbit/PIC12F675MPPT/blob/master/12f675%20MPPT.mpas (https://github.com/rasberryrabbit/PIC12F675MPPT/blob/master/12f675%20MPPT.mpas)