home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / ASM / LCFUNCS.ZIP / LATTICE.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-03-18  |  2.4 KB  |  71 lines

  1.        page      60,132
  2.  
  3.        .8087
  4.  
  5.        include   lattice.mac
  6.        PSEG
  7.  
  8. _MAIN  proc      near              ; you MUST have a procedure _MAIN !!!
  9.  
  10.        _fopen    fname,imode,fp1   ; Open input file    (console)
  11.        _fopen    fname,omode,fp2   ; Open output file   (console)
  12.        _printf   fp2,mess1         ; Print opening message
  13.        _scanf    fp1,Dfmt,num1     ; Read double precision number
  14.        _printf   fp2,mess1a        ; Ask for second number
  15.        _scanf    fp1,Dfmt,num2     ; And input it
  16.  
  17.        FINIT                       ; Initialize NDP
  18.        FLD       qword ptr ds:num1 ; push number onto stack
  19.        FADD      qword ptr ds:num2 ; Add it to second number
  20.        FSTP      qword ptr ds:num3 ; Put back into memory
  21.  
  22.        _printd   fp2,sum,num1      ; print first number,
  23.        _printd   fp2,Dfmt,num2     ; then second number,
  24.        _printd   fp2,mess2,num3    ; and the sum.
  25.  
  26.        _mul      num1,num2,num3    ; Library func to Multiply
  27.        _printd   fp2,prod,num3
  28.        _div      num1,num2,num3    ; Library func to divide
  29.        _printd   fp2,quot,num3
  30.        _sqrt     num1,num3
  31.        _printd   fp2,root,num3
  32.        _atan     one,num3          ; Arctangent of 1
  33.        _mul      num3,four,num2    ; times 4 is PI
  34.        _printd   fp2,pi,num2       ; print PI
  35.  
  36.        ret
  37.  
  38. _MAIN  endp
  39.  
  40.        ENDPS
  41.  
  42.        DSEG
  43. fp1    dw        ?                  ; file for input
  44. fp2    dw        ?                  ; file for output
  45.  
  46. one    dq        1.0e0              ; Integer constant
  47. four   dq        4.0e0
  48.  
  49. fname  db        'CON:',0           ; name of file
  50.  
  51. imode  db        'r',0              ; mode for read-only
  52. omode  db        'w',0              ; mode for write-only
  53.  
  54. Sfmt   db        '%s',0             ; format for string output
  55. Dfmt   db        '%lf',0            ; format for numeric output
  56.  
  57. mess1  db        'Enter Decimal number ',0
  58. mess1a db        0Ah,'Enter Second number ',0
  59. sum    db        0Ah,'%lf + ',0
  60. mess2  db        ' = %lf',0
  61. prod   db        0Ah,'Library multiply     %lf',0
  62. quot   db        0Ah,'Library divide       %lf',0
  63. root   db        0Ah,'Library square root  %lf',0
  64. pi     db        0Ah,'Calculated PI is     %lf',0
  65.  
  66. num1   db        8 dup (?)
  67. num2   db        8 dup (?)
  68. num3   db        8 dup (?)
  69.        ENDDS                       ; End of data segment
  70.        end
  71.