Mail Archives: djgpp/1996/10/07/14:30:39
YOMERO SOFTWARE LTD. wrote:
> >The code giving me the problem is:
> >
> >void myproc()
> >{
> > __asm__ __volatile__("
> > cli\n
> > movw $0x3DA, %dx\n
> >loc1:\n
> > inb %dx, %al\n
> > andb $8, %al\n
> > jnz loc1\n
> >loc2:\n
> > inb %dx, %al\n
> > andb $8, %al\n
> > jz loc2\n");
> >}
> >
> >What am I doing wrong? Help me, or I'll be bold soon! This error has driven
> >me NUTS!!!
> Farhan:
[--snip--]
> That's the way I did it, hope it works for you too! let me know about.
>
> Yomero.
You are both wrong. With optimization, the compiler is free to put
myproc()
inlined in other functions, thereby causing several loc1 and loc2 labels
in
the assembly file. The solution is to use GCC's unnamed labels:
void myproc() {
__asm__ __volatile__(
"\tcli\n\t"
"movw $0x3da, %dx\n"
"1:\t" "inb %dx, %al\n\t"
"andb $8, %al\n\t"
"jnz 1b\n"
"1:\t" "inb %dx, %al\n\t"
"andb $8, %al\n\t"
"jz 1b\n");
}
The point is that numbered labels can be repeated. When using them, you
will
specify '1b' to get _back_ to the previous label 1, and '1f' to get
_forward_
to the next label 1.
Another thing though. Those assembly statements is unnescessary, as GCC
compiles the equivalent C code just as well as you can do.
PKE.
--
Pål-Kristian Engstad, Funcom Oslo AS, http://www.funcom.com/~engstad
mailto:engstad AT funcom DOT com, +47 22 42 01 02.
- Raw text -