Recent

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

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #60 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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #61 on: June 08, 2017, 09:42:14 am »
That's OK most German people learn (kind of) English at school.
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #62 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?
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #63 on: June 08, 2017, 11:24:13 am »
I believe there is something like that for Amiga/m68k?

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #64 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.
« Last Edit: June 08, 2017, 04:55:54 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #65 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.  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.
« Last Edit: June 09, 2017, 09:42:30 am by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

andersos

  • New member
  • *
  • Posts: 9
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #66 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.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #67 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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

andersos

  • New member
  • *
  • Posts: 9
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #68 on: June 09, 2017, 05:49:13 pm »
Sounds good. I can contribute, but not with assembler. Do you need Swedish translation for example?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #69 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.  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.

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #70 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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #71 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 *

« Last Edit: June 12, 2017, 05:13:15 pm by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #72 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.  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. :)
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

mischi

  • Full Member
  • ***
  • Posts: 170
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #73 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
« Last Edit: June 12, 2017, 10:15:19 pm by mischi »

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: PicPas, Pascal compiler for Microchip PIC
« Reply #74 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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018