Short code to determine compiler's register use

John Hascall hascall at atanasoff.cs.iastate.edu
Sun Jul 23 00:03:04 AEST 1989


In <untold articles> <everyone at everywhere> "hordes o' people" have wrote:

    [.. various schemes (all flamed) to count used registers ..]

  Well, I think we've decided this is machine dependent, so I submit for your
kind flamage a VMS version (tested even, imagine that :-)

REG.C:
main()
{     
        register int        a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;
        int                 fn(); 
        short               *regs;

        a = fn(); b = fn(); c = fn(); d = fn();
        e = fn(); f = fn(); g = fn(); h = fn();
        i = fn(); j = fn(); k = fn(); l = fn();
        m = fn(); n = fn(); o = fn(); p = fn();

        regs = (short*)main;

        printf("Register mask = %04.4x\n", *regs);

        fx(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
}
RDUMMY.C:
fn()
{return(1);}
fx(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;
{}
------------------------------------------------------

John



More information about the Comp.lang.c mailing list