Daniel_Roedding@fiction.ms.sub.org (08/30/90)
cchase@ee.cornell.edu (Craig M. Chase) writes: > For reasons that > I won't go into here, we've got a bunch of registers that work as > pairs. What I mean is that (unless something goes drastically > wrong) these registers will always have the save value. When I > write to one, I really want to write to both. (...) > Problem is, if I try: > if (fancy_reg == 0xFFFF) > I get: > if (reg1 = reg2 == 0xFFFF) > and that doesn't do the right thing (== binds tighter than =, right?) BTW: Do you really want a re-assignment when reaching this if-statement? I think it's more elegant to access such a hardware register by two pseudo-functions, e.g.: #define setreg(x,y) x=(y) #define getreg(x) (x) Then you could use: #define fancy_reg reg1 = reg2 ... and then: Your solution: > So, if I do > fancy_reg = 0xFFFF; > the preprocessor generates: > reg1 = reg2 = 0xFFFF; And the new one: setreg(fancy_reg,0xffff); -> reg1 = reg2 = (0xffff); When reading from the port: if (getreg(fancy_reg)==0xffff) -> if ((reg1 = reg2) == 0xffff) Probably it's more elegant -- but it's no good when you access the registers very often (or do you like to hundredfold write rendundant stuff like "getreg"? - anyway, it's the way how *I* would solve the problem). Daniel --- Daniel Roedding #include <disclaimer.h> Geiststrasse 32 "This golden age of communication D-4400 Muenster Means everyone talks at the same time" (NMA) ++49 251 525306 daniel@fiction.ms.sub.org; ..!uunet!mcsun!unido!mcshh!veeble!fiction!daniel