View Single Post
  #27   Spotlight this post!  
Unread 18-03-2004, 11:00
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Help! Programming question with triggers

Quote:
Originally Posted by KenWittlief
it is concise in C - but unless the CPU has a HW multiplyer then multiplyer that one line of code might compile into something that will take hundreds of machine cycles to execute in assembler

when you only need an '=' getting clever to make your C look concise is usually a big mistake.
Actually both routines, Anthony Kesich's one-liner and Xufer's selection structure, take exactly 22 bytes of program space, just check the list file (FrcCode.lst) after compiling both. Xufers routine was the most program space efficient of the selection structures I saw because it involved the least branching (i.e. no else to set neutral which only takes 2 bytes). Anthony’s routine could probably be optimized in assembler since only the sign bit and least significant bit of one of the factors is relevant (I don't program in assembler so I am not sure). One-liners are much better for relays because it is simply addition no multiplication.

Processor speed is a different story and depends on the processor architecture.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 18-03-2004 at 11:10.