home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / S8-TCAL3.DMS / in.adf / Programmer / Examples.lha / demo_function.tclib.s next >
Encoding:
Text File  |  1994-10-30  |  2.4 KB  |  112 lines

  1. ;*************************************************************
  2. ;*****TurboCalc-LIB: external funtions - example**************
  3. ;*************************************************************
  4.  
  5.     include "tclib.i"
  6.  
  7. startall:
  8.     moveq   #-13,d0     ; if user tries to start this lib!
  9.     rts                 ;   (need -13 to identify TClibs!)
  10.     dc.l 'TCLB'         ; TurboCalc-Lib - this field is used to identify
  11.                         ;   TClibs and to link them in memory (i.e. that
  12.                         ;   this entry is used and thus changed by TC
  13.                         ;   to keep a list of all already loaded libs!)
  14.     dc.l 'FNCT'
  15.     dc.w 1,0            ; Version, Revision
  16.     dc.l txt_name
  17.     dc.l txt_ver
  18.     dc.l txt_author
  19.     dc.l 0              ; flags - reserved
  20.     dc.l 0              ; reserved
  21.     dc.l 0              ; reserved
  22. * default-routines
  23.     dc.l 0  ; init
  24.     dc.l 0  ; exit
  25.     dc.l 0  ; flush
  26.     dc.l 0
  27. *
  28.     dc.l 0  ; flags
  29.     dc.l 5
  30.     dc.l demo_fncdefault
  31.     dc.l demo_function1
  32.     dc.l demo_function2
  33.     dc.l demo_function3
  34.     dc.l demo_function4
  35.     dc.l demo_function5
  36.  
  37.  
  38. txt_name: dc.b 'Function/Macro-TCLib Example',0
  39. txt_ver: dc.b '$VER: SimpleFunctions V1.0 (01.11.94)',0
  40. txt_author: dc.b '© 1994 Michael Friedrich',0
  41.  cnop 0,2
  42.  
  43.  
  44. *** unknown function - simply return function-number as int!
  45. demo_fncdefault:
  46.     move.l  d7,d0
  47.     moveq   #TYPE_NUM,d2
  48.     rts
  49.  
  50. *** val1+val (as long)
  51. demo_function1:
  52.     move.l  d2,d0
  53.     add.l   d5,d0
  54.     moveq   #TYPE_NUM,d2
  55.     rts
  56. *** val1*val2 (as long)
  57. demo_function2:
  58.     move.l  d2,d0
  59.     mulu    d5,d0
  60.     moveq   #TYPE_NUM,d2
  61.     rts
  62. *** val1*val (as float)
  63. demo_function3:
  64.     moveq   #CDX_Mul,d7
  65.     XSR     Call_CDX
  66.     moveq   #TYPE_FLOAT,d2
  67.     rts
  68. *** uppercase(text) - starting at val1, max. val2 chars (0=all)!
  69. demo_function4:
  70.     move.l  a0,d0
  71.     beq.s   90$
  72.     XSR     DuplicateTEXT
  73.     move.l  a0,d0
  74.     beq.s   90$
  75. * skip first part
  76.     subq.w  #2,d2
  77.     bmi.s   22$
  78. 20$ tst.b   (a0)+
  79.     beq.s   90$
  80. 21$ dbra    d2,20$
  81. 22$
  82. *
  83.     subq.w  #1,d5
  84.     move.l  d0,d2
  85. 30$ move.b  (a0),d0
  86.     beq.s   39$
  87.     XSR     UpperCaseD0
  88.     move.b  d0,(a0)+
  89.     dbra    d5,30$
  90. 39$ move.l  d2,d0
  91. *
  92. 90$ moveq   #TYPE_TEXT,d2
  93.     rts
  94.  
  95. ******************************
  96. demo_function5: ; it's a macro!
  97. * simple macro, showing a guru!!!
  98. 10$ move.l  d5,d0
  99.     bchg    #1,$bfe001
  100. 20$ subq.l  #1,d0
  101.     bpl.s   20$
  102.     subq.l  #1,d2
  103.     bpl.s   10$
  104.     moveq   #0,d0
  105.     moveq   #TYPE_NUM,d2
  106.     rts
  107.  
  108.  
  109.  
  110.  
  111.         END
  112.