Forum Discussion
Altera_Forum
Honored Contributor
21 years agoUnoptimizing Code?
I have some code that basically bangs bits out a PPort. At the moment I dont really care how fast it occurs, however; the optimizer, or something is basically makeing my code useles! The code w...
Altera_Forum
Honored Contributor
21 years agoProperly speaking, you should use the stwio and ldwio opcodes rather than the stw and ldw opcodes for hitting IO ports. outb() and inb() should basically be something like
static char inb(unsigned int addr) { char result; __asm__ __volatile__ ( "ldwio %0, 0(%1)" : "=r" (result) : "r" addr); } and the appropriate corresponding thing for outb. It's a pity that you can't get it to work with <asm/io.h>, as that's the right way to do it.