duk@vu44.UUCP (09/08/84)
Who needs assembler when you can use C to write illegible, self-modifying code. The program below, slightly adapted from a program by Jack Jansen, compiles and "works" on our PDP11/44 running Unix V7. -------------------------------------------------------------------------- #include <stdio.h> main() { func(0); func(1); } func(arg) int arg; { int *jumptab[2]; goto endofit; /* cannot use &label before it's defined */ lab0: printf("Lab 0\n"); return; lab1: printf("Lab 1\n"); return; lab2: "Lab 2\n"; endofit: jumptab[0] = lab0; jumptab[1] = lab1; *(jumptab[0] + 1) = *(lab2 + 1); goto jumptab[arg]; } -------------------------------------------------------------------------- You shouldn't give any of the options -i, -n (evidently), or -O to cc. When you give the -O flag, the optimizer throws the labels away since they are not used (it *thinks* the're not used!), and then later ld can't find them. Duk Bekema