PDA

View Full Version : PBP Wish List



Radiance
- 21st July 2003, 23:48
A PicBasic Pro Wish List:

Function Calls:
Function Foo(var1,var2)

var result
result=var1*var2
Foo=result
(or this way, which I like better:)
return result
End Function

This eliminates:

Global Variables that mysteriously change
lots of line labels
the nasty GOSUB

Darrel Taylor
- 23rd July 2003, 01:17
I agree, it would be nice to have functions built into PBP. But until that happens, here is a round about way of achieving the same thing, kinda, sorta.

First, you need to create a "macro" that copies the passed parameters into known locations. Then create your subroutine just like normal, keeping in mind that the input and output are always thru the known Temp variables.

After the macro copies the parameters to the Temp variables, it will call the code for the function. When the function is finished it will return to the macro which will copy the result to the third parameter. You can pass as many parameters as you want (as long as they fit on 1 line).


Temp1 var word
Temp2 var word
Temp3 var word

asm
Foo macro W1, W2, R1
MOVE?WW W1, _Temp1 ; Copy first parameter to Temp Variable 1
MOVE?WW W2, _Temp2 ; Copy second parameter to Temp Variable 2
L?CALL _FooCode ; call the Foo functions code
MOVE?WW _Temp3, R1 ; Copy Temp3 to result
endm
endasm


FooCode: ' PBP code for the function
Temp3 = Temp1 * Temp2
' and whatever else Foo does
' final result must be in Temp3
return
To use the new function


bar var word
bleh var word
belch var word

@ Foo _bar, _bleh, _belch
or


Dogs var word
FleasPerDog var word
TotalFleas var word

@ Foo _Dogs, _FleasPerDog, _TotalFleas
The example shown will only work with words, to use bytes: change the appropriate MOVE?WW to MOVE?BB

The biggest benefit of a function is the ability to embed it in a math formula or conditional test. Unfortunately, this Macro type function DOES NOT allow you to do that. So I'm still hoping for true functions in PBP also.

Art
- 20th August 2003, 09:38
Would be nice to have a fully labelled assembler version of every
program without decompiling/relabelling yourself...
Art.

Robert Soubie
- 5th February 2004, 09:08
Originally posted by Art
Would be nice to have a fully labelled assembler version of every
program without decompiling/relabelling yourself...
Art.

Well, you have it: if you use Microcode Studio, go to "options" and check "listing file". Same if you use mpasm rather than pm...

jojokatada
- 1st February 2005, 07:09
hi anybody could help me how to display a 4 line character lcd.

sample code

main:
pause 1

lcdout $fe,1," Hello world", $fe,c0," hello again" ,fe,94,"welcome" fe,d4,"thank you"

goto main

end

mister_e
- 1st February 2005, 18:30
jojokatada

have a look in that thread (http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=1173)

Please, help us to keep thread/forum section as clean as they're supposed to be. You really don't need to post the same question twice.

;)