home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / apple2 / 69 < prev    next >
Encoding:
Internet Message Format  |  1991-06-01  |  4.1 KB

  1. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  2. Newsgroups: comp.sources.apple2
  3. Subject: v001SRC049:  time -- Print Current Time
  4. Message-ID: <May.31.11.34.39.1991.7166@yoko.rutgers.edu>
  5. Date: 31 May 91 15:34:39 GMT
  6. Approved: jac@paul.rutgers.edu
  7.  
  8.  
  9. Submitted-by: Andy Werner (st6934@siucvmb.bitnet)
  10. Posting-number: Volume 1, Source:49
  11. Archive-name: util/hyperc/time/time
  12. Architecture: ANY_2
  13. Version-number: 1.00
  14.  
  15. Print out the time under HyperC.  No-frills, shows how to use
  16. ProDOS MLI calls under HyperC.
  17.  
  18. Enjoy.
  19.  
  20. =Read.Me
  21. -
  22. -time
  23. -Version 1.00
  24. -
  25. -Time Utility for HyperC
  26. -This is freeware.  It's also a learning tool to see how HyperC works.
  27. -The included files are :
  28. -
  29. -cclib       :   Script file to compile unlinked C files
  30. -time.c      :   C source for time utility
  31. -getime.a    :   Assembly source for ProDOS MLI time call
  32. -date.a      :   Assembly source to unpack date after calling ProDOS MLI time
  33. -mk          :   pseudo-make script to link compiled but unlinked files
  34. -
  35. -Use cclib to compile time.c and use asm65 to compile the assembler files.
  36. -
  37. -For example, to compile getime.a, type :
  38. -
  39. -asm65 -o time.o time.a
  40. -
  41. -Use mk to link all the files ending with .o.  Type mk.
  42. -
  43. -Examine the script files to see if they point to the correct subdirectories.
  44. -Adjust them to suit your setup.  You can compile time.c down to native code
  45. -(or emulated for you IIgs people...) by editing ccn and deleting the lnk
  46. -phase at the end of that script and renaming the edited file ccnlib for ex-
  47. -ample.  I have not tried this at this time but I assume it will work.
  48. -
  49. -The time file as it stands can be placed in your bin subdirectory.  When you
  50. -type time at the keyboard, the program will respond by displaying the time
  51. -and date.  This program assumes you have a clock-calendar attached to your
  52. -system.  This program attempts to mimic the time() function of UNIX and ANSI C.
  53. -As I'm not on a UNIX site I'd like to get feedback from those of you who are.
  54. -I'm also interested in writing an asctime() function and mimicing clk_tck.
  55. -
  56. -You can send your comments to me at:
  57. -
  58. -    Andy Werner
  59. -    st6934@siucvmb.bitnet
  60. -    March 18, 1991.
  61. -
  62. -ProDOS is a trademark of Apple Computer, Inc.
  63. -UNIX is a trademark(?) of A.T.T.
  64. -HyperC is a trademark of the WSM Group, Inc.
  65. -
  66. =Manifest
  67. -
  68. -Read.Me
  69. -cclib
  70. -date.a
  71. -getime.a
  72. -mk
  73. -time.c
  74. -
  75. =cclib
  76. -;
  77. -; batch file for compiling C programs...
  78. -; NOTE: Do NOT specify the ".c" ending the source filename!
  79. -;
  80. -/csys/bin/ppf -i |/csys/hdrs/ -o $1.p $1.c
  81. -/csys/bin/hyperc -o $1.s $1.p
  82. -rm $1.p
  83. -/csys/bin/asmcp -o $1.o $1.s
  84. -
  85. -
  86. -
  87. =date.a
  88. -;
  89. -;   unpack date
  90. -;   by Andy Werner
  91. -;   march 12,1991
  92. -;
  93. -
  94. -.entry  _unpack_date
  95. -    _unpack_date:
  96. -    lda 0xbf90
  97. -    and #0x1f   ;   mask : 0001 1111
  98. -    sta _day
  99. -    lda 0xbf91
  100. -    lsr a
  101. -    sta _year
  102. -    lda 0xbf90
  103. -    and #0xe0   ;   mask : 1110 0000
  104. -    lsr a
  105. -    lsr a
  106. -    lsr a
  107. -    lsr a
  108. -    lsr a
  109. -    sta _month
  110. -    lda 0xbf91
  111. -    and #0xfe   ;   mask : 1111 1110
  112. -    asl a
  113. -    asl a
  114. -    asl a
  115. -    clc
  116. -    adc #_month
  117. -    sta _month
  118. -    rts
  119. -
  120. -    .data
  121. -    .entry _year
  122. -_year:
  123. -    .byte  00
  124. -
  125. -    .entry _month
  126. -_month:
  127. -   .byte  00
  128. -
  129. -    .entry _day
  130. -_day:
  131. -    .byte  00
  132. =getime.a
  133. -
  134. -;   time.a
  135. -;   prodos mli call to set the time
  136. -;
  137. -prodos  =   0xbf00
  138. -time    =   0x82
  139. -
  140. -.entry  _get_time
  141. -
  142. -_get_time:
  143. -
  144. -    jsr prodos
  145. -    .byte   time
  146. -    .word   0000
  147. -    rts
  148. -
  149. -
  150. -
  151. -
  152. =mk
  153. -;
  154. -;   Script file to make time utility.
  155. -;   examine the script to make sure that your utilities and libraries
  156. -;   can be found by this script.  Adjust accordingly.
  157. -;
  158. -/csys/bin/lnk -l |/csys/libs/ -a -o time &s.o time.o getime.o date.o &libc
  159. -
  160. =time.c
  161. -
  162. -/*  time.cc 
  163. - *  call prodos time
  164. - *  use anchored variables to print time
  165. - *  this is a test
  166. - */
  167. -
  168. -#include <std.h>
  169. -
  170. -EXTERN   VOID    get_time();
  171. -EXTERN   VOID    pack_date();
  172. -
  173. -EXTERN    CHAR    year;
  174. -EXTERN    CHAR    month;
  175. -EXTERN    CHAR    day;
  176. -
  177. -CHAR    hour      @0xbf93;
  178. -CHAR    minute    @0xbf92;
  179. -
  180. -VOID     main()
  181. -
  182. -{
  183. -
  184. -    get_time();
  185. -    printf("The time is %02d:%02d\n",hour,minute);
  186. -    unpack_date();
  187. -    printf("The date is %02d/%02d/%02d\n",month, day, year);
  188. -    exit();
  189. -
  190. -}
  191. + END OF ARCHIVE
  192.