To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 559
558  |  560
Subject: 
Re: LNP collision detection Bug found and fixed
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 10 Dec 1999 04:46:02 GMT
Viewed: 
1036 times
  
Hi Ben, you wrote:

define TX_COLL (-1)

would fix it.

it is already defined this way...
indeed it looks like egcs for h8300 treats char as unsigned by default.
look at the following test proggy...

char ch;
void showbug(void)
{
if (ch < 1) ch=-2;
}

... and the disassembled code

make bug.o CFLAGS=-g • /opt/legos/crossgcc/bin/h8300-hitachi-hms-gcc -g -c bug.c -o bug.o
h8300-hitachi-hms-objdump --disassemble-all -m h8300 bug.o

bug.o:     file format coff-h8300

Disassembly of section .text:

00000000 <_showbug>:
   0:   6d f6           6d f6             mov.w r6,@-e7
   2:   0d 76           0d 76             mov.w r7,r6
   4:   6a 0a 00 00     6a 0a 00 00       mov.b @0x0:16,r2l
   8:   0c aa           0c aa             mov.b r2l,r2l
   a:   46 00           46 00             bne   .0 (c)
                                          ^^^^^^^^^^^^^
   c:   fa fe           fa fe             mov.b #0xfe,r2l
   e:   6a 8a 00 00     6a 8a 00 00       mov.b r2l,@0x0:16

00000012 <.L1>:
  12:   6d 76           6d 76             mov.w @r7+,r6
  14:   54 70           54 70             rts
Disassembly of section .data:

the bne instruction will not catch negative values.
if you declare ch as signed char, however, a bgt intruction is
generated, what is fine -- and works in legOS, as i verified.

the volatile declaration seems to be essential. tx_state is read several
times in function lnp_logical_write, and in most cases will change it´s
value inbetween.


The 8 character queue will be the FIFO in the SIO - you can disable it
on Linux, I believe.

well, i hope there is an ioctl, i´ll check this. Many thanks for your
tips,
cheers, Martin



Message is in Reply To:
  Re: LNP collision detection Bug found and fixed
 
(...) It shouldn't matter if it does. More likely, it seems to me, is that TX_COLL is defined like this: #define TX_COLL -1 in which case, the offending statement becomes: tx_state=-1; which is old-style for: tx_state-=1; (should generate a (...) (25 years ago, 9-Dec-99, to lugnet.robotics.rcx.legos)

3 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