To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 9302
9301  |  9303
Subject: 
Re: Mindstorms spirit.ocx programming = RCX ASM coding? (fwd)
Newsgroups: 
lugnet.robotics
Date: 
Thu, 23 Dec 1999 04:42:01 GMT
Viewed: 
812 times
  
In article <199912230400.WAA30840@einstein.ssz.com>, Jim Choate
<ravage@einstein.ssz.com> wrote:

----- Forwarded message from Dave Baum -----

From: dbaum@spambgoneenteract.com (Dave Baum)
Subject: Re: Mindstorms spirit.ocx programming = RCX ASM coding?
Date: Thu, 23 Dec 1999 02:44:41 GMT

This gets pretty tedious.  Here's an example
taken from the SDK:

PBrickCtrl.If 2, 5, 2, 0, 15    | If (constant) 5 = variable 15 then
PBrickCtrl.PlayTone 440, 20     | play a 440 Hz tone for 200 ms.
PBrickCtrl.Else Else
PBrickCtrl.PlayTone 5000, 10    | play a 5000 Hz. tone with a 100 ms. duration
PBrickCtrl.EndIf                | Close the If...Else...EndIf • control-structure.

I don't know about you, but I'd much rather do something like this:

if (x == 5)
PlayTone(440, 20);
else
PlayTone(5000, 10);

Don't even get me started on how you'd use spirit.ocx to do something • like this:

if (x * 2 < y + 5)
PlayTone(440, 20);

----- End of forwarded message from Dave Baum -----

This is why they make pre-processors.


Preprocesors can make things a little less verbose and also assign
readable names to constants.  However, its quite another thing to convert
infix notation to function calls or allocate temporary variables.

In my example:

if (x * 2 < y + 5)
PlayTone(440, 20);

There isn't a way to ask the RCX to directly compare "x*2" with "y+5".
You must create two temporary variables, then do the assignments to set
them up.  I'm not fluent in spirit.ocx, but here's how it would look in
NQC without variable allocation and expression evaluation:

temp1 = x;
temp1 *= 2;
temp2 = y;
temp2 += 5;
if (temp1 < temp2)
  PlayTone(440, 20);

Anyway, this is exactly the sort of thing that NQC does for you.  I'm not
saying its impossible to write the code in spirit - just that there are
certain things that a compiler can do for you above what spirit provides.

Dave Baum

--
reply to: dbaum at enteract dot com



Message is in Reply To:
  Re: Mindstorms spirit.ocx programming = RCX ASM coding? (fwd)
 
----- Forwarded message from Dave Baum ----- From: dbaum@spambgoneenteract.com (Dave Baum) Subject: Re: Mindstorms spirit.ocx programming = RCX ASM coding? Date: Thu, 23 Dec 1999 02:44:41 GMT Correct. IMHO, calling this "programming the RCX in VB" (...) (25 years ago, 23-Dec-99, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR