|
|
1.1 ! root 1: .data ! 2: .asciz "@(#)addupc.s 1.1 86/02/03 Copyr 19834Sun Micro" ! 3: .even ! 4: .text ! 5: ! 6: | Copyright (c) 1984 by Sun Microsystems, Inc. ! 7: ! 8: | ! 9: | Add to user profiling counters. ! 10: | ! 11: | struct uprof { /* profile arguments */ ! 12: | short *pr_base; /* buffer base */ ! 13: | unsigned pr_size; /* buffer size */ ! 14: | unsigned pr_off; /* pc offset */ ! 15: | unsigned pr_scale; /* pc scaling */ ! 16: | } ; ! 17: | addupc( pc, pr, incr) ! 18: | register int pc; ! 19: | register struct uprof *pr; ! 20: | int incr; ! 21: | { ! 22: | register short *slot; ! 23: | short counter; ! 24: | ! 25: | slot = pr->pr_base ! 26: | + (((pc - pr->pr_off) * pr->pr_scale) >> 16)/(sizeof *slot); ! 27: | if (slot >= pr->pr_base && ! 28: | slot < (short *)(pr->pr_size + (int)pr->pr_base)) { ! 29: | if ((counter=fusword(slot))<0) { ! 30: | pr->pr_scale = 0; /* turn off profiling */ ! 31: | } else { ! 32: | counter += incr; ! 33: | susword(slot, counter); ! 34: | } ! 35: | } ! 36: | } ! 37: ! 38: #include "../machine/asm_linkage.h" ! 39: ! 40: PR_SIZE = 4 ! 41: PR_OFF = 8 ! 42: PR_SCALE= 12 ! 43: .text ! 44: ENTRY(addupc) ! 45: link a6,#-16 ! 46: moveml #0x3080,sp@ ! 47: movl a6@(8),d7 ! 48: movl a6@(12),a5 ! 49: | compute: ! 50: | pc - pr->pr_off in d7 ! 51: | +--------+--------+ ! 52: | | a | b | ! 53: | +--------+--------+ ! 54: | 31 16 15 0 ! 55: | ! 56: | pr->pr_scale at a5@(PR_SCALE) ! 57: | +--------+--------+ ! 58: | | c | d | ! 59: | +--------+--------+ ! 60: | 31 16 15 0 ! 61: | ! 62: | (pc - pr->pr_off) * pr->pr_scale >>16 ! 63: | is the middle bits of a sum of 4 products: ! 64: | ! 65: | +--------+--------+ ! 66: | | b * d | ! 67: | +--------+--------+ ! 68: | +--------+--------+ ! 69: | + | a * d | ! 70: | +--------+--------+ ! 71: | +--------+--------+ ! 72: | + | c * b | ! 73: | +--------+--------+ ! 74: | +--------+--------+ ! 75: | + | a * c | ! 76: | +--------+--------+ ! 77: |______________________________________________________ ! 78: | ! 79: | +--------+--------+ ! 80: | | result in d0 | ! 81: | +--------+--------+ ! 82: | ! 83: | ! 84: ! 85: subl a5@(PR_OFF),d7 ! 86: movw d7,d0 ! 87: mulu a5@(PR_SCALE+2),d0 ! 88: clrw d0 ! 89: swap d0 ! 90: movw d7,d1 ! 91: beqs 1f | short cut if product will be zero ! 92: mulu a5@(PR_SCALE),d1 ! 93: addl d1,d0 ! 94: 1: ! 95: swap d7 ! 96: movw a5@(PR_SCALE+2),d1 ! 97: beqs 2f | short cut if product will be zero ! 98: mulu d7,d1 ! 99: addl d1,d0 ! 100: 2: ! 101: movw a5@(PR_SCALE),d1 ! 102: beqs 3f | short cut if product will be zero ! 103: mulu d7,d1 ! 104: swap d1 ! 105: clrw d1 ! 106: addl d1,d0 ! 107: 3: ! 108: andb #0xfe,d0 | make sure address is even. ! 109: addl a5@,d0 ! 110: movl d0,a4 ! 111: cmpl a5@,a4 ! 112: jcs LE12 ! 113: movl a5@(PR_SIZE),d0 ! 114: addl a5@,d0 ! 115: cmpl d0,a4 ! 116: jcc LE12 ! 117: pea a4@ ! 118: jbsr _fusword ! 119: addql #4,sp ! 120: tstl d0 ! 121: jge L16 ! 122: clrl a5@(PR_SCALE) ! 123: jra LE12 ! 124: L16: ! 125: addw a6@(18),d0 ! 126: movl d0,sp@- ! 127: pea a4@ ! 128: jbsr _susword ! 129: addql #8,sp ! 130: LE12: ! 131: moveml sp@,#0x3080 ! 132: unlk a6 ! 133: rts
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.