home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l320 / 2.img / EXAMPLES / BDATE.F next >
Encoding:
Text File  |  1989-07-13  |  3.6 KB  |  123 lines

  1.       PROGRAM BDATE
  2.  
  3. c Purpose: demonstrates calling NDP C from NDP Fortran
  4. c The Fortran calling program passes an empty string,
  5. c a number that indexes into an array of day names,
  6. c a month number that indexes into an array of
  7. c month names, a number representing the day of the
  8. c month, and a number representing the year. It gets
  9. c these values by using the INT386 routine to invoke
  10. c DOS Service 42 (2A hexadecimal), Get System Date.
  11.  
  12. c The NDP C routine has a static array of month names,
  13. c which are of varying length, and a static array of
  14. c day names, also of varying length. If these arrays
  15. c were defined in the Fortran program, the members
  16. c would need to be of fixed length and thus would
  17. c occupy more storage. The savings here are small, but
  18. c in other circumstances could be significant. The NDP C
  19. c function uses the sprintf function to build a string of
  20. c the form "dayname monthname dd, yyyy". 
  21.  
  22. c Note that the Fortran program passes by reference,
  23. c i.e., it pushes the address of each item onto the
  24. c stack. In addition, when passing a string, it passes
  25. c the length of the string first, i.e., highest on the
  26. c stack. If there is more than one string passed, the
  27. c length of the last string is pushed first, the length
  28. c of the next to the last second, and so on. No matter
  29. c where the strings are in the actual argument list,
  30. c their lengths always pushed first.
  31.  
  32. c The following section is the data declaration for the buffer
  33. c used by the INT386 routine. It is a copy of the file DOS.FH,
  34. c which comes on your release diskette, and would normally
  35. c be included by the INCLUDE directive.
  36. c **************** Beginning of DOS.FH ********************
  37. c
  38. c Defines the data structures used for passing register contents
  39. c back and forth to the DOS interface routines by a Fortran program.
  40. c
  41. c Copyright (C) MicroWay, Inc., 1988
  42.  
  43.  
  44.     integer*4 intno
  45.  
  46. c Interrupt number: 33 for int 21h, etc.
  47.  
  48.  
  49.      integer*4 inregs(7),outregs(7)
  50.     integer*2 winregs(14),woutregs(14)
  51.     integer*1 binregs(28),boutregs(28)
  52.  
  53. c    inregs(1) = eax
  54. c    inregs(2) = ebx
  55. c    inregs(3) = ecx
  56. c    inregs(4) = edx
  57. c    inregs(5) = esi
  58. c    inregs(6) = edi
  59. c    inregs(7) = eflags
  60. c
  61. c And similarly for outregs.
  62.  
  63.  
  64. c    winregs(1) = ax
  65. c    winregs(3) = bx
  66. c    winregs(5) = cx
  67. c    winregs(7) = dx
  68. c    winregs(9) = si
  69. c    winregs(11) = di
  70. c    winregs(13) = flags
  71. c
  72. c    winregs(2) = winregs(4) = winregs(6) = winregs(8) = winregs(10) =
  73. c        winregs(12) = winregs(14) = unused
  74. c
  75. c And similarly for woutregs.
  76.  
  77.  
  78. c    binregs(1) = al
  79. c    binregs(2) = ah
  80. c    binregs(5) = bl
  81. c    binregs(6) = bh
  82. c    binregs(9) = cl
  83. c    binregs(10) = ch
  84. c    binregs(13) = dl
  85. c    binregs(14) = dh
  86. c    binregs(25) = lo_flags
  87. c    binregs(26) = hi_flags
  88. c
  89. c All other elements of binregs are unused.
  90. c
  91. c And similarly for boutregs.
  92.  
  93.  
  94. c Overlay byte, word and doubleword register data structures.
  95.  
  96.     equivalence (inregs(1), winregs(1), binregs(1))
  97.     equivalence (outregs(1), woutregs(1), boutregs(1))
  98. c  ******************** End of DOS.FH  ********************
  99.  
  100.       INTEGER     DAY, MONTH, DATE, YEAR
  101.       CHARACTER*26 DATESTRING
  102.  
  103. c Call DOS Service 42 (2A hexadecimal), Get System Date
  104. c Interrupt 33 (21 hexadecimal), Register AH = 42 (2A hexadecimal)
  105.       BINREGS(2) = 42
  106.       CALL INT386(33,INREGS(1),OUTREGS(1))
  107.  
  108. c Register AL has day of week (0=Sunday, 1=Monday, etc)
  109. c Register DH has number of month (1-12)
  110. c Register DL has number of day (1-31)
  111. c Register CX has year (1980-2099)
  112.       DAY = BOUTREGS(1)
  113.       MONTH = BOUTREGS(14)
  114.       DATE = BOUTREGS(13)
  115.       YEAR = WOUTREGS(5)
  116.  
  117.       CALL BILDDATE (DATESTRING, DAY, MONTH, DATE, YEAR)
  118.  
  119.       WRITE (*,100) DATESTRING
  120.   100 FORMAT (1X,A)
  121.  
  122.       END
  123.