home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / winsrc.zip / FRACSUBA.ASM < prev    next >
Assembly Source File  |  1990-10-31  |  3KB  |  130 lines

  1. ;    FRACASM.ASM - Assembler subroutines for fractals.c
  2.  
  3. ;             required for compatibility if Turbo ASM
  4. IFDEF ??version
  5. MASM51
  6. QUIRKS
  7. ENDIF
  8.  
  9. .MODEL    medium,c
  10.  
  11. .8086
  12.  
  13.     ; these must NOT be in any segment!!
  14.     ; this get's rid of TURBO-C fixup errors
  15.     extrn    multiply:far        ; this routine is in 'general.asm'
  16.  
  17. .data
  18.  
  19.     extrn    lold:qword, lnew:qword    ; each defined as LCMPLX in fractals.c
  20.     extrn    ltempsqrx:dword     ; for fractals.c
  21.     extrn    ltempsqry:dword     ; for fractals.c
  22.     extrn    lmagnitud:dword     ; for fractals.c
  23.     extrn    llimit:dword        ; from calcfrac.c
  24.     extrn    llimit2:dword        ; from calcfrac.c
  25.     extrn    bitshift:word        ; fudgefactor for integer math
  26.     extrn    overflow:word        ; error from integer math
  27.  
  28. .code
  29.  
  30.  
  31.     public    longbailout
  32.  
  33. longbailout    proc
  34. ;
  35. ; equivalent to the C code:
  36. ;  ltempsqrx = lsqr(lnew.x); ltempsqry = lsqr(lnew.y);
  37. ;  lmagnitud = ltempsqrx + ltempsqry;
  38. ;  if (lmagnitud >= llimit || lmagnitud < 0 || labs(lnew.x) > llimit2
  39. ;     || labs(lnew.y) > llimit2 || overflow)
  40. ;           { overflow=0; return(1); }
  41. ;  lold = lnew;
  42. ;  return(0);
  43. ;
  44. ;  ltempsqrx = lsqr(lnew.x);
  45.     push    bitshift
  46.     push    WORD PTR lnew+2
  47.     push    WORD PTR lnew
  48.     push    WORD PTR lnew+2
  49.     push    WORD PTR lnew
  50.     call    FAR PTR multiply
  51.     mov    WORD PTR ltempsqrx,ax
  52.     mov    WORD PTR ltempsqrx+2,dx
  53. ;  ltempsqry = lsqr(lnew.y);
  54.     push    bitshift
  55.     push    WORD PTR lnew+6
  56.     push    WORD PTR lnew+4
  57.     push    WORD PTR lnew+6
  58.     push    WORD PTR lnew+4
  59.     call    FAR PTR multiply
  60.     add    sp,20
  61.     mov    WORD PTR ltempsqry,ax
  62.     mov    WORD PTR ltempsqry+2,dx
  63. ;  lmagnitud = ltempsqrx + ltempsqry;
  64.     add    ax,WORD PTR ltempsqrx
  65.     adc    dx,WORD PTR ltempsqrx+2
  66.     mov    WORD PTR lmagnitud,ax
  67.     mov    WORD PTR lmagnitud+2,dx
  68. ;  if (lmagnitud >= llimit
  69.     cmp    dx,WORD PTR llimit+2
  70.     jl    chkvs0
  71.     jg    bailout
  72.     cmp    ax,WORD PTR llimit
  73.     jae    bailout
  74. ;   || lmagnitud < 0
  75. chkvs0: or    dx,dx
  76.     js    bailout
  77. ;   || labs(lnew.x) > llimit2
  78.     mov    ax,WORD PTR lnew
  79.     mov    dx,WORD PTR lnew+2
  80.     or    dx,dx
  81.     jge    lnewx
  82.     neg    ax
  83.     adc    dx,0
  84.     neg    dx
  85. lnewx:    cmp    dx,WORD PTR llimit2+2
  86.     jl    chklnewy
  87.     jg    bailout
  88.     cmp    ax,WORD PTR llimit2
  89.     ja    bailout
  90. ;   || labs(lnew.y) > llimit2
  91. chklnewy:
  92.     mov    ax,WORD PTR lnew+4
  93.     mov    dx,WORD PTR lnew+6
  94.     or    dx,dx
  95.     jge    lnewy
  96.     neg    ax
  97.     adc    dx,0
  98.     neg    dx
  99. lnewy:    cmp    dx,WORD PTR llimit2+2
  100.     jl    chkoflow
  101.     jg    bailout
  102.     cmp    ax,WORD PTR llimit2
  103.     ja    bailout
  104. ;   || overflow)
  105. chkoflow:
  106.     cmp    overflow,0
  107.     jne    bailout
  108. ;  else {
  109. ;  lold = lnew;
  110.     mov    ax,WORD PTR lnew
  111.     mov    dx,WORD PTR lnew+2
  112.     mov    WORD PTR lold,ax
  113.     mov    WORD PTR lold+2,dx
  114.     mov    ax,WORD PTR lnew+4
  115.     mov    dx,WORD PTR lnew+6
  116.     mov    WORD PTR lold+4,ax
  117.     mov    WORD PTR lold+6,dx
  118. ;  return(0); }
  119.     sub    ax,ax
  120.     ret
  121. bailout:
  122. ;  { overflow=0; return(1); }
  123.     mov    overflow,0
  124.     mov    ax,1
  125.     ret
  126. longbailout    endp
  127.  
  128.         end
  129.  
  130.