I bet you could do UART_RBR_A_REG + (8*selectedUart) = somevalue I need to write I do this kind of branch elimination optimization all the time. Good luck, Dave Helsley ----- Original Message ----- From: <> To: <> Sent: Monday, November 19, 2001 11:57 AM Subject: [c54x] ioport > I have a UART chip with two Uarts on it, and the registers are mapped > into memory locations 0-7 for Uart A and 8-15 for Uart B. > > I have them defined like this: > > #define UART_RBR_A_REG port0 > #define UART_THR_A_REG port0 > #define UART_IER_A_REG port1 > #define UART_IIR_A_REG port2 > #define UART_FCR_A_REG port2 > #define UART_LCR_A_REG port3 > #define UART_MCR_A_REG port4 > #define UART_LSR_A_REG port5 > #define UART_MSR_A_REG port6 > #define UART_SCR_A_REG port7 > > // uart B registers > #define UART_RBR_B_REG port8 > #define UART_THR_B_REG port8 > #define UART_IER_B_REG port9 > #define UART_IIR_B_REG porta > #define UART_FCR_B_REG porta > #define UART_LCR_B_REG portb > #define UART_MCR_B_REG portc > #define UART_LSR_B_REG portd > #define UART_MSR_B_REG porte > #define UART_SCR_B_REG portf > I also have a enumerated type like this : > typedef enum > { > UART_A = 0x00, > UART_B = 0x01, > } UartSelect, *PUartSelect; > > with a variable declared as : > UartSelect selectedUart; > > what I would like to be able to do is like this: > > UART_RBR_A_REG + selectedUart = somevalue I need to write > > Instead of doing this > > If(selectedUArt == UART_A) > { > UART_RBR_A_REG = somevalue; > } > else > { > UART_RBR_B_REG = somevalue; > } > Is there a way of doing this? > Carl Chipman > Nomadics, Inc. > > http://www.nomadics.com > _____________________________________ > Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. > > _____________________________________ > About this discussion group: > > To Join: Send an email to > > To Post: Send an email to > > To Leave: Send an email to > > Archives: http://www.yahoogroups.com/group/c54x > > Other Groups: http://www.dsprelated.com > ">http://docs.yahoo.com/info/terms/ > |