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 / 2232
2231  |  2233
Subject: 
GNU C wizards?
Newsgroups: 
lugnet.robotics
Date: 
Mon, 4 Jan 1999 05:20:46 GMT
Original-From: 
dave madden <[dhm@paradigm.webvision]spamcake[.com]>
Viewed: 
1178 times
  
Are there any GNU C/C++ wizards out there?  I'm trying to write an
asm() statement to describe the H8's bclr/bset instructions.  I have a
wicked sweet tooth for C++ syntactic sugar, and I'd like to be able to
say (for example):

    Port6.Bit3 = true;

and have it turn into:

    bset #3,@0xbb:8

[Actually, I'd *really* like to say: "Port6[3] = true;" but after
beating my head against the compiler for an hour or two, I don't think
it's going to happen.]

I'm making some headway with templates for Ports and Bits:

    template <int DR, int DDR> Port {
        public:
        template <int N> Bit {
            public:
            Bit &operator=( bool b ) {
                if (b)
                    asm( "bset..." );
                else
                    asm( "bclr..." );
                return *this;
            }
        } ;

        Bit<0>  Bit0;
        // ...
        Bit<7>  Bit7;
    } ;

but I can't get the constraints for the two asm() statements quite
right.  Can anybody help?

Thanks,
d.
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message has 1 Reply:
  Re: GNU C wizards?
 
(...) Actually, you can do that -- look at the STL implementation for BitVector<bool>. (...) This is similar to the STL implementation using a helper class for the assignments. All you need to do is pass a reference to the port object into the bit (...) (26 years ago, 4-Jan-99, to lugnet.robotics)

6 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