1: /
   2: /
   3: 
   4: / rc -- complex arithmetic
   5: 
   6: .globl  c8c16
   7: .globl  c16c8
   8: .globl  i4c8
   9: .globl  r4c8
  10: .globl  r8c8
  11: .globl  i4c16
  12: .globl  r4c16
  13: .globl  r8c16
  14: .globl  cad8
  15: .globl  csb8
  16: .globl  cmp8
  17: .globl  cdv8
  18: .globl  cng8
  19: .globl  cad16
  20: .globl  csb16
  21: .globl  cmp16
  22: .globl  cdv16
  23: .globl  cng16
  24: .globl  rval16
  25: .globl  rval16p
  26: .globl  gas16
  27: .globl  ceq8
  28: .globl  cne8
  29: .globl  ceq16
  30: .globl  cne16
  31: 
  32: .globl  cpi8
  33: .globl  cpi16
  34: 
  35: one = 040200
  36: a = r2
  37: b = r3
  38: c = r4
  39: d = r5
  40: 
  41: e = r0
  42: f = r1
  43: 
  44: gas16:
  45:         mov     16.(sp),r0
  46:         setd
  47:         movf    (sp)+,a
  48:         movf    (sp)+,b
  49:         tst     (sp)+
  50:         movf    a,(r0)+
  51:         movf    b,(r0)+
  52:         jmp     *(r4)+
  53: 
  54: rval16p:
  55:         mov     r3,r0
  56:         add     (r4)+,r0
  57:         mov     (r0),r0
  58:         br      1f
  59: 
  60: rval16:
  61:         mov     (r4)+,r0
  62: 1:
  63:         setd
  64:         movf    (r0)+,a
  65:         movf    (r0)+,b
  66:         movf    b,-(sp)
  67:         movf    a,-(sp)
  68:         jmp     *(r4)+
  69: 
  70: cad16:
  71:         setd
  72:         br      1f
  73: 
  74: cad8:
  75:         setf
  76: 1:
  77:         jsr     pc,garg
  78:         addf    a,e
  79:         addf    b,f
  80:         br      sarg
  81: 
  82: csb16:
  83:         setd
  84:         br      1f
  85: 
  86: csb8:
  87:         setf
  88: 1:
  89:         jsr     pc,garg
  90:         subf    a,e
  91:         negf    e
  92:         subf    b,f
  93:         negf    f
  94:         br      sarg
  95: 
  96: cmp16:
  97:         setd
  98:         br      1f
  99: 
 100: cmp8:
 101:         setf
 102: 1:
 103:         jsr     pc,garg
 104:         mulf    a,e
 105:         mulf    b,f
 106:         subf    f,e
 107:         mulf    d,a
 108:         mulf    c,b
 109:         movf    a,f
 110:         addf    b,f
 111: 
 112: sarg:
 113:         movf    f,-(sp)
 114:         movf    e,-(sp)
 115:         jmp     *(r4)+
 116: 
 117: cdv16:
 118:         setd
 119:         br      1f
 120: 
 121: cdv8:
 122:         setf
 123: 1:
 124: divide:
 125:         jsr     pc,garg
 126:         absf    e
 127:         absf    f
 128:         cmpf    e,f
 129:         cfcc
 130:         blt     1f
 131: 
 132: / algorithm #1 |c| > |d|
 133: 
 134:         movf    d,e
 135:         divf    c,e             / r = d/c
 136:         movf    d,f
 137:         mulf    e,f
 138:         addf    c,f             / x = c+rd
 139:         movf    f,c
 140:         movf    a,f
 141:         mulf    e,f
 142:         negf    f
 143:         addf    b,f
 144:         mulf    b,e
 145:         addf    a,e
 146:         divf    c,e
 147:         divf    c,f
 148:         br      sarg
 149: 
 150: / algorithm #2 |c| < |d|
 151: 
 152: 1:
 153:         movf    c,e
 154:         divf    d,e             / r = c/d
 155:         movf    c,f
 156:         mulf    e,f
 157:         addf    d,f             / x = d+rc
 158:         movf    f,c
 159:         movf    b,f
 160:         mulf    e,f
 161:         subf    a,f
 162:         mulf    a,e
 163:         addf    b,e
 164:         divf    c,e
 165:         divf    c,f
 166:         br      sarg
 167: 
 168: cng16:
 169:         setd
 170:         br      1f
 171: 
 172: cng8:
 173:         setf
 174: 1:
 175:         movf    (sp)+,a
 176:         negf    a
 177:         negf    (sp)
 178:         movf    a,-(sp)
 179:         jmp     *(r4)+
 180: 
 181: / setup the following registers
 182: / (a,bi) +o (c,di) -> (e+fi)
 183: / a,b,c,d are input
 184: / e,f are output and also contain
 185: / c,d on input
 186: 
 187: garg:
 188:         mov     (sp)+,r0
 189:         movf    (sp)+,e
 190:         movf    e,c
 191:         movf    (sp)+,f
 192:         movf    f,d
 193:         movf    (sp)+,a
 194:         movf    (sp)+,b
 195:         jmp     (r0)
 196: 
 197: i4c8:
 198:         setf
 199:         br      1f
 200: 
 201: i4c16:
 202:         setd
 203: 1:
 204:         setl
 205:         movif   (sp)+,fr0
 206:         br      2f
 207: 
 208: r4c8:
 209:         setf
 210:         br      1f
 211: 
 212: r8c16:
 213:         setd
 214: 1:
 215:         movf    (sp)+,fr0
 216:         br      2f
 217: 
 218: r4c16:
 219:         setd
 220:         br      1f
 221: 
 222: r8c8:
 223:         setf
 224: 1:
 225:         movof   (sp)+,fr0
 226: 2:
 227:         clrf    -(sp)
 228:         movf    fr0,-(sp)
 229:         jmp     *(r4)+
 230: 
 231: c16c8:
 232:         setd
 233:         br      1f
 234: 
 235: c8c16:
 236:         setf
 237: 1:
 238:         movf    (sp)+,r0
 239:         movf    (sp)+,r1
 240:         movfo   r1,-(sp)
 241:         movfo   r0,-(sp)
 242:         jmp     *(r4)+
 243: 
 244: ceq16:
 245:         setd
 246:         br      1f
 247: ceq8:
 248:         setf
 249: 1:
 250:         mov     $1,r1
 251:         br      2f
 252: 
 253: cne16:
 254:         setd
 255:         br      1f
 256: 
 257: cne8:
 258:         setf
 259: 1:
 260:         clr     r1
 261: 2:
 262:         jsr     pc,garg
 263:         cmpf    c,a
 264:         cfcc
 265:         bne     1f
 266:         cmpf    d,b
 267:         cfcc
 268:         beq     2f
 269: 1:
 270:         inc     r1
 271:         bic     $2,r1
 272: 2:
 273:         mov     r1,-(sp)
 274:         jmp     *(r4)+
 275: 
 276: cpi8:
 277:         setf
 278:         br      1f
 279: 
 280: cpi16:
 281:         setd
 282: 1:
 283:         clr     r0
 284:         tst     (sp)+
 285:         mov     (sp)+,r1
 286:         bge     1f
 287:         inc     r0
 288:         neg     r1
 289: 1:
 290:         movf    (sp)+,fr0
 291:         movf    fr0,fr4
 292:         movf    (sp)+,fr0
 293:         movf    fr0,fr5
 294:         movf    $one,fr0
 295:         clrf    fr1
 296: 1:
 297:         dec     r1
 298:         bmi     1f
 299:         movf    fr0,fr2
 300:         movf    fr1,fr3
 301:         mulf    fr4,fr0
 302:         mulf    fr4,fr1
 303:         mulf    fr5,fr2
 304:         mulf    fr5,fr3
 305:         subf    fr3,fr0
 306:         addf    fr2,fr1
 307:         br      1b
 308: 1:
 309:         tst     r0
 310:         beq     1f
 311:         clrf    -(sp)
 312:         movf    $one,fr2
 313:         movf    fr2,-(sp)
 314:         movf    fr1,-(sp)
 315:         movf    fr0,-(sp)
 316:         jmp     divide
 317: 1:
 318:         movf    fr1,-(sp)
 319:         movf    fr0,-(sp)
 320:         jmp     *(r4)+

