home *** CD-ROM | disk | FTP | other *** search
- PROGRAM BDATE
-
- c Purpose: demonstrates calling NDP C from NDP Fortran
- c The Fortran calling program passes an empty string,
- c a number that indexes into an array of day names,
- c a month number that indexes into an array of
- c month names, a number representing the day of the
- c month, and a number representing the year. It gets
- c these values by using the INT386 routine to invoke
- c DOS Service 42 (2A hexadecimal), Get System Date.
-
- c The NDP C routine has a static array of month names,
- c which are of varying length, and a static array of
- c day names, also of varying length. If these arrays
- c were defined in the Fortran program, the members
- c would need to be of fixed length and thus would
- c occupy more storage. The savings here are small, but
- c in other circumstances could be significant. The NDP C
- c function uses the sprintf function to build a string of
- c the form "dayname monthname dd, yyyy".
-
- c Note that the Fortran program passes by reference,
- c i.e., it pushes the address of each item onto the
- c stack. In addition, when passing a string, it passes
- c the length of the string first, i.e., highest on the
- c stack. If there is more than one string passed, the
- c length of the last string is pushed first, the length
- c of the next to the last second, and so on. No matter
- c where the strings are in the actual argument list,
- c their lengths always pushed first.
-
- c The following section is the data declaration for the buffer
- c used by the INT386 routine. It is a copy of the file DOS.FH,
- c which comes on your release diskette, and would normally
- c be included by the INCLUDE directive.
- c **************** Beginning of DOS.FH ********************
- c
- c Defines the data structures used for passing register contents
- c back and forth to the DOS interface routines by a Fortran program.
- c
- c Copyright (C) MicroWay, Inc., 1988
-
-
- integer*4 intno
-
- c Interrupt number: 33 for int 21h, etc.
-
-
- integer*4 inregs(7),outregs(7)
- integer*2 winregs(14),woutregs(14)
- integer*1 binregs(28),boutregs(28)
-
- c inregs(1) = eax
- c inregs(2) = ebx
- c inregs(3) = ecx
- c inregs(4) = edx
- c inregs(5) = esi
- c inregs(6) = edi
- c inregs(7) = eflags
- c
- c And similarly for outregs.
-
-
- c winregs(1) = ax
- c winregs(3) = bx
- c winregs(5) = cx
- c winregs(7) = dx
- c winregs(9) = si
- c winregs(11) = di
- c winregs(13) = flags
- c
- c winregs(2) = winregs(4) = winregs(6) = winregs(8) = winregs(10) =
- c winregs(12) = winregs(14) = unused
- c
- c And similarly for woutregs.
-
-
- c binregs(1) = al
- c binregs(2) = ah
- c binregs(5) = bl
- c binregs(6) = bh
- c binregs(9) = cl
- c binregs(10) = ch
- c binregs(13) = dl
- c binregs(14) = dh
- c binregs(25) = lo_flags
- c binregs(26) = hi_flags
- c
- c All other elements of binregs are unused.
- c
- c And similarly for boutregs.
-
-
- c Overlay byte, word and doubleword register data structures.
-
- equivalence (inregs(1), winregs(1), binregs(1))
- equivalence (outregs(1), woutregs(1), boutregs(1))
- c ******************** End of DOS.FH ********************
-
- INTEGER DAY, MONTH, DATE, YEAR
- CHARACTER*26 DATESTRING
-
- c Call DOS Service 42 (2A hexadecimal), Get System Date
- c Interrupt 33 (21 hexadecimal), Register AH = 42 (2A hexadecimal)
- BINREGS(2) = 42
- CALL INT386(33,INREGS(1),OUTREGS(1))
-
- c Register AL has day of week (0=Sunday, 1=Monday, etc)
- c Register DH has number of month (1-12)
- c Register DL has number of day (1-31)
- c Register CX has year (1980-2099)
- DAY = BOUTREGS(1)
- MONTH = BOUTREGS(14)
- DATE = BOUTREGS(13)
- YEAR = WOUTREGS(5)
-
- CALL BILDDATE (DATESTRING, DAY, MONTH, DATE, YEAR)
-
- WRITE (*,100) DATESTRING
- 100 FORMAT (1X,A)
-
- END
-