• Pic® Basic


  • CONVERTING C SOURCE CODE INTO PROTON BASIC

    by LittlePIC

    INTRODUCTION

    Welcome all! This is the introduction to a number of application notes I hope to write and help Proton users convert C source code written for PIC® micro’s into our ‘native’ Proton PIC® Basic.
    WHY IS THIS OF ANY USE? Well, a quick visit to www.microchip.com (along with other websites) will give you all the reason’s why – basically there is a huge amount of code written in C for PIC®, with excellent application notes, which will add great stocks of source code to any developer looking to fast track there idea’s.

    C is the preferred language for the masses that develop PIC® applications, and has been for some time. BASIC is considered ‘Unstructured’ and too limited to be of any serious use (even I felt along that line of thought), but Proton changed my thinking…Proton has plenty of commands to cover almost any requirement by writing sub-routines. Ok – some of you would like to see more commands added which just let you type a few words like: 7SEGMENT DISPLAY and 50 lines of Assembly pop out the other end, but this is not always possible. My suggestion is to stop requesting the development team for more commands and start writing some sub-routines which achieve the same result. (And naturally post them for all users to enjoy).

    The success of C is based on this very concept – multiple subroutines which add ‘commands’ to their programming language, we can do the same thing, and too, rub a bit more salt into the C PIC® programming community – we will use their subroutines…(known as Functions)

    Now before any hardcore C programmers get on their soap box and start raving ‘you can’t do that!’ or ‘it will never work’, I say ‘BOO HA HA ,Yes it can and it will!’(And get off the soap box because someone needs the wood)

    Yes, they are right, (hard to admit…) there are many differences between the two languages, but there is also many similarities, (with some crude work around) will give you the guts of the structure of the code.

    What I’m trying to do is simply ‘text process’ the C code into Basic, similar to a translator, but like the saying ‘lost in translation’, it won’t be an easy ride. Some grey matter between your ears will need to be used.

    Along with the 5 Part’s listed below – I hope to write a VB plug-in to process C source code and their Header files, but by reading through the notes (as they are written) will help you with the ‘manual’ processing after the Plug-in has done its job. (Sorry, but the Plug-in will be the last part written, these notes will help with the plug-in development)

    Finally – Anyone in Forum Land or Proton Developers who wish to help or add their two cent’s worth are welcome. This is a big task, but achievable. I am by no means any type of C Programming Guru, actually I have never used any C compiler for PIC®, but (probably the same for many reading this ) have bashed out a few programs using Borderland C, C+ and similar, but learning is only a quick ‘Google’ away, so no one has any excuse to not contribute. What’s the worst that could happen? You’ll learn the basis of C and develop a better understanding of Proton’s Basic by writing subroutines.

    Possible Outline of Application Notes:

    Part 1 will explain the common structures of C and the first few direct conversions easily done (namely the Preprocessor Directives)

    Part 2 will cover the Operators and Constructs (Math operators and WHILE/IF type loops)

    Part 3 will deal with Functions (similar to Gosub sub-routines)

    Part 4 will cover Input/Output

    Part 5 (6,7,8..)will cover the rest

    So why not jump one board and help out? Remember what your parents used to say about ‘many hands make light work’, well it’s true – I’m happy to plod along and do it myself but any help and feedback(either good or bad) is welcomed.

    I’m known as LittlePIC in the Forum,so if you’re a C programmer and want to spit some venom, you know where to find me…, or help me out to take this IDE to another level…

    Regards

    LittlePIC
  • Recent Activity

    normnet-324

    FineLineIDE

    Thread Starter: normnet

    Coming soon a new IDE: FineLineIDE! Features include:<O:p</O:p Bracket lines linking If-Endif, For-Next etc.<O:p</O:p Tabbed explorer so...

    normnet Yesterday, 09:31 Go to last post
    Henk57-24049

    Compiler 3.6.1.7 issue with 16F1829 and I2C-LCD

    Thread Starter: Henk57

    Spend this afternoon with a compiler issue; no error's, but my LCD give only first line with squares, no characters, nothing. If I flash an old .hex...

    Henk57 Today, 03:19 Go to last post
    normnet-324

    New dual core dsPIC33CH PIC

    Thread Starter: normnet

    The Master core and Slave core can operate independently, and can be programmed and debugged separately during the application development. Both...

    normnet Yesterday, 23:42 Go to last post