home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / allcharg / video.arc / BASIC.DOC next >
Encoding:
Text File  |  1986-09-25  |  15.1 KB  |  411 lines

  1.  
  2.                 TITLE: BASIC.DOC
  3.  
  4.                 AUTHOR: Peter Wong, ALL Computers Inc.
  5.  
  6.                 DATE:   16 SEPTEMBER, 1986
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                 TABLE OF CONTENTS
  14.                 =================
  15.  
  16.  
  17.                 1.)     Other related documents
  18.                 2.)     Introduction
  19.                 3.)     Variables, and Files  Used in MEMACC.BAS
  20.                 4.)     Subroutines
  21.                 5.)     How to Use it
  22.                 6.)     MEMACC.BAS
  23.                 7.)     Example  TEST.BAS
  24.  
  25.  
  26.  
  27.  
  28.  
  29. 1.)     OTHER RELATED DOCUMENTS
  30.         =======================
  31.  
  32.         1.      ALL/MOS TECHNICAL REFERENCE MANUAL
  33.                 ---- Intended for use by programmers who wish to write
  34.                      programs in assember using the Memory Management
  35.                      features of the ALL/MOS standard support software
  36.                      for the ALL Card AT1/M.
  37.  
  38.         2.      ALL/MOS SOFTWARE REFERENCE MANUAL
  39.                 ---- How to install and use the ALL/MOS software.
  40.  
  41.         3.      ALL CARD HARDWARE REFERENCE MANUAL
  42.                 ---- How to install the ALL Card AT1/M
  43.  
  44.         4.      ALL MMU PROGRAMMING GUIDE
  45.                 ---- How to write programs that directly use the AT1/M Memory
  46.                      Management Unit.
  47.  
  48.  
  49.  
  50.         These manuals may be obtained on request from
  51.  
  52.                         ALL Computers Inc.
  53.                         102 Bloor Street West, Suite 1200
  54.                         Toronto, Ontario
  55.                         Canada, M5S 1M9
  56.                         (416) 960-0111
  57.  
  58.  
  59.  
  60.  
  61.  
  62. 2.)     INTRODUCTION
  63.         ============
  64.  
  65. All/MOS is a set of extensions to PC-DOS and MS-DOS ( Versions 2.0 and
  66. higher) which allows applications to take advantage of the memory management
  67. facilities provided by the ALL Card AT1/M and other future products currently
  68. being developed by ALL Computers Inc.
  69.  
  70. The program MEMACC.BAS provides two routines which allow users to access
  71. ALL/MOS service routines (MEMMAN  routines)  in BASIC.
  72.  
  73. For detailed description of each MEMMAN routines, refer to the
  74. "ALL/MOS TECHNICAL REFERENCE MANUAL".
  75.  
  76.  
  77. 3.)     VARIABLES, AND FILES USED IN MEMACC.BAS
  78.         =======================================
  79.  
  80.         VARIABLES
  81.         ---------
  82.         1. SUBRT%       An integer which is used to store the location of
  83.                         "fcall.bin".
  84.  
  85.         Since the base of all arrays in MEMACC.BAS is 1 , the application
  86.         programs which are used with "MEMACC.BAS" have to declare all arrays
  87.         with the base of 1.
  88.  
  89.         2. FCALL%       An integer array ,45 words long, which is used
  90.                         to store an assembly routine "fcall.bin" which
  91.                         is loaded from the disk.     This routine performs
  92.                         FAR CALL with passing registers AX, BX, CX, DX, SI,
  93.                         and DI as inputs, as well as outputs.
  94.  
  95.         2. REG%         An integer array, six words long, which is used to
  96.                         store the content of the processor registers.
  97.                         It is passed to the routine "fcall.bin" as input and
  98.                         back to calling routine as output.
  99.  
  100.                                 REG%(1) = AX register
  101.                                 REG%(2) = BX register
  102.                                 REG%(3) = CX register
  103.                                 REG%(4) = DX register
  104.                                 REG%(5) = SI register
  105.                                 REG%(6) = DI register
  106.  
  107.         3. MEMMAN.ADDRESS%
  108.                         An integer array, two words long, which is used
  109.                         to store the location of the routine MEMMAN.
  110.                         This routine is the entry point to the ALL/MOS
  111.                         memory manager.
  112.  
  113.         4. V$           A string array, 20 bytes long, which is used to
  114.                         store a control data string, read from the ALLMOS
  115.                         device driver using IOCTL$ command.
  116.  
  117.  
  118.         FILES
  119.         -----
  120.  
  121.         1. "$ALLMOS$"   The name of ALLMOS.SYS device driver, opened
  122.                         for input as file #3.
  123.  
  124.  
  125.  
  126.  
  127.  
  128. 4.)     SUBROUTINES
  129.         ===========
  130.  
  131.         1. 9300    MEMINIT ---- initializes the MEMMAN subroutine, open
  132.                                 a connection to ALL/MOS.  This routine
  133.                                 must be called once before calling the
  134.                                 MEMMAN subroutine.
  135.                                 It has no input and no output.
  136.  
  137.         2. 9400    MEMMAN  ---- calls the ALL/MOS memory manager service
  138.                                 routine.  The CPU registers are loaded
  139.                                 from the array REG% before calling ALL/MOS,
  140.                                 and the output registers from ALL/MOS are
  141.                                 saved back into REG% on completion. To find
  142.                                 out how to use the memory manager, refer to
  143.                                 the "ALL/MOS TECHNICAL REFERENCE MANUAL".
  144.  
  145.  
  146.  
  147.  
  148.  
  149. 5.)     HOW TO USE IT
  150.         =============
  151.  
  152.  
  153.         1.      The device driver ALLMOS.SYS must be installed in the
  154.                 CONFIG.SYS file.
  155.  
  156.         2.      The current directory should contain the following files.
  157.                 * fcall.bin
  158.                 * memacc.bas
  159.  
  160.         3.      The MEMACC.BAS program starts with line number 9300.
  161.                 Users can use MEMACC.BAS to access ALL/MOS service routine
  162.                 by writing an application program with line number less
  163.                 than 9300.
  164.  
  165.         4.      At the beginning of the application program, the following
  166.                 statement should be installed.
  167.  
  168.                 nn CHAIN MERGE "MEMACC", ALL, DELETE nn
  169.  
  170.                 where nn is a line number
  171.  
  172.                 e.g.  10 CHAIN MERGE "MEMACC", ALL, DELETE 10
  173.                       20 GOSUB ....etc.
  174.                       30 ...etc.
  175.  
  176.         5.      Before calling the MEMMAN subroutine, MEMINIT subroutine
  177.                 must be called first.  Its entry point is line number 9300.
  178.  
  179.                 e.g. GOSUB 9300
  180.  
  181.         6.      Before calling the MEMMAN subroutine, the user must assign
  182.                 appropriate values to each appropriate element of the integer
  183.                 array REG%, and then call the MEMMAN routine.  After
  184.                 executing the ALL/MOS memory manager, the CPU registers
  185.                 from ALL/MOS will be copied back into the REG% array.
  186.                 Its entry point is line number 9400.
  187.  
  188.                 e.g. REG%(1) = &HFF00     ' get version of ALL/MOS
  189.                      GOSUB 9400
  190.                      VERSION% = REG%(2)
  191.  
  192.  
  193.  
  194.  
  195. 6.)     MEMACC.BAS
  196.         ==========
  197.  
  198.         The following is a listing of "MEMACC.BAS".
  199.  
  200.  
  201.      9300 GOTO 9508          '    meminit routine
  202.      9400 GOTO 9533          '    memman routine
  203.      9401 REM *********************************************************************
  204.      9402 REM *                                                                   *
  205.      9403 REM *          TITLE :     MEMACC.BAS                                   *
  206.      9404 REM *                                                                   *
  207.      9405 REM *          FUNCTION:   ACCESS ALLMOS.SYS MEMORY MANAGER             *
  208.      9406 REM *                                                                   *
  209.      9407 REM *          AUTHOR:     Peter Wong, ALL Computers Inc.               *
  210.      9408 REM *                                                                   *
  211.      9409 REM *          DATE:       September 16, 1986                           *
  212.      9410 REM *                                                                   *
  213.      9411 REM *          HISTORY:    16 SEPT 86         NEW                       *
  214.      9412 REM *                                                                   *
  215.      9413 REM *********************************************************************
  216.      9414 '
  217.      9500 '
  218.      9501 ' ******************** SUBROUTINES ***********************************
  219.      9502 REM
  220.      9503 REM
  221.      9504 REM      1. MEMINIT ----- initialize MEMACC service routine.
  222.      9505 REM
  223.      9506 REM
  224.      9507 REM
  225.      9508 OPTION BASE 1
  226.      9509 DIM REG%(6)
  227.      9510 DIM MEMMAN.ADDRESS%(2)
  228.      9511 DIM FCALL%(45)
  229.      9512 DIM V$(20)
  230.      9513 SUBRT% = 0
  231.      9514 ' open file for read
  232.      9515 OPEN "$ALLMOS$" FOR INPUT AS #3
  233.      9516 V$ = IOCTL$(#3)
  234.      9517 MEMMAN.ADDRESS%(1) = ASC(MID$(V$,1,1)) + 256*(ASC(MID$(V$,2,1)))
  235.      9518 MEMMAN.ADDRESS%(2) = ASC(MID$(V$,3,1)) + 256*(ASC(MID$(V$,4,1)))
  236.      9519 '
  237.      9520 'find start of array
  238.      9521 SUBRT% = VARPTR(FCALL%(1))
  239.      9522 '
  240.      9523 'load routine into array
  241.      9524 BLOAD "fcall.bin",SUBRT%
  242.      9525 RETURN
  243.      9526 '---------------------------------------------------------------------
  244.      9527 REM
  245.      9528 REM
  246.      9529 REM         2. MEMMAN ---- Call ALL/MOS Memory Manager.
  247.      9530 REM                        input: reg
  248.      9531 REM                       output: reg
  249.      9532 REM
  250.      9533 SUBRT%= VARPTR(FCALL%(1))
  251.      9534 CALL SUBRT%(MEMMAN.ADDRESS%(1),REG%(1))
  252.      9535 RETURN
  253.      9536 '
  254.      9537 '--------------------------------------------------------------------------
  255.      9538 '**************************************************************************
  256.      9539 '******************* END of MEMACC.BAS ************************************
  257.      9540 '**************************************************************************
  258.  
  259.  
  260.  
  261. 7.)     A SAMPLE PROGRAM
  262.         ================
  263.  
  264.         This is a listing of EXAMPLE.BAS which is included in the distribution
  265.         disk.   It is a good example to demonstrate  how to access
  266.         ALLMOS.SYS service routine.
  267.  
  268.  
  269.  
  270.       10 CHAIN MERGE "MEMACC",ALL, DELETE 10   'Merge MEMACC.BAS; delete merge command.
  271.       20 REM ************************************************************************
  272.       30 REM *                                                                      *
  273.       40 REM *                TITLE :  EXAMPLE.BAS                                     *
  274.       50 REM *                                                                      *
  275.       60 REM *                FUNCTION : A example to access ALLMOS.SYS service     *
  276.       70 REM *                           routine.                                   *
  277.       80 REM *                AUTHOR : Peter Wong, ALL Computers Inc.               *
  278.       90 REM *                                                                      *
  279.       100 REM *                DATE : 16 SEPTEMBER 1986                              *
  280.       110 REM *                                                                      *
  281.       120 REM *               HISTORY :  16 SEPT 86            NEW                   *
  282.       130 REM *                                                                      *
  283.       140 REM ************************************************************************
  284.       150 '
  285.       160 'This program does the following.
  286.       170 '* calls meminit to initialize MEMMAN subroutine.
  287.       180 '* gets the version number of ALL/MOS.
  288.       190 '* opens a new process id.
  289.       200 '* sets the memory allocation type.
  290.       210 '* gets the memory allocation type.
  291.       220 '* gets the total number of pages in system.
  292.       230 '* gets the number of free pages.
  293.       240 '* allocates 4 contiguous pages.
  294.       250 '* reads the page mapped into a logical page.
  295.       260 '* maps a physical page into a logical page.
  296.       270 '* deallocates 4 contiguous pages.
  297.       280 '* closes a process id.
  298.       290 '
  299.       300 '
  300.       310 '
  301.       320 '
  302.       330 '
  303.       340 'MEMINIT
  304.       350 GOSUB 9300
  305.       360 '
  306.       370 ' find out which version of ALL/MOS
  307.       380 REG%(1) = &HFF00            'VERSION
  308.       390 GOSUB 9400
  309.       400 ' REG%(2) = version of ALL/MOS.
  310.       410 '
  311.       420 'open new process id
  312.       430 REG%(1) = &H0               'OPEN_PID
  313.       440 GOSUB 9400
  314.       450 PROCESS.ID% = REG%(4)
  315.       460 '
  316.       470 'set memory allocation type
  317.       480 REG%(1) = &H200             'SET_MEM_TYPE
  318.       490 REG%(2) = &H2               'any memory
  319.       500 REG%(4) = PROCESS.ID%
  320.       510 GOSUB 9400
  321.       520 '
  322.       530 ' get memory allocation type
  323.       540 REG%(1) = &H300             'GET_MEM_TYPE
  324.       550 REG%(4) = PROCESS.ID%
  325.       560 GOSUB 9400
  326.       570 MEMORY.TYPE% = REG%(2)
  327.       580 '
  328.       590 'get total number of pages in system
  329.       600 REG%(1) = &H900             'TOTAL_PAGES
  330.       610 REG%(2) = &H2               'any memory
  331.       620 GOSUB 9400
  332.       630 TOTAL.PAGES% = REG%(2)
  333.       640 '
  334.       650 'get number of free pages
  335.       660 REG%(1) =&HA00              'FREE_PAGES
  336.       670 REG%(2) = &H2               'any memory
  337.       680 GOSUB 9400
  338.       690 FREE.PAGES% = REG%(2)
  339.       700 '
  340.       710 'allocate 4 contiguous pages
  341.       720 REG%(1) = &H500             'TAKENPAGES
  342.       730 REG%(3)= 4                  'number of pages
  343.       740 REG%(4) = PROCESS.ID%
  344.       750 GOSUB 9400
  345.       760 PAGE.TOKEN% = REG%(2)
  346.       770 '
  347.       780 ' read the page mapped into a logical page
  348.       790 REG%(1) = &HDD0             'READ_MAP
  349.       800 GOSUB 9400
  350.       810 OLD.PAGE.TOKEN% = REG%(2)
  351.       820 '
  352.       830 ' map the first allocated page into &HD000:0000
  353.       840 REG%(1) = &HCD0             'MAP
  354.       850 REG%(2) = PAGE.TOKEN%
  355.       860 REG%(4) = PROCESS.ID%
  356.       870 GOSUB 9400
  357.       880 '
  358.       890 ' peek a value into the first allocated page
  359.       900 DEF SEG=&HD000
  360.       910 POKE 0,1
  361.       920 DEF SEG
  362.       930 ' map the second allocated page into &HD000:0000
  363.       940 REG%(1) = &HCD0             'MAP
  364.       950 REG%(2) = PAGE.TOKEN%+1
  365.       960 REG%(4) = PROCESS.ID%
  366.       970 GOSUB 9400
  367.       980 '
  368.       990 ' peek a value into the second allocated page
  369.       1000 DEF SEG = &HD000
  370.       1010 POKE 0,2
  371.       1020 DEF SEG
  372.       1030 ' map the first allocated page into &HD000:0000
  373.       1040 REG%(1) = &HD000           'MAP
  374.       1050 REG%(2) = PAGE.TOKEN%
  375.       1060 REG%(4) = PROCESS.ID%
  376.       1070 GOSUB 9400
  377.       1080 '
  378.       1090 'read a byte from the first allocated page
  379.       1100 DEF SEG =&HD000
  380.       1110 V = PEEK(0)
  381.       1120 DEF SEG
  382.       1130 ' map the second allocated page into &HD000:0000
  383.       1140 REG%(1) = &HCD0
  384.       1150 REG%(2) = PAGE.TOKEN%+1
  385.       1160 REG%(4) = PROCESS.ID%
  386.       1170 GOSUB 9400
  387.       1180 '
  388.       1190 ' read a byte from second allocated page
  389.       1200 DEF SEG = &HD000
  390.       1210 V=PEEK(0)
  391.       1220 DEF SEG
  392.       1230 '
  393.       1240 ' restore original page token (old.page.token)
  394.       1250 REG%(1) = &HCD0
  395.       1260 REG%(2) = OLD.PAGE.TOKEN%
  396.       1270 REG%(4) = -1
  397.       1280 GOSUB 9400
  398.       1290 '
  399.       1300 'deallocate 4 contiguous pages
  400.       1310 REG%(1) = &H700
  401.       1320 REG%(2) = PAGE.TOKEN%
  402.       1330 REG%(3) = 4
  403.       1340 REG%(4) = PROCESS.ID%
  404.       1350 GOSUB 9400
  405.       1360 '
  406.       1370 ' close process id
  407.       1380 REG%(1) = &H100
  408.       1390 REG%(4) = PROCESS.ID%
  409.       1400 GOSUB 9400
  410.       1410 END
  411.