home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l320 / 2.img / EXAMPLES / CALLM2.F < prev    next >
Encoding:
Text File  |  1989-10-31  |  3.1 KB  |  105 lines

  1.       PROGRAM CALLM2
  2. C Purpose: calls real mode program via address
  3. C Copyright (C) MicroWay, Inc. 1989
  4. C Usage: run386 -minreal ???? callm2.exp
  5. C where ???? is the minimum number of paragraphs
  6. C of conventional memory to be reserved for the
  7. C real mode program. See appropriate section of
  8. C Phar Lap manual.
  9.  
  10.       INTEGER BUFFSIZE, PARASIZE
  11.       PARAMETER (BUFFSIZE=1, PARASIZE=16)
  12.  
  13.       INTEGER MSIZE,NSIZE
  14.       PARAMETER (MSIZE=((BUFFSIZE*PARASIZE)/2), NSIZE=4)
  15.  
  16.       INTEGER INTNUM, BUFFSEG
  17.       INTEGER PHYSADD
  18.       INTEGER*2 M(MSIZE)
  19.       INTEGER*2 N(NSIZE)
  20.       CHARACTER*80 COMMANDLINE
  21.       INCLUDE 'DOS.FH'
  22.  
  23. C INT 21 hexadecimal (33 decimal), service 25C0 hexadecimal
  24. C (9664 decimal) is used to allocate BUFFSIZE paragraphs of
  25. C MS-DOS memory. The segment address of the allocated buffer
  26. C is stored in BUFFSEG.
  27. C       winregs(3) = bx
  28. C       winregs(1) = ax
  29.       INTNUM = Z'21'
  30.       WINREGS(3) = BUFFSIZE
  31.       WINREGS(1) = Z'25C0'
  32.       CALL INT386(INTNUM,INREGS(1),OUTREGS(1))
  33. C Paragraph address of real mode buffer returned in AX
  34.       BUFFSEG = WOUTREGS(1)
  35.  
  36.       WRITE(COMMANDLINE, 20) BUFFSEG
  37.    20 FORMAT("RB.EXE ", I5)
  38.       WRITE (*,*) COMMANDLINE
  39. C system invokes the real mode program named in COMMANDLINE
  40.       CALL SYSTEM (COMMANDLINE)
  41. C Convert paragraph address in BUFFSEG to 32-bit address
  42.       PHYSADD = BUFFSEG * 16
  43.  
  44. C In this example, BLK_MB() moves 16 bytes of information
  45. C from offset PHYSADD in conventional memory to the array
  46. C M() in the NDP program's data segment. Conventional memory
  47. C is accessed by Phar Lap's segment selector 34 hexadecimal
  48. C (52 decimal). Segment 34h maps to the first megabyte
  49. C of memory (real memory), and the address is
  50. C calculated by multiplying the real mode segment
  51. C by 16 (done above) and adding the offset into
  52. C the segment (in this case, 0).
  53.  
  54.       CALL BLK_MB(M(1), Z'34', PHYSADD, (BUFFSIZE*PARASIZE))
  55.  
  56. C The BASIC program has loaded M(4) with the
  57. C segment and M(3) with the offset of a data
  58. C transfer area.
  59.  
  60.       PHYSADD = M(4) * 16 + M(3)
  61.       N(1) = 2
  62.       N(2) = 3
  63.       N(3) = 5
  64.       N(4) = 7
  65.  
  66. C The call to BLK_BM() is syntactically similar
  67. C to the one to BLK_MB(). In this case, it loads
  68. C the BASIC array with the values found in N(1)
  69. C through N(4).
  70.  
  71.       CALL BLK_BM(N(1), Z'34', PHYSADD, (2*NSIZE))
  72. C winregs(3) = bx
  73. C winregs(4) = high byte of ebx
  74. C inregs(3) = ecx
  75. C winregs(1) = ax
  76.  
  77.       INTNUM = Z'21'
  78.       WINREGS(3) = M(1)
  79.       WINREGS(4) = M(2)
  80.       INREGS(3) = 0
  81.       WINREGS(1) = Z'250E'
  82.  
  83. C This call to INT386 places a call to the entry
  84. C point BASIC left in the M() array at segment
  85. C M(2), offset M(1)
  86.  
  87.       CALL INT386(INTNUM,INREGS(1),OUTREGS(1))
  88.  
  89. C The array, as altered by BASIC, brought back
  90. C to protected mode by a last call to BLK_MB().
  91.  
  92.       CALL BLK_MB(N(1), Z'34', PHYSADD, (2*NSIZE))
  93.       WRITE(*,*) N(1), N(2), N(3), N(4)
  94.  
  95. C Free MS-DOS memory allocated above
  96. C       winregs(5) = cx
  97. C       winregs(1) = ax
  98.       INTNUM = Z'21'
  99.       WINREGS(5) = BUFFSEG
  100.       WINREGS(1) = Z'25C1'
  101.       CALL INT386(INTNUM,INREGS(1),OUTREGS(1))
  102.  
  103.       END
  104.  
  105.