PDA

View Full Version : Passing arguments to subroutines



flotulopex
- 12th March 2008, 08:43
Hello,

Is there a way to pass one or more arguments when calling, i.e., a subroutine?

Example: I want to call a subroutine that does something according to a changing value.

It would look like "GOSUB SubRoutine, 123" where 123 is the changing value.

Is this possible in PBP?

Acetronics2
- 12th March 2008, 09:05
Hi, Roger

If you like assembler ... just have a look to PbPxx Libs., Functions sections. That will show you how the arguments are passed to the functions.

My souvenirs tell me the full lib must fit into page 0 for 14 bits prog. devices ...

read you later

Alain

flotulopex
- 12th March 2008, 09:57
Hello Alain,

Thanks for your super-quick reply ;)

Well then, I go back to my dreams since assembly will not be able to find some place in my brain in this life, I'm afraid... My brain is like the swiss cheese: lots of holes and only few consistent matter :D

Have a nice day.

NB: dommage, ça m'aurait été super-utile!

Acetronics2
- 12th March 2008, 10:23
Yes , Roger

BUT ... is it so difficult to set the variables to be used to their values just before jumping to your sub ???

< NB: dommage, ça m'aurait été super-utile!>

Just choose the convenient processor ... after all !!!

Alain

flotulopex
- 12th March 2008, 10:38
...I'm too lazy :p

Seriously, I was looking to avoid this way of doing (because this is what I actually do).

Once again, you prove there is ALWAYS a solution... and thank you for this.

Raflex
- 14th March 2008, 08:56
Hello, try with this code:
b0 var byte

Main:

... some code
b0=123
gosub test
...some code
goto Main

test:
if b0=123 then
...code
endif
return