home *** CD-ROM | disk | FTP | other *** search
- ;
- ; GETDAT.ASM
- ;
- ; Author: M. Steven Baker
- ; Date: August 27, 1988
- ;
- ; a GETDAT subroutine for LAHEY F77/32 bit
- ; must assemble with MASM 5.x or higher
- ; based on SAMPLE.ASM code from LAHEY supplemental disk
- ; FORTRAN calling convention with INTEGER*4 arguments
- ; CALL GETDAT(iyear,imonth,iday)
-
- .386 ; required to generate 32-bit code/data
-
- ; It is very important when linking to F77L-EM/32 program units that any data
- ; segments your assembly code uses have their class name as 'DATA' in order
- ; to link correctly. In addition, you must also use the GROUP directive
- ; to include the data in group DGROUP. DS and ES are set to DGROUP by the
- ; FORTRAN code, and must be set that way on return. Your code segment must
- ; also be included in the group CGROUP, and include the directive:
- ; ASSUME DS:DGROUP, CS:CGROUP
-
- data segment dword public 'DATA'
- dgroup group data
-
- data ends
- ;
- ; Any code segments should have a class name of 'CODE'.
- ;
- excode segment dword public 'CODE'
- cgroup group excode
- assume cs:cgroup, ds:dgroup
- ;
- ; The procedure names must be declared public to be addressable by
- ; other modules.
- ;
- public GETDAT
-
- GETDAT proc near
- ;
- ; Upon entry to any subroutine, F77L-EM/32 has pushed addresses of
- ; each argument onto the stack. In the calling program,
- ; 'gettim' was defined as a simple subroutine;
- ; When all arguments have been dealt with,
- ; F77L-EM/32 issues a near call to the named routine.
- ;
- ; log4 = example( int2, int4, int2a, int2a(3), dp, cmpx )
- ; arg1 arg2 arg3 arg4 arg5 arg6
- ;
- ; push ebp ; always do this... if EBP/ESP are used
- ; mov ebp, esp ; and this (ebp must be preserved)
- ;
- ; The arguments are pushed right to left; thus, the first argument
- ; is closest to ebp. At this point, the stack contains:
- ;
- ; offset of argn
- ; ...
- ; offset of arg1 = IHR
- ; return code offset (EIP) }-- four byte address from near call
- ; saved ebp <-- ebp, esp
- ;
- ; The first argument address is now 8 bytes from ebp, referenced at [ebp+8].
- ; Note that the minimum argument displacement is 8 for subroutines and 12
- ; for functions.
- ;
- ;
- ; CALL GETDAT(iyear,imonth,iday)
- mov ah,2ah ;DOS Get Date function
- int 21h ;returns CX=year
- ; DH =month DL=day
- mov eax,ss:[esp+4]
- mov dword ptr [eax],0 ;zero value
- mov [eax],cx ;set year
- ;
- mov eax,ss:[esp+8]
- mov dword ptr [eax],0 ;zero value
- mov [eax],dh ;set month
- ;
- mov eax,ss:[esp+0ch]
- mov dword ptr [eax],0 ;zero value
- mov [eax],dh ;set day
- ;
- ret
- GETDAT endp
-
-
- excode ends
-
- end
- ;
- ; Do not put any label name or expression after the end statement! This
- ; defines a program entry point, which has already been defined by the
- ; Fortran MAIN module.
-