News:

Let's find out together what makes a PIC Tick!

Main Menu

Do you mind the savings I made in the procedure?

Started by Yasin, Dec 07, 2021, 08:43 PM

Previous topic - Next topic

Yasin

Hello everybody.

Inspired by the example on page 387 of the Positron8 manual, I created two Procs that do the same job.

First Proc
Proc DisplayText(pEAddress As Word),String * 100
    Dim pCount As Byte
    Dim pString As String * 100
    pCount = 0
    Do                                      ' Create an infinite loop
        pString[pCount] = ERead pEAddress   ' Read the EEPROM data
        If pString[pCount] = 0 Then Break   ' Exit when null found
        Inc pEAddress                       ' Move up to the next address
        Inc pCount
    Loop                                    ' Close the loop
    Result = pString
EndProc

Second Proc
Proc DisplayText(pEAddress As Word),String * 100       
    Dim pCount As Byte
    pCount = 0
    Do
        DisplayTextResult[pCount] = ERead pEAddress
        If DisplayTextResult[pCount] = 0 Then Break
        Inc pEAddress
        Inc pCount
    Loop
    'Result = pString
EndProc

It does the same thing in both procedures. I learned the alias of "Result" from the ASM output. In the second procedure, I transferred my eprom directly to it. Thus, 100 ram was saved. Do you think it's okay to use Procedures this way?

Best regards.

atomix

And better like this:

Proc DisplayText(pEAddress As Word),String * 100       
    Dim pCount As Byte
    pCount = 0
    Do
        Result[pCount] = ERead pEAddress
        If Result[pCount] = 0 Then Break
        Inc pEAddress
        Inc pCount
    Loop
EndProc

top204

It is just so good to see the users of the compilers developing code with the new features I added.

Procedures make things so much clearer, but do not dominate a program, as other procedure languages do. So code is flexible and much clearer to read and understand, and write.

Yasin

I did not know ASM at all and because I was not interested, I could not progress in this direction. Now, thanks to proton&positron, I'm looking at the asm outputs and I'm starting to understand. The more I use the positron, the more my love for it grows. The support of the forum, especially Les, is great. Being able to quickly find answers to many problems by reviewing/modifying/using code samples is invaluable. I think microchip company should see this now. And positron compilers should support it. Because it is a factor that affects direct sales. If people like us prefer to use the positron compiler, it means using the microchip mcu.
King regards.

top204

#4
Many thanks Yasin

I joined Microchip third party a couple of times over the years and all they did was steal my concepts and ideas!!! As did some others. :-( They also removed the compilers when they started to sell their own.

And there is nothing I can do because I do not have the funds to afford lawyers. Heck, I can hardly afford to heat the house, never mind pay a "legal thief" £1000 an hour, or more. LOL

Never, never, never trust Microchip, because they are not chip designers any more, they are a corporate that buys other companies, dismembers the parts of the company they bought, and destroy the parts, and people, that do not make enough money for them. Then use what is left with their name alone on it, as if they designed it!!! They have done this many times over with other companies... They also take other people's concepts, get a third party to design something the same, and place their name on it!!!

However, if Microchip, or any other company, offered to buy the compilers, I would agree to it, because they make no money whatsoever for me. But I still take the time to add to them, for some inexplicable reason. LOL