1: #include "../h/config.h"
   2: /*
   3:  * Long integer arithmetic routines with overflow checking.
   4:  */
   5: Global(_runerr)         /* Run-time error routine */
   6: Global(_ckadd)
   7: Global(_cksub)
   8: Global(_ckmul)
   9: #ifdef VAX
  10:  .text
  11:  .align 1
  12: /*
  13:  * Addition.
  14:  */
  15: _ckadd: Mask    0
  16:         addl3   4(ap),8(ap),r0  # Perform addition
  17:         jvs     oflow           # Branch if overflow
  18:         ret                     # Return result in r0
  19: 
  20:  .align 1
  21: /*
  22:  * Subtraction.
  23:  */
  24: _cksub:Mask     0
  25:         subl3   8(ap),4(ap),r0  # Perform subtraction
  26:         jvs     oflow           # Branch if overflow
  27:         ret                     # Return result in r0
  28: 
  29:  .align 1
  30: /*
  31:  * Multiplication.
  32:  */
  33: _ckmul: Mask    0
  34:         mull3   4(ap),8(ap),r0  # Perform multiplication
  35:         jvs     oflow           # Branch if overflow
  36:         ret                     # Return result in r0
  37: 
  38: oflow:                          # Got overflow on an operation
  39:         pushl   $0
  40:         pushl   $203
  41:         calls   $1,_runerr      # runerr(203,0)
  42: 
  43: #endif VAX
  44: 
  45: #ifdef PORT
  46: DummyFcn(_ckadd)
  47: DummyFcn(_cksub)
  48: DummyFcn(_ckmul)
  49: #endif PORT
  50: 
  51: #ifdef PDP11
  52: / Long integer arithmetic routines with overflow checking
  53: Global(csv)
  54: Global(cret)
  55: 
  56:  .text
  57: _ckadd:
  58:         mov     r5,-(sp)
  59:         mov     sp,r5
  60:         mov     6(r5),r1
  61:         mov     4(r5),r0
  62:         add     12(r5),r1
  63:         adc     r0
  64:         bvs     oflow
  65:         add     10(r5),r0
  66:         bvs     oflow
  67:         br      return
  68: 
  69: _cksub:
  70:         mov     r5,-(sp)
  71:         mov     sp,r5
  72:         mov     6(r5),r1
  73:         mov     4(r5),r0
  74:         sub     12(r5),r1
  75:         sbc     r0
  76:         bvs     oflow
  77:         sub     10(r5),r0
  78:         bvs     oflow
  79: return:
  80:         mov     r5,sp
  81:         mov     (sp)+,r5
  82:         rts     pc
  83: 
  84: _ckmul:
  85:         jsr     r5,csv
  86:         mov     6(r5),r2
  87:         sxt     r1
  88:         sub     4(r5),r1
  89:         mov     10.(r5),r0
  90:         sxt     r3
  91:         sub     8.(r5),r3
  92:         mul     r0,r1
  93:         mul     r2,r3
  94:         add     r1,r3
  95:         mul     r2,r0
  96:         sub     r3,r0
  97:         jmp     cret
  98: 
  99: oflow:
 100:         clr     -(sp)
 101:         mov     $203.,-(sp)
 102:         jsr     pc,_runerr
 103: #endif PDP11

Defined functions

_ckadd defined in line 57; used 2 times
  • in line 6, 46
_ckmul defined in line 84; used 2 times
  • in line 8, 48
_cksub defined in line 69; used 2 times
  • in line 7, 47
oflow defined in line 99; used 7 times
return defined in line 79; used 1 times
  • in line 67
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 765
Valid CSS Valid XHTML 1.0 Strict