Weird code
justice at isucs1.UUCP
justice at isucs1.UUCP
Tue Oct 15 18:04:32 AEST 1985
Ok you wizards out there, why does this program do what it does?
Here are a couple of hints:
1) It only works on Vaxes
2) The same idea is used to initialize the UNIBUS adapters
--------------Here is a script showing the details------------------------
Script started on Mon Oct 14 14:08:05 1985
% cat reg.c
main()
{
register int x, y;
int i;
int func();
fix((int *)func);
x = 1; y = 5;
for (i = 1; i <= 10; i++) {
func(1,5);
printf("x = %d, y = %d\n",x,y);
}
}
func(x,y)
int x,y;
{
register int a,b;
a += a; b *= 5;
x--; y++;
}
fix(f)
int *f;
{
*f &= ~0xc00;
}
% cc reg.c -N -o reg
% reg
x = 2, y = 25
x = 4, y = 125
x = 8, y = 625
x = 16, y = 3125
x = 32, y = 15625
x = 64, y = 78125
x = 128, y = 390625
x = 256, y = 1953125
x = 512, y = 9765625
x = 1024, y = 48828125
% exit
%
script done on Mon Oct 14 14:08:29 1985
--------------------------------------------------------------------------
Good luck!
Brian Justice, Iowa State University
UUCP: {okstate||umn-cs||csu-cs}!isucs1!justice CSNET: justice at iowa-state
More information about the Comp.unix.wizards
mailing list