Subject: looks like a compiler error
To: None <tech-toolchain@NetBSD.ORG>
From: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
List: tech-toolchain
Date: 01/16/1998 18:24:04
I just found a piece of code which doesn't work as expected:
(from cgd's new wscons code)

		ev->value = ffs(d) - 1;
#if 0
		KASSERT(ev->value >= 0);
#else
		if (ev->value < 0)
		    printf("wsms_in: %x/%x/%x\n", mb, ub, ev->value);
#endif

Here is what the (-current) compiler makes of it:

0xf021be28 <wsmouse_input+116>: bsfl   0xffffffec(%ebp),%eax
0xf021be2c <wsmouse_input+120>: jne    0xf021be33 <wsmouse_input+127>
0xf021be2e <wsmouse_input+122>: movl   $0xffffffff,%eax
0xf021be33 <wsmouse_input+127>: movl   %eax,0x4(%ebx)
0xf021be36 <wsmouse_input+130>: jns    0xf021be4c <wsmouse_input+152>
0xf021be38 <wsmouse_input+132>: pushl  %eax
0xf021be39 <wsmouse_input+133>: pushl  0xfffffff4(%ebp)
0xf021be3c <wsmouse_input+136>: pushl  0xfffffff8(%ebp)
0xf021be3f <wsmouse_input+139>: pushl  $0xf021bd9e
0xf021be44 <wsmouse_input+144>: call   0xf012e044 <printf>
0xf021be49 <wsmouse_input+149>: addl   $0x10,%esp

The "less than zero" decision is made by "jns", but the sign flag
is not valid at this point ("bsfl" sets only the zero flag).

best regards
Matthias