Defined functions

a defined in line 36; used 18 times
b defined in line 37; used 15 times
c defined in line 38; used 13 times
c16c8 declared in line 7; defined in line 231; used 1 times
  • in line 7
c8c16 declared in line 6; defined in line 235; used 1 times
  • in line 6
cad16 declared in line 19; defined in line 70; used 1 times
  • in line 19
cad8 declared in line 14; defined in line 74; used 1 times
  • in line 14
cdv16 declared in line 22; defined in line 117; used 1 times
  • in line 22
cdv8 declared in line 17; defined in line 121; used 1 times
  • in line 17
ceq16 declared in line 29; defined in line 244; used 1 times
  • in line 29
ceq8 declared in line 27; defined in line 247; used 1 times
  • in line 27
cmp16 declared in line 21; defined in line 96; used 1 times
  • in line 21
cmp8 declared in line 16; defined in line 100; used 1 times
  • in line 16
cne16 declared in line 30; defined in line 253; used 1 times
  • in line 30
cne8 declared in line 28; defined in line 257; used 1 times
  • in line 28
cng16 declared in line 23; defined in line 168; used 1 times
  • in line 23
cng8 declared in line 18; defined in line 172; used 1 times
  • in line 18
cpi16 declared in line 33; defined in line 280; used 1 times
  • in line 33
cpi8 declared in line 32; defined in line 276; used 1 times
  • in line 32
csb16 declared in line 20; defined in line 82; used 1 times
  • in line 20
csb8 declared in line 15; defined in line 86; used 1 times
  • in line 15
d defined in line 39; used 7 times
divide defined in line 124; used 1 times
e defined in line 41; used 24 times
f defined in line 42; used 29 times
garg defined in line 187; used 5 times
gas16 declared in line 26; defined in line 44; used 1 times
  • in line 26
i4c16 declared in line 11; defined in line 201; used 1 times
  • in line 11
i4c8 declared in line 8; defined in line 197; used 1 times
  • in line 8
one defined in line 35; used 2 times
r4c16 declared in line 12; defined in line 218; used 1 times
  • in line 12
r4c8 declared in line 9; defined in line 208; used 1 times
  • in line 9
r8c16 declared in line 13; defined in line 212; used 1 times
  • in line 13
r8c8 declared in line 10; defined in line 222; used 1 times
  • in line 10
rval16 declared in line 24; defined in line 60; used 1 times
  • in line 24
rval16p declared in line 25; defined in line 54; used 1 times
  • in line 25
sarg defined in line 112; used 4 times
Last modified: 1975-07-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 382
Valid CSS Valid XHTML 1.0 Strict