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 / 1520
1519  |  1521
Subject: 
Re: How to call SCOUT ROM subroutine from NQC
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 27 May 2003 01:23:18 GMT
Viewed: 
8524 times
  
Dear Dave Baum,

Thank you for your reply. First of all, I enyoy your wonderful creation NQC
very much. I also learn much from your EXTREME MINDSTORM book although it is
dedicated to RCX rather than to RDS SCOUT.

I successfully call almost all SCOUT ROM Subroutines by following your
advice (#pragma and asm stuffs). However, I have to correct my original
statement saying that calling SCOUT ROM Subroutines may save much memory. It
is not ALWAYS the case. Also by calling ROM Subroutines, I have to be
extremely careful managing my local variables if I do not use #pragma
statement at the beginning of my NQC programs. For example, ROM Subroutines
use Local Variable 1, 2, 3 and then sometime Local Variable 8 (these are
identical with Var[10], Var[11], Var[12] and Var[17], respectively, in NQC
assembly language). But when I declare the first variable in a task or block
of program, the NQC will assign the variable to Var[17] which is the "most
unused" one, and for the second variable to Var[16] a.s.o. In addition to
that, I must check whether other local variables are preserved after
returning from a ROM subroutine call. All of these may end with a program
with more bytecodes. If we can isolate a single job in a task and do not
bother with the local variables book-keeping then calling ROM Subroutines
are indeed useful for saving memory. For example, subroutine for light
seeking, dark seeking, SCOUT predefined dancing movement, geiger-counter
sound, etc. For other cases, I loss the beauty of C (NQC) language.

In future, hopefully, I could post the include files containing macros for
calling (easily) the SCOUT ROM subroutines.

Best Regards,

Liem Peng Hong

In lugnet.robotics.rcx.nqc, Dave Baum writes:
> In article <HFC38G.1BJw@lugnet.com>,
> "Liem Peng Hong" <liemph@nais.ne.jp> wrote:
> 
> > Dear members,
> > I would like to know how to call RDS SCOUT ROM subroutines from NQC.
> > The SCOUT ROM Subroutines are useful and may save much memory for SCOUT.
> > 
> > Thankyou in advance.
> > 
> > Liem PH
> 
> There isn't any built-in support for calling the ROM routines, but you
> can probably hack together what you need.  You'll need to use "#pragma
> reserve" to prevent NQC from assigning variables to the registers used
> for parameter passing to the ROM routines.  Then you'll need to write
> and "asm" statement that moves your desired parameters (which can come
> from variables) into those registers and issues the bytecode to call the
> routine.  The last section in the NQC Programmer's Guide provides some
> explanation for "#pragma reserve" and "asm".  The Scout documentation
> from Lego describes the ROM routines and what registers are used for
> parameters.
> 
> Dave Baum



Message has 1 Reply:
  Re: How to call SCOUT ROM subroutine from NQC
 
(...) I would love to see the include file you created for calling the Scout ROM subroutines. Any chance it could be posted here (or that you could post a link to the file)? Thanks! John Hansen (23 years ago, 17-Oct-03, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: How to call SCOUT ROM subroutine from NQC
 
(...) There isn't any built-in support for calling the ROM routines, but you can probably hack together what you need. You'll need to use "#pragma reserve" to prevent NQC from assigning variables to the registers used for parameter passing to the (...) (23 years ago, 24-May-03, to lugnet.robotics.rcx.nqc)

5 Messages in This Thread:

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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

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