home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MSOFT / M-SOFT.CAT < prev    next >
Text File  |  2000-06-30  |  4KB  |  75 lines

  1. --------------------------------
  2.        THE CALL STATEMENT
  3. --------------------------------
  4. There have been a number of requests for clarification of the 
  5. CALL statement in the various Microsoft langauges.  Hopefully, 
  6. the following explanations will clear up several 
  7. misunderstandings.
  8.   First, let's look at the "Microsoft CALL standard".  When any 
  9. Microsoft program issues a CALL statement, such as "CALL MYROUT", 
  10. control is passed to the address specified by MYROUT.  In all 
  11. cases except the Basic Interpreter, MYROUT must be the name of a 
  12. SUBROUTINE program, or a GLOBAL/PUBLIC label within a Macro-80 
  13. routine.  The calling and the called program must be linked 
  14. together by L80 into a single file.
  15.   In the Basic Interpreter (MBASIC), the variable MYROUT must be 
  16. set to the beginning address of the subroutine.  If we complicate 
  17. things by adding a few paramaters to the CALL, such as:  "CALL 
  18. MYROUT(A,B);  the parameters are passed as follows.  The 
  19. *ADDRESS* of the first parameter is passed in registers HL, the 
  20. second in DE, and the third in BC.  If there are more than three 
  21. parameters, BC points to a block of memory containing the 
  22. *ADDRESS* of parameters three through N.  Note that the address 
  23. and *NOT* the parameter itself is passed.
  24.   The arguments themselves correspond to the standard Microsoft 
  25. variable format, (2 bytes for an integer, 4 bytes for single 
  26. precision floating point, and 8 bytes for a double precision 
  27. floating point number) with two exceptions.
  28.   COBOL passes variables as they would appear to another COBOL 
  29. program (DISPLAY, COMP, or COMP-3).
  30.   Strings are also handled a bit differently.  The address 
  31. pointed to by the register contains a three byte "string 
  32. descriptor".  This string descriptor contains the length of the 
  33. string in byte one, and the address of the string in bytes two 
  34. and three.  When passing strings, take care not to modify this 
  35. string descriptor, or unpredictable results will occur.  
  36.   In all cases, it is the user's responsibility to ensure that 
  37. the arguments correspond *EXACTLY*, in both type and number.  
  38. Also, be sure to preserve *ALL* of the registers and use your own 
  39. local stack when you call Macro routines.
  40.   With the preliminaries out of the way, let's look at which 
  41. languages can call which other languages.  In the following 
  42. table, "B" represents the Basic Interpreter (MBASIC), "BC" the 
  43. Basic Compiler (BASCOM), "F" the Fortran Compiler (F80), "C" the 
  44. Cobol Compiler, and "M" the Macro Assembler (M80).  A "Y" in the 
  45. appropriate entry means that a CALL is possible.
  46.              CALLed Program
  47.  CALLing   B   BC   F   C   M  
  48.  Program  +---+---+---+---+---+
  49.       B   |   |   |   |   | Y |
  50.       BC  |   |   | 1 |   | Y |
  51.       F   |   |   | Y |   | Y |
  52.       C   |   |   | 2 | Y | Y |
  53.       M   |   |   | 3 |   | Y |
  54.           +---+---+---+---+---+
  55.       
  56.  
  57. Notes:
  58.  
  59. 1 - When calling a FORTRAN routine from the Basic Compiler, only 
  60. one of the two languages may be used to perform I/O.  When the 
  61. programs are linked, link the Basic program first, then search 
  62. BASLIB, then load the Fortran program, then search FORLIB.  The 
  63. multiply defined global message may be ignored.
  64.  
  65. 2 - When calling FORTRAN from COBOL, remember that the variable 
  66. types are different.  Only COMP data items will be passed in such 
  67. a way that FORTRAN can deal with them without an ENCODE statement.
  68.  
  69. 3 - While Macro-80 may not directly CALL Fortran subroutines, you 
  70. may make use of the routines in the FORTRAN Library.  For more 
  71. information, see the Fortran Manual.  Of course, from within M80, 
  72. you may initiate execution of any other .COM file by reading the 
  73. file and then jumping to the appropriate address.
  74.  
  75.