In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:
[3]I am trying to understand the declaration and use of parameters in a section of code provided by Parallax in support of their serial display (part 27977). [/3][3]The code works fine, I am not understanding how it works.[/3]
[3] [/3]
[3]Question #1 regards a sub declaration's MIN parameters [/3]
[3]SX/B help states that in the sub declarations, the two arguments are the min and max number of parameters. If only one value is provded ten that is t emin and max. The code line of interest (follows, line 92) indicates that a minimum of two parameters must be sent when the sub is called.[/3]
[3]LCD_STR SUB 2 ' send string to LCD[/3]
[3] [/3]
[3]But when the sub is called in the program (follows, line 118) only one parameter is sent[/3]
[3]LCD_STR " PARALLAX SX/B "[/3]
[3]Question #2 - what does the parameter actually hold?[/3]
[3]I lose the logic of the value in the parameter between the call of the sub and the use within the sub. When the sub is called the parameter is the string of characters to display. But within the sub the parameter seems to be an offset, which I would think is a number indicating where to start parsing the string to send individual bytes one at a time to the sub that actually displays them. And what value goes into temp4 since only one param was sent? I understand that the following code can pull characters from a data store (READ) but it is also used by the above GOSUB to display the literal string.[/3]
[3] [/3]
[3]' Use: LCD_STR [ string | label ][/3]
[3]' -- "string" is an embedded literal string[/3]
[3]' -- "label" is DATA statement label for stored z-String[/3]
[3] [/3]
[3]LCD_STR: [/3]
[3]temp3 = __PARAM1 ' get string offset[/3]
[3]temp4 = __PARAM2 ' get string base[/3]
[3] DO[/3]
[3] READ temp4 + temp3, temp5 ' read a character[/3]
[3] IF temp5 = 0 THEN EXIT ' if 0, string complete[/3]
[3] LCD_OUT temp5 ' send the byte[/3]
[3] INC temp3 ' point to next character[/3]
[3] temp4 = temp4 + Z ' update base on overflow[/3]
[3] LOOP[/3]
[3] RETURN[/3]
[3] [/3]
[3] [/3]
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=190310
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)