From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Pereira Habkost Subject: [bcc patch] Fix variable offset macros for #asm (was: Re: ELKS memcpy_fromfs() failing. Wrong variable offsets) Date: Wed, 2 Jun 2004 13:10:49 -0300 Sender: linux-8086-owner@vger.kernel.org Message-ID: <20040602161048.GB26330@duckman.distro.conectiva> References: <20040601222140.GV21172@duckman.distro.conectiva> <609c173af82cc283@mayday.cix.co.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tjCHc7DPkfUGtrlw" Return-path: Content-Disposition: inline In-Reply-To: <609c173af82cc283@mayday.cix.co.uk> List-Id: To: Robert de Bath Cc: Linux-8086 --tjCHc7DPkfUGtrlw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 02, 2004 at 09:47:25AM +0100, Robert de Bath wrote: >=20 > You have highlighted a bug though, the definition some of the 'set' > variables is actually wrong, they should have memcpy_fromfs.off added > when it might be non-zero. I am sending a fix to this bug. I hope that I didn't anything wrong, as I am not familiar with bcc code. I guess that creating an outoffset(variable) function that uses .off when needed would be better, but that was just a quick fix. >=20 > BTW: You should really be using those variables to access C arguments > and locals, the '_memcpy_fromfs.ds' is for stack pointer relative the > '.memcpy_fromfs.ds' is for 'bp' relative. As we have a fix for bcc >=3D 0.16.8, I will send a fix for ELKS code, for using .., now. :) >=20 > I can fix the bug in one of two ways; either actually add the > 'memcpy_fromfs.off' variable to the 'set' variables or simply > have the compiler assume that any '#asm' will use si and di. > (The asm("...") function will not however.) >=20 > Actually I think assuming that #asm uses si/di is best because as this > example has shown it is quite likely to be true, plus, it's the failsafe > option. I prefer the code as it is now: if some #asm will use some register, then it should save it. Or maybe a better one (IMO): having a way to tell the compiler which registers will be used. And even if assuming that all #asm will use SI and DI, it is a little safer fixing the offsets, too. Just in case someone make more changes to the code, try to optmize #asm, and break things because there are implict things (like: dumplocs() only work because when using #asm, .off is zero) they didn't see. Which fix do you plan to include on the next releases of bcc? (BTW, I really missed a BCC_VERSION macro or equivalent. It would be very useful in cases like this one) -- Eduardo --- dev86-0.16.15/bcc/codefrag.c 2002-08-03 13:38:27.000000000 -0300 +++ dev86-current/bcc/codefrag.c 2004-06-02 12:38:28.233060704 -0300 @@ -105,7 +105,6 @@ # define outlswitch() (outload(), outstr(ireg0str), outncregname(DREG)) # define outnc1() outnstr(",*1") # define outsbc() outop3str("sbb\t") -# define outset() outstr ("\tset\t") # define outsl() outop2str("shl\t") # define outsr() outop2str("sar\t") # define outtransfer() outload() @@ -134,6 +133,10 @@ outstr(acclostr); outncregname(BREG); } +PUBLIC void outset() +{ + outstr ("\tset\t"); +} PUBLIC void comment() { outstr("! "); @@ -417,7 +420,6 @@ # define outpil2switch() outnop2str("LDD\tD,X") # define outrolhi() outnop1str("ROLA"); # define outsbc() outop2str("SBC") -# define outset() outstr ("\tSET\t") # define outsl() outop1str("LSL") # define outtransfer() outop2str("TFR\t") # define reclaimfactor() outnstr ("++") /* discard factor from stack */ @@ -434,6 +436,10 @@ # define tfrhilo() outnop2str("TFR\tA,B") # define tfrlohi() outnop2str("TFR\tB,A") # define usr1() (outnop1str("LSRA"), outnop1str("RORB")) +PUBLIC void outset() +{ + outstr ("\tSET\t"); +} PUBLIC void clrBreg() { outnop1str("CLRB"); --- dev86-0.16.15/bcc/table.c 2002-07-28 04:43:13.000000000 -0300 +++ dev86-current/bcc/table.c 2004-06-02 12:48:12.176287840 -0300 @@ -402,8 +402,38 @@ =20 for (i =3D 0; i < HASHTABSIZE; ++i) for (symptr =3D hashtab[i]; symptr !=3D NULL; symptr =3D symptr->next) - if (symptr->storage =3D=3D LOCAL) - set(symptr->name.namea, symptr->offset.offi - sp); + if (symptr->storage =3D=3D LOCAL) { + /* Variable offset relative to sp */ + outccname(funcname); + outbyte(LOCALSTARTCHAR); + outstr(symptr->name.namea); + outset(); + outshex(symptr->offset.offi - sp); + outnl(); + +#ifdef FRAMEPOINTER + /* Variable offset relative to bp */ + if (framep)=20 + { + outbyte(LOCALSTARTCHAR); + outstr(funcname); + outbyte(LOCALSTARTCHAR); + outstr(symptr->name.namea); + outset(); + outshex(symptr->offset.offi - framep); +#ifdef I8088 +#ifndef NO_DEL_PUSH + if (optimise && !callersaves && symptr->offset.offi < framep) { + outbyte('+'); + outstr(funcname); + outstr(".off"); + } +#endif +#endif + outnl(); + } +#endif + } } =20 #ifdef HOLDSTRINGS --tjCHc7DPkfUGtrlw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFAvfwIcaRJ66w1lWgRAoa3AJ9bczUkfa+l50dyk/QiOaifXFYhHgCeOI2q Jh7S2f5p9kYTwTbGEV4uk48= =WIu8 -----END PGP SIGNATURE----- --tjCHc7DPkfUGtrlw--