Exact match. Not showing close matches.
PICList
Thread
'[SX] SX/B Help - Passing string to a subroutine'
2005\09\05@002953
by
johncouturen/a
|
|
I'm trying to display a string using a subroutine. Something like the following. Complete code in attachment. The problem is that I can't seem to be able to pass the string name as a parameter. When I hardcode the string name in the subroutine, it works ok. Thus, it must be some kind of syntax error that I'm introducing that is preventing the passing of the string address. There's something about that __PARAM1 and the @ symbol that I am not understanding.
DISPLAY SUB 1
Msg1:
Data "This is a string",0
Msg2:
Data "Another string ",0
start:
DISPLAY Msg1
PAUSE 255
DISPLAY Msg2
PAUSE 255
goto start
'------------------
' page 1 subroutine section
'------------------
DISPLAY:
dpos = 0
goto disp6
disp5:
dcol = 64
goto disp7
disp6:
dcol = 0
disp7:
POSCUR dcol
read __PARAM1+dpos,dbyte
if dbyte=0 then disp9
LCDOUT dbyte
dcol = dcol + 1
dpos = dpos + 1
if dcol = 72 then disp6
if dcol = 8 then disp5
goto disp7
disp9:
return
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=86956
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)
2005\09\05@044051 by Jon Williamsn/a
|
|
Have you downloaded the latest version of SX/B? If not, please do and then look in the examples for READ. One of the improvements made is the handling of strings and with 1.42 you can pass the name of a string (z-string stored in a DATA table) or pass as string directly.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=86956#m86960
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)
2005\09\05@153552 by johncouturen/a
|
|
Jon,
Thank you! I'm working on it now. My apologies for not downloading the 1.42 version earlier. Good example in the attachment.
Now that's dedication! You answered the email at 3:44am! Are you on the East Coast or something? (grin)
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=86956#m87018
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)
2005\09\05@170411 by Jon Williamsn/a
|
|
Central Time Zone (Dallas, TX). Funny, I don't remember getting up that early, but yesteday was a big movie day (my other love), so I may have....
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=86956#m87030
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)
2005\09\05@192841 by johncouturen/a
|
|
Jon,
In the READ2.SXB listing above, the TX_STR subroutine:
-------------------------------------------------------
1) The comments above TX_STR show a usage of up to THREE parameters (one of them is an either or param), yet the subroutine assigns PARAM1 through PARAM4 to variables. What happened to the fourth parameter in the USE documentation?
-------------------------------------------------------
2) You use a "C" and a "Z" which seem to be aliases (ref online manual under "SX/B Aliases, SX Registers")
C = Carry (Status.0)
Z = Zero (Status.2)
If one assumes that PARAM2 is the count (as in how many characters to send out), then I don't understand the adding of a bit to this variable. Can you explain this one further. (Ref: line 150 and line 160)
-------------------------------------------------------
3) It seems that if you are sending a string to a subroutine, the subroutine has to assign PARAM1 and PARAM2 to SOMETHING even if you want the subroutine to send the entire string. Am I correct?
-------------------------------------------------------
4) (grin) If you rewrite this example, would it be easier to read if you used stemp1=param1, stemp2=param2 etc instead of temp3=param1, temp4=param2, if it is a full moon temp5=Mickey Mantle, temp6=the catcher .... Who's on first base again?
This SX sure is a fun chip! Thank you for all of the info that you make available to us.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=86956#m87053
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)
2005\09\05@210933 by Jon Williamsn/a
|
|
1) Strings count as two parameters: base and offset (this is mentioned in the help file toward the end of READ; the section concerning strings)
2) __PARAM1 is the offset, __PARAM2 is the base -- the address is sent "Little Endian" (low byte, high byte)
3) Yes, again, strings take two parameters (which point to the starting location in memory of the string)
4) It works now ... why rewrite it? (other than simplifying to eliminate substrings)
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=86956#m87059
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)
More... (looser matching)
- Last day of these posts
- In 2005
, 2006 only
- Today
- New search...