Aucbvax.6857 fa.info-vax utzoo!decvax!ucbvax!info-vax Thu Apr 22 09:30:57 1982 unix cc and float registers >From dove@mit-dspg@mit-mc Thu Apr 22 09:22:29 1982 The following results were obtained from mit-vax (berkeley 4.1 I think). The adb files were taken from a.out. The only compiler switch was -O. ---junkc.c--- main() { register double z=0, x=1; register int i=100000; while(i-->0) { z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; } } ---junkc.adb---- _main: _main: 800 3e: subl2 $10,sp 41: movd _environ+4,-8(fp) 49: movd _environ+c,-10(fp) 51: movl $186a0,r11 58: brb 8c 5a: addd2 -10(fp),-8(fp) 5f: addd2 -10(fp),-8(fp) 64: addd2 -10(fp),-8(fp) 69: addd2 -10(fp),-8(fp) 6e: addd2 -10(fp),-8(fp) 73: addd2 -10(fp),-8(fp) 78: addd2 -10(fp),-8(fp) 7d: addd2 -10(fp),-8(fp) 82: addd2 -10(fp),-8(fp) 87: addd2 -10(fp),-8(fp) 8c: movl r11,r0 8f: decl r11 91: tstl r0 93: bgtr 5a 95: ret 96: halt 97: halt _exit: ---junkp.p--- program junkp (input, output); var z, x :real; i : integer; begin z := 0; x := 1; i := 100000; while i>0 do begin z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; i := i-1 end end. ---junkp.adb--- _program: _program: 0 66: subl2 $10,sp 69: moval _UNWIND,(fp) 70: moval __disply+8,-4(fp) 78: movq __disply+8,-c(fp) 80: movq ap,__disply+8 87: clrq _z 8d: cvtld $1,_x 94: movl $186a0,_i 9f: brb _program+b2 a1: addd2 _x,_z ac: addd2 _x,_z b7: addd2 _x,_z c2: addd2 _x,_z cd: addd2 _x,_z d8: addd2 _x,_z e3: addd2 _x,_z ee: addd2 _x,_z f9: addd2 _x,_z _program+a0: addd2 _x,_z _program+ab: subl2 $1,_i _program+b2: tstl _i _program+b8: bgtr a1 _program+ba: movq -c(fp),__disply+8 _program+c2: ret _program+c3: As you can see, registers don't get used for floating point. Here is an equivalent program with ints instead of doubles, and it does the right thing: ---junkci.c--- main() { register int z=0, x=1; register int i; for(i=0; i<100000; 51: 43: RET 5A: 3E: UNDERSTAND 60: +="x;" 45: C I++) 4E: Z 54: INCL R9,$186A0 5D: { } 63: 6C: FLOATS!) (WHEN MOVL 48: 65: 57: R9 R10,R11 6E: 45 6F:
This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.
2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright© 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.


Goto NEXT article in FA.info-vax Newsgroup
Return to FA.info-vax index
Return to the Usenet Oldnews Archive index ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.