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 / 1622
1621  |  1623
Subject: 
NQC & Spybot subroutine code generation bug
Newsgroups: 
lugnet.robotics.rcx.nqc, lugnet.robotics.spybotics
Date: 
Wed, 11 Feb 2004 17:53:25 GMT
Viewed: 
9653 times
  
I have just received a report from a user that NQC programs containing
subroutines do not execute correctly against the Spybot platform.  I have
confirmed that this is a problem with all versions of NQC which support the
Spybot brick.

This program:

#define SpyReturn asm { 0xF6 }

sub test()
{
//  int i = 15;
  PlayTone(400, 50);
//  if (i < 30) SpyReturn;
  Wait(50);
//  SpyReturn;
}

sub test2()
{
  PlayTone(800, 50);
  Wait(50);
//  SpyReturn;
}

sub test3()
{
  PlayTone(1000, 50);
  Wait(50);
//  SpyReturn;
}

task main()
{
  PlaySound(SOUND_FAST_UP);
  Wait(100);
  test();
  PlaySound(SOUND_DOUBLE_BEEP);
}

generates essentially identical code for both the RCX2 and Spybot targets (the
only difference being subroutine & task numbers:

*** Task 8 = main
000 pwr        ABC, 7                13 07 02 07
004 dir        ABC, Fwd              e1 87
006 plays      5                     51 05
008 wait       100                   43 02 64 00
012 calls      128                   17 00
014 plays      1                     51 01

*** Sub 128 = test
000 playt      400, 50               23 90 01 32
004 wait       50                    43 02 32 00

*** Sub 129 = test2
000 playt      800, 50               23 20 03 32
004 wait       50                    43 02 32 00

*** Sub 130 = test3
000 playt      1000, 50              23 e8 03 32
004 wait       50                    43 02 32 00

Total size: 40 bytes

On the RCX2 platform this code executes correctly.  On the Spybot platform it
does not.  After executing the code in the first subroutine (128) instead of
returning to the code in task 8 (main) the code in all subsequent subroutines
will execute in order before finally returning to the line in task 8 following
the call statement.

Until I can release a new beta of NQC 3.0 the workaround is to define a macro

#define SpyReturn asm { 0xF6 }

use SpyReturn instead of return, and make sure you end all your subroutines with
SpyReturn;

John Hansen



1 Message 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