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 / 2288
2287  |  2289
Subject: 
H8 bit operations (was Re: GNU C wizards?)
Newsgroups: 
lugnet.robotics
Date: 
Mon, 4 Jan 1999 22:52:18 GMT
Original-From: 
John A. Tamplin <jat@traveller%AntiSpam%.com>
Viewed: 
1589 times
  
On Mon, 4 Jan 1999, John A. Tamplin wrote:

=>I don't think you need to use asm - the compiler will use those
=>instructions.  Just do it in C++:
=>  value|=(1<<bit) to set
=>  value&= ~(1<<bit) to clear

I saw "bset" and "bclr" generated for these types of statements in
some places, but my test case (Port6[3] = true;) resulted in

mov.b @0xffbb,r2l ; (this is from memory...)
or.b #x08,r2l
mov.b r2l,@0xffbb

Wastes space, and worse, throws off the timing.  (Although the LCD
driver doesn't seem to be *that* sensitive to those delay loops
getting shortened.)

Hmm, you are correct.  It does seem to reliably generate btst instructions
for things like if(*p & 4) ..., but the set/clear aren't always.  That should
be something that can be fixed in the compiler, possibly creating a peephole
optimization.

After looking into it further, if the compiler has the address in a
register (or will use it more than once so it will load it in a register),
it does use the bset/bclr instructions.  However, there is this in h8300.md:

;; Bitfield operations no longer accept memory operands.  We need
;; to add variants which operate on memory back to the MD.

Looking at the instruction patterns, it restricts the type of the second
operand to being non-memory, presumably so it can use the or instruction
if the value isn't suitable for bset.  There are constraint types O and P
already, so I think it should be easy to add those instructions as
separate patterns in addition to the patterns already there.

I will play around with the machine description and let you know what I find.

John A. Tamplin Traveller Information Services
jat@Traveller.COM 2104 West Ferry Way
256/705-7007 - FAX 256/705-7100 Huntsville, AL 35801

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



Message has 1 Reply:
  Re: H8 bit operations (was Re: GNU C wizards?)
 
Ok, after more investigation the problem is twofold: 1) The compiler doesn't look at an absolute address (such as generated by #define P6DR (*(volatile unsigned char *)0xFFBB) and then used by P6DR=0). Instead, it looks for an attribute (...) (26 years ago, 5-Jan-99, to lugnet.robotics)

Message is in Reply To:
  Re: GNU C wizards?
 
(...) GCC has in general done a very good job removing unnecessary code from templates. You can certainly optimize the generated code further, but you are getting the facilities of a high-level language in exchange for the (usually) small losses in (...) (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

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

Custom Search

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