Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!uokmax!munnari.oz.au!metro!dmssyd.syd.dms.CSIRO.AU!ditsydh.syd.dit.CSIRO.AU!evans From: evans@syd.dit.CSIRO.AU (Bruce.Evans) Newsgroups: comp.os.minix Subject: Re: bcc, goto and address out of bound Message-ID: <1991Apr3.104229.16478@syd.dit.CSIRO.AU> Date: 3 Apr 91 10:42:29 GMT References: <157@petruz.sublink.ORG> <159@petruz.sublink.ORG> <168@acestes.UUCP> Organization: CSIRO Division of Info Tech, Sydney, Australia Lines: 38 In article <168@acestes.UUCP> paradis@acestes.UUCP (Jim Paradis) writes: >In article <159@petruz.sublink.ORG> root@petruz.sublink.ORG (root) writes: > >>I got some pieces of code with many , really many , goto's ... it seems >>that bcc gets lost with them , It produces a good assembler output but >>"as" tells me that there is an address out of bound :-( >> >>I used also -j option for As , all works fine ... 'till crash ! >> >> ... what can I do ? ( please don't tell me to clean goto's ... I can't ! ) > >Ah yes... turns out this is a bug in Bruce's compiler 8-( You see, there >... >The bug is that this does NOT work for the UNconditional relative jump >instruction, but the assembler tries this trick anyway. The unconditional >relative jump byte displacement opcode is "eb"; apply the above trick >to it and you get 0f fb. This is an illegal instruction, and your program >crashes. The "address out of bounds" bug is in the compiler. It gets the lengths of instructions slightly wrong. I have fixed at least one wrong length. The other bug is really in the assembler. "loop" instructions also have the bug. 32-bit offsets are not even legal for loops. The bug has not caused much trouble because no compilers generate "loop" and the -j flag is used mostly by my port of gcc, which outputs "jmp" instead of "j". The bug does not affect "jmp" (or the old equivalent "br"). I have not fixed it, but for other reasons I recently changed the meaning of "jmp" to "jmp short" and made bcc output "jmp" instructions, so the buggy "j" case is not exposed. Instead of the -j flag, the -w flag (i.e. cc -C-w) might help. It causes all jumps to be output as long in the first place. Unfortunately it also forces an assembly error if the first bug occurred. It's relatively easy to get around this by editing the assembler file. -- Bruce Evans evans@syd.dit.csiro.au