home *** CD-ROM | disk | FTP | other *** search
-
- TITLE: BASIC.DOC
-
- AUTHOR: Peter Wong, ALL Computers Inc.
-
- DATE: 16 SEPTEMBER, 1986
-
-
-
-
-
-
- TABLE OF CONTENTS
- =================
-
-
- 1.) Other related documents
- 2.) Introduction
- 3.) Variables, and Files Used in MEMACC.BAS
- 4.) Subroutines
- 5.) How to Use it
- 6.) MEMACC.BAS
- 7.) Example TEST.BAS
-
-
-
-
-
- 1.) OTHER RELATED DOCUMENTS
- =======================
-
- 1. ALL/MOS TECHNICAL REFERENCE MANUAL
- ---- Intended for use by programmers who wish to write
- programs in assember using the Memory Management
- features of the ALL/MOS standard support software
- for the ALL Card AT1/M.
-
- 2. ALL/MOS SOFTWARE REFERENCE MANUAL
- ---- How to install and use the ALL/MOS software.
-
- 3. ALL CARD HARDWARE REFERENCE MANUAL
- ---- How to install the ALL Card AT1/M
-
- 4. ALL MMU PROGRAMMING GUIDE
- ---- How to write programs that directly use the AT1/M Memory
- Management Unit.
-
-
-
- These manuals may be obtained on request from
-
- ALL Computers Inc.
- 102 Bloor Street West, Suite 1200
- Toronto, Ontario
- Canada, M5S 1M9
- (416) 960-0111
-
-
-
-
-
- 2.) INTRODUCTION
- ============
-
- All/MOS is a set of extensions to PC-DOS and MS-DOS ( Versions 2.0 and
- higher) which allows applications to take advantage of the memory management
- facilities provided by the ALL Card AT1/M and other future products currently
- being developed by ALL Computers Inc.
-
- The program MEMACC.BAS provides two routines which allow users to access
- ALL/MOS service routines (MEMMAN routines) in BASIC.
-
- For detailed description of each MEMMAN routines, refer to the
- "ALL/MOS TECHNICAL REFERENCE MANUAL".
-
-
- 3.) VARIABLES, AND FILES USED IN MEMACC.BAS
- =======================================
-
- VARIABLES
- ---------
- 1. SUBRT% An integer which is used to store the location of
- "fcall.bin".
-
- Since the base of all arrays in MEMACC.BAS is 1 , the application
- programs which are used with "MEMACC.BAS" have to declare all arrays
- with the base of 1.
-
- 2. FCALL% An integer array ,45 words long, which is used
- to store an assembly routine "fcall.bin" which
- is loaded from the disk. This routine performs
- FAR CALL with passing registers AX, BX, CX, DX, SI,
- and DI as inputs, as well as outputs.
-
- 2. REG% An integer array, six words long, which is used to
- store the content of the processor registers.
- It is passed to the routine "fcall.bin" as input and
- back to calling routine as output.
-
- REG%(1) = AX register
- REG%(2) = BX register
- REG%(3) = CX register
- REG%(4) = DX register
- REG%(5) = SI register
- REG%(6) = DI register
-
- 3. MEMMAN.ADDRESS%
- An integer array, two words long, which is used
- to store the location of the routine MEMMAN.
- This routine is the entry point to the ALL/MOS
- memory manager.
-
- 4. V$ A string array, 20 bytes long, which is used to
- store a control data string, read from the ALLMOS
- device driver using IOCTL$ command.
-
-
- FILES
- -----
-
- 1. "$ALLMOS$" The name of ALLMOS.SYS device driver, opened
- for input as file #3.
-
-
-
-
-
- 4.) SUBROUTINES
- ===========
-
- 1. 9300 MEMINIT ---- initializes the MEMMAN subroutine, open
- a connection to ALL/MOS. This routine
- must be called once before calling the
- MEMMAN subroutine.
- It has no input and no output.
-
- 2. 9400 MEMMAN ---- calls the ALL/MOS memory manager service
- routine. The CPU registers are loaded
- from the array REG% before calling ALL/MOS,
- and the output registers from ALL/MOS are
- saved back into REG% on completion. To find
- out how to use the memory manager, refer to
- the "ALL/MOS TECHNICAL REFERENCE MANUAL".
-
-
-
-
-
- 5.) HOW TO USE IT
- =============
-
-
- 1. The device driver ALLMOS.SYS must be installed in the
- CONFIG.SYS file.
-
- 2. The current directory should contain the following files.
- * fcall.bin
- * memacc.bas
-
- 3. The MEMACC.BAS program starts with line number 9300.
- Users can use MEMACC.BAS to access ALL/MOS service routine
- by writing an application program with line number less
- than 9300.
-
- 4. At the beginning of the application program, the following
- statement should be installed.
-
- nn CHAIN MERGE "MEMACC", ALL, DELETE nn
-
- where nn is a line number
-
- e.g. 10 CHAIN MERGE "MEMACC", ALL, DELETE 10
- 20 GOSUB ....etc.
- 30 ...etc.
-
- 5. Before calling the MEMMAN subroutine, MEMINIT subroutine
- must be called first. Its entry point is line number 9300.
-
- e.g. GOSUB 9300
-
- 6. Before calling the MEMMAN subroutine, the user must assign
- appropriate values to each appropriate element of the integer
- array REG%, and then call the MEMMAN routine. After
- executing the ALL/MOS memory manager, the CPU registers
- from ALL/MOS will be copied back into the REG% array.
- Its entry point is line number 9400.
-
- e.g. REG%(1) = &HFF00 ' get version of ALL/MOS
- GOSUB 9400
- VERSION% = REG%(2)
-
-
-
-
- 6.) MEMACC.BAS
- ==========
-
- The following is a listing of "MEMACC.BAS".
-
-
- 9300 GOTO 9508 ' meminit routine
- 9400 GOTO 9533 ' memman routine
- 9401 REM *********************************************************************
- 9402 REM * *
- 9403 REM * TITLE : MEMACC.BAS *
- 9404 REM * *
- 9405 REM * FUNCTION: ACCESS ALLMOS.SYS MEMORY MANAGER *
- 9406 REM * *
- 9407 REM * AUTHOR: Peter Wong, ALL Computers Inc. *
- 9408 REM * *
- 9409 REM * DATE: September 16, 1986 *
- 9410 REM * *
- 9411 REM * HISTORY: 16 SEPT 86 NEW *
- 9412 REM * *
- 9413 REM *********************************************************************
- 9414 '
- 9500 '
- 9501 ' ******************** SUBROUTINES ***********************************
- 9502 REM
- 9503 REM
- 9504 REM 1. MEMINIT ----- initialize MEMACC service routine.
- 9505 REM
- 9506 REM
- 9507 REM
- 9508 OPTION BASE 1
- 9509 DIM REG%(6)
- 9510 DIM MEMMAN.ADDRESS%(2)
- 9511 DIM FCALL%(45)
- 9512 DIM V$(20)
- 9513 SUBRT% = 0
- 9514 ' open file for read
- 9515 OPEN "$ALLMOS$" FOR INPUT AS #3
- 9516 V$ = IOCTL$(#3)
- 9517 MEMMAN.ADDRESS%(1) = ASC(MID$(V$,1,1)) + 256*(ASC(MID$(V$,2,1)))
- 9518 MEMMAN.ADDRESS%(2) = ASC(MID$(V$,3,1)) + 256*(ASC(MID$(V$,4,1)))
- 9519 '
- 9520 'find start of array
- 9521 SUBRT% = VARPTR(FCALL%(1))
- 9522 '
- 9523 'load routine into array
- 9524 BLOAD "fcall.bin",SUBRT%
- 9525 RETURN
- 9526 '---------------------------------------------------------------------
- 9527 REM
- 9528 REM
- 9529 REM 2. MEMMAN ---- Call ALL/MOS Memory Manager.
- 9530 REM input: reg
- 9531 REM output: reg
- 9532 REM
- 9533 SUBRT%= VARPTR(FCALL%(1))
- 9534 CALL SUBRT%(MEMMAN.ADDRESS%(1),REG%(1))
- 9535 RETURN
- 9536 '
- 9537 '--------------------------------------------------------------------------
- 9538 '**************************************************************************
- 9539 '******************* END of MEMACC.BAS ************************************
- 9540 '**************************************************************************
-
-
-
- 7.) A SAMPLE PROGRAM
- ================
-
- This is a listing of EXAMPLE.BAS which is included in the distribution
- disk. It is a good example to demonstrate how to access
- ALLMOS.SYS service routine.
-
-
-
- 10 CHAIN MERGE "MEMACC",ALL, DELETE 10 'Merge MEMACC.BAS; delete merge command.
- 20 REM ************************************************************************
- 30 REM * *
- 40 REM * TITLE : EXAMPLE.BAS *
- 50 REM * *
- 60 REM * FUNCTION : A example to access ALLMOS.SYS service *
- 70 REM * routine. *
- 80 REM * AUTHOR : Peter Wong, ALL Computers Inc. *
- 90 REM * *
- 100 REM * DATE : 16 SEPTEMBER 1986 *
- 110 REM * *
- 120 REM * HISTORY : 16 SEPT 86 NEW *
- 130 REM * *
- 140 REM ************************************************************************
- 150 '
- 160 'This program does the following.
- 170 '* calls meminit to initialize MEMMAN subroutine.
- 180 '* gets the version number of ALL/MOS.
- 190 '* opens a new process id.
- 200 '* sets the memory allocation type.
- 210 '* gets the memory allocation type.
- 220 '* gets the total number of pages in system.
- 230 '* gets the number of free pages.
- 240 '* allocates 4 contiguous pages.
- 250 '* reads the page mapped into a logical page.
- 260 '* maps a physical page into a logical page.
- 270 '* deallocates 4 contiguous pages.
- 280 '* closes a process id.
- 290 '
- 300 '
- 310 '
- 320 '
- 330 '
- 340 'MEMINIT
- 350 GOSUB 9300
- 360 '
- 370 ' find out which version of ALL/MOS
- 380 REG%(1) = &HFF00 'VERSION
- 390 GOSUB 9400
- 400 ' REG%(2) = version of ALL/MOS.
- 410 '
- 420 'open new process id
- 430 REG%(1) = &H0 'OPEN_PID
- 440 GOSUB 9400
- 450 PROCESS.ID% = REG%(4)
- 460 '
- 470 'set memory allocation type
- 480 REG%(1) = &H200 'SET_MEM_TYPE
- 490 REG%(2) = &H2 'any memory
- 500 REG%(4) = PROCESS.ID%
- 510 GOSUB 9400
- 520 '
- 530 ' get memory allocation type
- 540 REG%(1) = &H300 'GET_MEM_TYPE
- 550 REG%(4) = PROCESS.ID%
- 560 GOSUB 9400
- 570 MEMORY.TYPE% = REG%(2)
- 580 '
- 590 'get total number of pages in system
- 600 REG%(1) = &H900 'TOTAL_PAGES
- 610 REG%(2) = &H2 'any memory
- 620 GOSUB 9400
- 630 TOTAL.PAGES% = REG%(2)
- 640 '
- 650 'get number of free pages
- 660 REG%(1) =&HA00 'FREE_PAGES
- 670 REG%(2) = &H2 'any memory
- 680 GOSUB 9400
- 690 FREE.PAGES% = REG%(2)
- 700 '
- 710 'allocate 4 contiguous pages
- 720 REG%(1) = &H500 'TAKENPAGES
- 730 REG%(3)= 4 'number of pages
- 740 REG%(4) = PROCESS.ID%
- 750 GOSUB 9400
- 760 PAGE.TOKEN% = REG%(2)
- 770 '
- 780 ' read the page mapped into a logical page
- 790 REG%(1) = &HDD0 'READ_MAP
- 800 GOSUB 9400
- 810 OLD.PAGE.TOKEN% = REG%(2)
- 820 '
- 830 ' map the first allocated page into &HD000:0000
- 840 REG%(1) = &HCD0 'MAP
- 850 REG%(2) = PAGE.TOKEN%
- 860 REG%(4) = PROCESS.ID%
- 870 GOSUB 9400
- 880 '
- 890 ' peek a value into the first allocated page
- 900 DEF SEG=&HD000
- 910 POKE 0,1
- 920 DEF SEG
- 930 ' map the second allocated page into &HD000:0000
- 940 REG%(1) = &HCD0 'MAP
- 950 REG%(2) = PAGE.TOKEN%+1
- 960 REG%(4) = PROCESS.ID%
- 970 GOSUB 9400
- 980 '
- 990 ' peek a value into the second allocated page
- 1000 DEF SEG = &HD000
- 1010 POKE 0,2
- 1020 DEF SEG
- 1030 ' map the first allocated page into &HD000:0000
- 1040 REG%(1) = &HD000 'MAP
- 1050 REG%(2) = PAGE.TOKEN%
- 1060 REG%(4) = PROCESS.ID%
- 1070 GOSUB 9400
- 1080 '
- 1090 'read a byte from the first allocated page
- 1100 DEF SEG =&HD000
- 1110 V = PEEK(0)
- 1120 DEF SEG
- 1130 ' map the second allocated page into &HD000:0000
- 1140 REG%(1) = &HCD0
- 1150 REG%(2) = PAGE.TOKEN%+1
- 1160 REG%(4) = PROCESS.ID%
- 1170 GOSUB 9400
- 1180 '
- 1190 ' read a byte from second allocated page
- 1200 DEF SEG = &HD000
- 1210 V=PEEK(0)
- 1220 DEF SEG
- 1230 '
- 1240 ' restore original page token (old.page.token)
- 1250 REG%(1) = &HCD0
- 1260 REG%(2) = OLD.PAGE.TOKEN%
- 1270 REG%(4) = -1
- 1280 GOSUB 9400
- 1290 '
- 1300 'deallocate 4 contiguous pages
- 1310 REG%(1) = &H700
- 1320 REG%(2) = PAGE.TOKEN%
- 1330 REG%(3) = 4
- 1340 REG%(4) = PROCESS.ID%
- 1350 GOSUB 9400
- 1360 '
- 1370 ' close process id
- 1380 REG%(1) = &H100
- 1390 REG%(4) = PROCESS.ID%
- 1400 GOSUB 9400
- 1410 END