To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 549
548  |  550
Subject: 
Re: RCX2: ViewSourceValue Help
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Mon, 24 Apr 2000 23:02:32 GMT
Viewed: 
2069 times
  
In article <FtJBAs.K9I@lugnet.com>, "James Pritchard"
<dungeon@madasafish.com> wrote:

Hi, I'm back after a break from Lego. (I had exams).
I've been playing around with RCX2 firmware and want to use the new
ViewSourceValue command. What is the correct asm for this. So far I've
got
this by guessing and looking at RCX2.NQH

#define DISPLAY_USER  7

void ViewSourceValue(const int p, const int &v) { asm { 0xE5, 0, p, &v };
}


Does anyone have some more info on the syntax of these asm statements.


asm statements are just followed by a comma-separated list of fields
enclosed in braces.  In general, each field is evaluated at compile time
and the resulting value is truncated to 8 bits.  The exception is the &
operator.

The &x syntax is used to embed an 'effective address' into an assembly
statement.  By default data sources 0-15 are allowed (data sources are
defined in the RCX docs from lego - source 0 is a variable, source 2 is
a constant, etc).  The default format for an effective address is an 8
bit type code followed by a 16 bit value.  However, you can use a
'restrictor' in cases where the bytecode requires a different format
and/or only support a subset of the data sources.  Here's an example
from rcx2.nqh:

void SetPower(const int o, const int &p)  { asm { 0x13, (o), &p :
0x1000015}; }

The 0x1000015 is a restrictor.  The bits of a restrictor are defined as
follows:

Bits 0-15 are a bitmask of the legal data sources.  For example, 0x15
specifies sources 4, 2, and 0 (random numbers, constants, and variables).

Bits 16-23 are undefined.  They may work for data sources 16-23, but if
so this is accidental.

Bit 24 is a modifier that makes the effective address use an 8 bit value
instead of 16 bits.

Bit 25 is a modifier that suppresses the type code in the effective
address.

For example, SetPower() can accept 3 different data sources, and the
address is written as two bytes (a type code and an 8 bit value).

In cases where the passed parameter doesn't match the mask of allowable
types, it will attempt to copy the parameter to a temp variable and then
use the temp variable (assuming type code 0 is allowed).

RCX 2.0 gets rid of a lot of these restrictions and also introduces a
lot of new data sources, so I'm going to have to re-work the restrictor
code.  At minimum, I'll add a new flag that means 'unrestricted'.
However, I may completely redefine the bits in order to clean things up
- the current approach grew out of a series of quick hacks and was never
well designed.  So, use these things at your own risk.

Probably the biggest limitation in hacking RCX 2.0 stuff with the
current NQC compiler is that sources 16 and up really aren't handled
well.  As a result, I don't think its possible to write a program that
directly monitors something like the battery voltage.  Instead, you'll
need to display a variable and then periodically update the variable
with the battery voltage (using the @ operator to access a data source -
see Timer() in rcx2.nqh as an example).

Dave Baum

--
reply to: dbaum at enteract dot com



Message is in Reply To:
  RCX2: ViewSourceValue Help
 
Hi, I'm back after a break from Lego. (I had exams). I've been playing around with RCX2 firmware and want to use the new ViewSourceValue command. What is the correct asm for this. So far I've got this by guessing and looking at RCX2.NQH #define (...) (25 years ago, 24-Apr-00, to lugnet.robotics.rcx.nqc)

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