home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-05-24 | 35.0 KB | 1,293 lines |
- 1
-
-
-
- PROCEDURE ValueDemo(A: CARDINAL; B: INTEGER; F: REAL;
- Str: String20);
- .
- .
- -----------------------------------------------------
- .
- .
- A := 1; {A is a CARDINAL}
- B := -1; {B is an INTEGER}
- F := 10.384; {F is a REAL}
- Str := 'Hello There!'; {Str is an ARRAY[0..19] OF CHAR}
- ValueDemo(a, B, F, Str);
-
-
-
- At the call to ValueDemo the stack is set up as follows:
-
-
- +---------+---------+
- BP + 14H | Value of A |
- +---------+---------+
- BP + 12H | Value of B |
- +---------+---------+
- | Word 1 of F |
- +---------+---------+
- | Word 2 of F |
- +---------+---------+
- | Word 3 of F |
- +---------+---------+
- BP + 0AH | Word 4 of F |
- +---------+---------+
- | Seg of Str |
- +---------+---------+
- BP + 06H | Ofst of Str |
- +---------+---------+
- BP + 04H | Return Segment |
- +---------+---------+
- BP + 02H | Address Offset |
- +---------+---------+
- BP + 00H | Old BP |
- +---------+---------+
-
- Figure 1. Procedure code and stack for a procedure whose parameters
- are called by value.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 2
-
-
-
-
- PROCEDURE OpenArrayProc(VAR TestArray: ARRAY OF CHAR;
- OtherArray : ARRAY OF CHAR);
- .
- .
- ----------------------------------------------------------
- .
- .
- VAR
- TestArray,
- OtherArray: ARRAY[0..19] OF CHAR;
- .
- .
- .
- TestArray := 'This is a Test';
- OtherArray := 'This is the other array';
- OpenArrayProc(TestArray, OtherArray);
-
-
-
- At the call to ValueDemo the stack is set up as follows:
-
-
- +---------+---------+
- BP + 10H | Max Index of |
- | TestArray |
- +---------+---------+
- | Seg of TestArray |
- +---------+---------+
- BP + 0CH | Ofst of TestArray |
- +---------+---------+
- BP + 0AH | Max Index of |
- | OtherArray|
- +---------+---------+
- | Seg of OtherArray |
- +---------+---------+
- BP + 06H | Ofst of OtherArray|
- +---------+---------+
- BP + 04H | Return Segment |
- +---------+---------+
- BP + 02H | Address Offset |
- +---------+---------+
- BP + 00H | Old BP |
- +---------+---------+
-
- Figure 2. Procedure code and stack for a procedure whose arguments
- are open arrays.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3
-
-
- FOREIGN DEFINITION MODULE NetNNN;
-
- (*
- Title : NetNNN
- LastEdit: 4-May-88 13:33
- Author : J. C. Johnston
- System : Network Tools No-wait Name Procedures
- Compiler: LOGITECH MODULA-2 V3.03
- *)
-
- FROM NetDefs IMPORT NetNameStr;
-
- EXPORT QUALIFIED
- NNNADD, NNNADG, NNNRMV;
-
-
- PROCEDURE NNNADD(VAR NTErr, NTErr1, Adapter : INTEGER;
- VAR NetName: NetNameStr;
- VAR NameNumber : INTEGER);
- (* Alternate No-Wait Add a name *)
-
- PROCEDURE NNNADG(VAR NTErr, NTErr1, Adapter: INTEGER;
- VAR GrpName : NetNameStr;
- VAR GrpNum : INTEGER);
- (* Alternate No-wait add a group name *)
-
- PROCEDURE NNNRMV(VAR NTErr, NTErr1, Adapter : INTEGER;
- VAR NetName : NetNameStr);
- (* Alternate No-wait Remove a group name *)
-
- END NetNNN.
-
- Figure 4. Example Definition Module for Network Tools code.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4
-
-
-
- ;
-
- ; Notice that the following variable is in the code segment
- ;
- DStore DW ? ; hold the DS Register
- ;
- ;
- L__FGDrawLines__IRISGraf PROC FAR ;
- ;
- ;
- ; PROCEDURE FGDrawLines(FrameNo, PointCount : CARDINAL;
- ; VAR PointArray: ILUTArrayType): CARDINAL;
- ; (* draws a line through each point specified in the array *)
- ;
- ;
- PArray = 6
- PCount = PArray+4
- FrameNo = PCount+2
- ;
- PUSH BP
- MOV BP,SP
- MOV CS:DStore,DS ;save the Current DS
- MOV AX,[BP]+FrameNo ;get the parameter
- PUSH AX ;push it
- MOV AX,[BP]+PCount ;get the parameter
- PUSH AX ;push it
- LDS AX,[BP]+PArray
- PUSH DS
- PUSH AX
- CALL IS_DRAW_LINES ;
- MOV DS,CS:DStore ;get DS back
- MOV SP,BP ; reset stack pointer
- POP BP ;restore BP
- RET 08H
- ;
- L__FGDrawLines__IRISGraf ENDP
-
- Figure 5. Building an Iris call from a Modula-2 call.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
- PAGE ,132
- .LALL
- ;
- ;IRISINIT - M2 Interface for DT-IRIS isinit module
- ;-----------------
- ;
- ;Interface for Data Translation IRIS isinit Module
- ;to LOGITECH MODULA Version 3
- ;
- ; The purpose of this module is to provide an interface between
- ; the Logitech M2 compiler and the DT-IRIS library. The DT-IRIS
- ; library is written to link to the Microsoft Pascal Compiler.
- ; The library code, as supplied by Data Translation, assumes the
- ; use of FAR calls to reach the library functions and NEAR
- ; references to parameters passed by reference.
- ;
- ; The Modula compiler uses FAR calls to communicate with procedures
- ; in external modules but passes parameters by reference using
- ; FAR references.
- ;
- ; In an effort to correct for this mismatch, all of the variables
- ; passed from by reference between the DT-IRIS library and the
- ; Modula program will be defined in a seperate module. This
- ; should insure that all of the data will be in the same
- ; data segment.
- ;
- ; Modula strings are ASCIIZ as are DT-IRIS strings. MS Pascal
- ; strings use the 0th element to hold the string length. If
- ; this presents a problem, it may have to be dealt with here also.
- ;
- ;
- ;*****************************************************************
- ;* *
- ;* Author: Chris Johnston (March 1988) *
- ;* Microgravity Materials Science Laboratory *
- ;* NASA Lewis Research Center *
- ;* 21000 Brookpark Road MS 105-1 *
- ;* Cleveland, Ohio 44132 *
- ;* (216) 433-5029 *
- ;* *
- ;*****************************************************************
- ;
- ;
- ;
- TITLE IRISInit
- ;
- DGROUP GROUP DATA
- ;
- ; Exported Procedures
- ;
- PUBLIC L__FGInit__IRISInit
- PUBLIC L__FGAbort__IRISInit
- PUBLIC L__FGConfig__IRISInit
- PUBLIC L__FGReset__IRISInit
-
-
-
-
-
-
-
-
-
- 2
-
-
- PUBLIC L__FGEnd__IRISInit
- PUBLIC L__FGTest__IRISInit
- ;
- ;
- ; Initialization Entry point
- ;
- PUBLIC $INIT__IRISInit
- PUBLIC $BODY__IRISInit
- ;
- ;
- ; Exported Variables
- ;
- ; Cardinals
- ;
- PUBLIC ExternTriggerStatus__IRISInit, IVal__IRISInit
- PUBLIC RedVal__IRISInit, GreenVal__IRISInit, BlueVal__IRISInit
- PUBLIC RowAddr__IRISInit, ColAddr__IRISInit, RowPos__IRISInit
- PUBLIC ColumnPos__IRISInit
- ;
- ; Frame ID array
- ;
- PUBLIC FrameID__IRISInit
- ;
- ; Long Integers
- ;
- PUBLIC FGMemFailAddr__IRISInit, RsltSum__IRISInit
- ;
- ; Config Array
- ;
- PUBLIC FGConfiguration__IRISInit
- ;
- ; ILUT arrays
- ;
- PUBLIC PointArray__IRISInit
- PUBLIC ILUTArray__IRISInit, RedArray__IRISInit
- PUBLIC GreenArray__IRISInit, BlueArray__IRISInit
- ;
- ;
- ; Bin Array
- ;
- PUBLIC BinArray__IRISInit
- ;
- ; FGCA variables
- ;
- PUBLIC CharArray__IRISInit
- ;
- ; Array Addresses
- ;
- PUBLIC SourceArrayAddr__IRISInit, DestArrayAddr__IRISInit
- ;
- ; FileName String
- ;
- PUBLIC FGFileName__IRISInit
- ;
-
-
-
-
-
-
-
-
-
- 3
-
-
- ;
- PUBLIC $BM__IRISInit, $EM__IRISInit ;beginning and end of module
- PUBLIC $BD__IRISInit, $BD__IRISInit ;beginning and end of data
- ;
- ; The symbol KEY__<dateSYMfile>_OF_<modulename> is needed for
- ; version checking and can be set to zero
- ; Do a:
- ; DIR IRISInit.SYM
- ; to get the time and date of compilation of the .DEF file
- ; Assemble with:
- ; ASMMOD IRISInit
-
- PUBLIC KEY__13apr88_1005_OF_IRISInit
- ;
- KEY__13apr88_1005_OF_IRISInit EQU 0
- ;
- CR = 0DH
- ;
- ;----------------------------------------------------------------------
- ;
- ; External definitions
- ;
- ;----------------------------------------------------------------------
- ;
- EXTRN IS_INITIALIZE:FAR, IS_CONFIGURATION:FAR, IS_RESET:FAR
- EXTRN IS_ABORT:FAR, IS_TEST:FAR, IS_END:FAR
- EXTRN I$DRIVER_HANDLE:BYTE, I$FLAGS:BYTE, I$ERROR_TABLE_END:WORD
- EXTRN I$MAX_BUFFERS_AVAILABLE:BYTE
- ;
- ;----------------------------------------------------------------------
- ;
- ; Macro definitions
- ;
- ;----------------------------------------------------------------------
- ;
- IF1 ;DEFINE ON FIRST PASS ONLY
- SetCall MACRO ; set up for an IRIS call
- PUSH BP
- MOV BP,SP
- MOV CS:DStore,DS ;Save the Current DS
- MOV AX,SEG I$FLAGS ; get the segment of the IRIS data
- MOV DS,AX ; flag data and set up DS
- ENDM
- ;
- SetVarCall MACRO
- PUSH BP
- MOV BP,SP
- MOV CS:DStore,DS ;save the Current DS
- ENDM
- ;
- Recover MACRO
- MOV DS,CS:DStore ;get DS back
- MOV SP,BP ; reset stack pointer
- POP BP ;restore BP
-
-
-
-
-
-
-
-
-
- 4
-
-
- ENDM
- ;
- RecoverVar MACRO
- MOV SP,BP
- POP BP
- ENDM
- ENDIF
- ;
- ;
- ;----------------------------------------------------------------------
- ;
- ; Implementation Code for Modula 2/86
- ;
- ;----------------------------------------------------------------------
- ;
- ;
- ;
- IRISInit_TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:IRISInit_TEXT
- ASSUME DS:NOTHING
- ;
- $BM__IRISInit:
- ;
-
- ORG 0
- ;
- ;----------------------------------------------------------------------
- ;
- ;DSeg LABEL WORD
- ;
- ;
- ;
- DStore DW ? ;space for DS storage
- ;
- ;VParam1 DW ? ;space for VALUE
- ;VParam2 DW ? ; Params
- ;RParam1 DD ? ;Space for REFERENCE
- ;RParam2 DD ? ; long
- ;RParam3 DD ? ; pointers
- ;
- ;
- ;**********************************************************************
- ;
- ; Procedure Code
- ;
- ;**********************************************************************
- ;
- ;
- L__FGInit__IRISInit PROC FAR ;INITIALIZE grabber
- ;
- ;
- ; PROCEDURE FGInit(): CARDINAL;
- ; (* This procedure initializes the frame grabber *)
- ;
-
-
-
-
-
-
-
-
-
- 5
-
-
- SetCall
- CALL IS_INITIALIZE ;CALL IRIS Init
- Recover
- RET
- ;
- L__FGInit__IRISInit ENDP
- ;
- ;
- L__FGAbort__IRISInit PROC FAR ;grabber ABORT
- ;
- ;
- ; PROCEDURE FGAbort(): CARDINAL;
- ; (* This procedure causes an immediate abort of the
- ; current grabber function *)
- ;
- ;
- SetCall
- CALL IS_ABORT ;CALL IRIS ABORT
- Recover
- RET
- ;
- L__FGAbort__IRISInit ENDP
- ;
- ;
- L__FGConfig__IRISInit PROC FAR ;report grabber CONFIG
- ;
- ;
- ; PROCEDURE FGConfig(VAR FGConfiguration: FGConfArray): CARDINAL;
- ; (* this procedure returns the grabber configuration *)
- ;
- Array = 6
- ;
- SetVarCall
- LDS DI,[BP]+Array
- PUSH DI
- ; MOV AX,SEG I$FLAGS
- CALL IS_CONFIGURATION ;call the IRIS routine
- Recover
- RET 04H
- ;
- L__FGConfig__IRISInit ENDP
- ;
- ;
- L__FGReset__IRISInit PROC FAR ;SEND
- ;
- ;
- ; PROCEDURE FGReset(): CARDINAL;
- ; (* This procedure resets the frame grabber *)
- ;
- ;
- SetCall
- CALL IS_RESET ;reset the frame grabber
- Recover
- RET ;
-
-
-
-
-
-
-
-
-
- 6
-
-
- ;
- L__FGReset__IRISInit ENDP
- ;
- ;
- L__FGEnd__IRISInit PROC FAR ;grabber END
- ;
- ;
- ; PROCEDURE FGEnd(): CARDINAL;
- ; (* This procedure wipes out all connection to the grabber. It closes
- ; the channel to the device driver, and deallocates all frame buffers
- ; and temporary intermediate buffers *)
- ;
- SetCall
- CALL IS_END ;END it all
- Recover
- RET
- ;
- L__FGEnd__IRISInit ENDP
- ;
- ;
- L__FGTest__IRISInit PROC FAR ;grabber TEST
- ;
- ;
- ; PROCEDURE FGTest(VAR FGMemFailAddr: LONGINT): CARDINAL;
- ; (* This procedure stops, tests and resets the grabber. The address
- ; of the first bad byte of menory is returned in FGMemFailAddr *)
- ;
- TAddr = 6
- ;
- SetVarCall
- LDS DI,[BP]+TAddr ;get address of variable
- PUSH DI ; push offest
- CALL IS_TEST ;CALL IRIS Test
- Recover
- RET 04H
- ;
- L__FGTest__IRISInit ENDP
- ;
- ;
- $BODY__IRISInit PROC FAR ;module body code
- ;
- RET ;just leave
- ;
- $BODY__IRISInit ENDP
- ;
- ;
- ;
- $INIT__IRISInit PROC FAR ;Module Init Code
- ;
- MOV ax,0 ;CLEAR ax
- MOV I$FLAGS,AL ;clear I$FLAGS
- RET
- ;
- $INIT__IRISInit ENDP
-
-
-
-
-
-
-
-
-
- 7
-
-
- ;
- ;
- $EM__IRISInit:
- ;
- IRISInit_TEXT ENDS
- ;
- ;
- IRISInit_DATA SEGMENT WORD PUBLIC 'FAR_BSS'
- ASSUME CS:IRISInit_TEXT
- ;
- $BD__IRISInit LABEL FAR
-
- $ED__IRISInit LABEL FAR
- IRISInit_DATA ENDS
- ;
- ;
- ; This DATA segment should be merged with the segment of
- ; the same name in isinit.obj
- ;
- DATA SEGMENT WORD PUBLIC 'DATA'
- ;
- ExternTriggerStatus__IRISInit DW ? ;Define the Cardinals
- IVal__IRISInit DW ? ;
- RedVal__IRISInit DW ? ;
- GreenVal__IRISInit DW ? ;
- BlueVal__IRISInit DW ? ;
- RowAddr__IRISInit DW ? ;
- ColAddr__IRISInit DW ? ;
- RowPos__IRISInit DW ? ;
- ColumnPos__IRISInit DW ? ;
- ;
- FrameID__IRISInit DW 2 DUP(?) ;Frame ID type
- ;
- FGMemFailAddr__IRISInit DD ? ;Long Integers
- RsltSum__IRISInit DD ? ;
- ;
- FGConfiguration__IRISInit DW 20 DUP(?) ;Configuration Array
- ;
- PointArray__IRISInit DW 256 DUP(?) ;Point Arrays
- ILUTArray__IRISInit DW 256 DUP(?) ;ILUT Arrays
- RedArray__IRISInit DW 256 DUP(?) ;
- GreenArray__IRISInit DW 256 DUP(?) ;
- BlueArray__IRISInit DW 256 DUP(?) ;
- ;
- BinArray__IRISInit DD 256 DUP(?) ;Bin Arrays
- ;
- CharArray__IRISInit DB 256 DUP(?) ;Char Array
- ;
- SourceArrayAddr__IRISInit DD ? ;holds addresses
- DestArrayAddr__IRISInit DD ? ;
- ;
- FGFileName__IRISInit DB 30 DUP(?) ;holds the filename
- ;
- DATA ENDS
-
-
-
-
-
-
-
-
-
- 8
-
-
-
- INIT_FLAG_DATA SEGMENT WORD PUBLIC 'FAR_DATA'
- ;
- $FLAG__IRISInit DB 0
- ;
- INIT_FLAG_DATA ENDS
- ;
- END
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DEFINITION MODULE BlockMove;
- (*
- Title : BlockMove - Move Data to/from memory and frame grabber
- LastEdit: 9-May-88 12:26
- Author : J. C. Johnston
- System : Telescience
- Compiler: LOGITECH MODULA-2 V3.03
- *)
-
- FROM SYSTEM IMPORT BYTE, ADDRESS;
-
- EXPORT QUALIFIED
- BlockGDTType, GBlockAddress, BlockMoveGDT,
- MoveMem2FG, MoveFG2Mem, AddArith;
-
- TYPE
- BlockGDTType = ARRAY[0..47] OF BYTE;
-
- VAR
- GBlockAddress : ADDRESS;
- BlockMoveGDT : BlockGDTType;
-
- PROCEDURE MoveMem2FG(Source, Destination: ADDRESS; Length: CARDINAL);
- (* This procedure set up and executes a block move from
- system memory to the Frame Grabber memory *)
-
- PROCEDURE MoveFG2Mem(Source, Destination: ADDRESS; Length: CARDINAL);
- (* This procedure set up and executes a block move from the Frame
- Grabber memory to system memory *)
-
- PROCEDURE AddArith(VAR AddressArg: ADDRESS; Increment: CARDINAL);
- (* This procedure adds the increment to AddressArg and returns the
- new Address in AddredssArg. Use this procedure to do arithmetic
- on ADDRESS type variables to handle overflow of the OFFSET into
- the SEGMENT *)
-
- END BlockMove.
- Figure 7a. Definition module for an assembly language module
- -------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-1
-
-
- ;
- PAGE ,132
- .LALL
- .286
- ;******************************************************************
- ; Module : BlockMove, move a block between DOS memory
- ; and Frame Grabber Memory
- ;
- TITLE BlockMove
-
- PUBLIC L__MoveMem2FG__BlockMove
- PUBLIC L__MoveFG2Mem__BlockMove
- PUBLIC L__AddArith__BlockMove
- ;
- ; Set the KEY symbol to the compilation date for the def module.
- ; the compilation date can be obtained by executing the command:
- ; DIR BlockMove.sym
- ;
- PUBLIC KEY__23may88_1724_OF_BlockMove
-
- KEY__23may88_1724_OF_BlockMove EQU 0
-
- PUBLIC $INIT__BlockMove
- PUBLIC $BM__BlockMove, $EM__BlockMove
- PUBLIC $BD__BlockMove, $ED__BlockMove
-
-
- BlockMove_TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:BlockMove_TEXT
- ASSUME DS:NOTHING
- $BM__BlockMove:
-
- ;-----------------------------------------------------------
- L__MoveMem2FG__BlockMove PROC FAR
- ;-----------------------------------------------------------
- ;
- ;PROCEDURE MoveMem2FG(Source, Destination: ADDRESS; Length: CARDINAL);
- ; (* This procedure set up and executes a block move from
- ; system memory to the Frame Grabber memory *)
- ;
- MLength = 6
- destination = MLength + 2
- source = destination + 4
- ;
- PUSH BP
- MOV BP,SP
- PUSH DS
- PUSH AX
- PUSH BX
- PUSH CX
- PUSH DX
- MOV AX, SEG BlockMove_DATA
- MOV DS,AX
- ;
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-2
-
-
- CALL S_SetFGRW__BlockMove ; set the frame grabber to R/W
- ;
- LES CX,[BP]+source
- MOV AX,ES ;get ES into AX
- SHL AX,4 ;shift 4 bits
- MOV BX,ES ;Move ES into BX
- SHR BX,12 ;shift high part
- ADD AX,CX ;add offset and shifted source
- ADC BX,0 ;add BX with carry
- MOV SAddressL,AX ;store the low source address
- MOV SAddressH,BL ;store the high source address
- ;
- LES CX,[BP]+destination
- MOV AX,ES ;get ES into AX
- SHL AX,4 ;shift 4 bits
- MOV BX,ES ;Move ES into BX
- SHR BX,12 ;shift high part
- ADD AX,CX ;add offset and shifted destination
- ADC BX,00A0H ;add BX and offset with carry
- MOV DAddressL,AX ;store the low destination address
- MOV DAddressH,BL ;store the high destination address
- ;
- MOV AX,[BP]+MLength ;get the length to move
- MOV SLength,AX ;store it in the GDT
- MOV DLength,AX ;store it in the GDT
- ;
- MOV CX,AX ;load the length into CX
- SHR CX,1 ; get the number of words
- MOV AX,GBlockAdrSeg ;get the segment of the GDT
- MOV ES,AX ; into ES
- MOV SI,GBlockAddress__BlockMove
- MOV AH,87H ;get the command
- INT 15H ;do the call
- ;
- CALL S__ResetFG__BlockMove ;Reset the Frame Grabber planes
- POP DX
- POP CX
- POP BX
- POP AX
- POP DS
- MOV SP,BP
- POP BP
- RET 0AH
-
- L__MoveMem2FG__BlockMove ENDP
-
- ;-----------------------------------------------------------
- L__MoveFG2Mem__BlockMove PROC FAR
- ;-----------------------------------------------------------
- ;
- ;PROCEDURE MoveFG2Mem(Source, Destination: ADDRESS; Length: CARDINAL);
- ; (* This procedure set up and executes a block move from
- ; system memory to the Frame Grabber memory *)
- ;
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-3
-
-
- MLength = 6
- destination = MLength + 2
- source = destination + 4
- ;
- PUSH BP
- MOV BP,SP
- PUSH DS
- PUSH AX
- PUSH BX
- PUSH CX
- PUSH DX
- MOV AX, SEG BlockMove_DATA
- MOV DS,AX
- ;
- CALL S_SetFGRW__BlockMove ; set the frame grabber to R/W
- ;
- LES CX,[BP]+source
- MOV AX,ES ;get ES into AX
- SHL AX,4 ;shift 4 bits
- MOV BX,ES ;Move ES into BX
- SHR BX,12 ;shift high part
- ADD AX,CX ;add offset and shifted source
- ; ADC BX,00A4H ;add BX with carry
- ADC BX,00A0H ;add BX with carry
- MOV SAddressL,AX ;store the low source address
- MOV SAddressH,BL ;store the high source address
- ;
- LES CX,[BP]+destination
- MOV AX,ES ;get ES into AX
- SHL AX,4 ;shift 4 bits
- MOV BX,ES ;Move ES into BX
- SHR BX,12 ;shift high part
- ADD AX,CX ;add offset and shifted destination
- ADC BX,0 ;add BX and offset with carry
- MOV DAddressL,AX ;store the low destination address
- MOV DAddressH,BL ;store the high destination address
- ;
- MOV AX,[BP]+MLength ;get the length to move
- ; SHR CX,1 ; get the number of words
- MOV SLength,AX ;store it in the GDT
- MOV DLength,AX ;store it in the GDT
- ;
- MOV CX,[BP]+MLength ;load the length
- SHR CX,1 ; get the number of words
- MOV AX,GBlockAdrSeg ;get the segment of the GDT
- MOV ES,AX ; into ES
- MOV SI,GBlockAddress__BlockMove
- MOV AH,87H ;get the command
- INT 15H ;do the call
- ;
- CALL S__ResetFG__BlockMove ;Reset the Frame Grabber planes
- POP DX
- POP CX
- POP BX
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-4
-
-
- POP AX
- POP DS
- MOV SP,BP
- POP BP
- RET 0AH
-
- L__MoveFG2Mem__BlockMove ENDP
- ;
- ;-----------------------------------------------------------
- L__AddArith__BlockMove PROC FAR
- ;-----------------------------------------------------------
- ;
- ;PROCEDURE AddArith(VAR AddressArg: ADDRESS; Increment: CARDINAL);
- ; (* This procedure adds the increment to AddressArg and returns the
- ; new Address in AddredssArg. Use this procedure to do arithmetic
- ; on ADDRESS type variables to handle overflow of the OFFSET into
- ; the SEGMENT *)
- ;
- Increment = 6
- AddressArg = MLength + 2
- ;
- PUSH BP
- MOV BP,SP
- PUSH AX
- PUSH BX
- PUSH CX
- PUSH DX
- ;
- LES BX,[BP]+AddressArg ;get the address of the parameter
- LES BX,ES:[BX] ;get the parameter itself
- MOV AX,ES ;get SEG into AX
- SHL AX,4 ;shift SEG 4 bits left
- MOV CX,ES ;Move SEG into BX
- SHR CX,12 ;isolate the high nybble
- ADD AX,BX ;add OFFSET (in BX) and Lshifted SEG
- ADC CX,0 ;add Rshifted SEG and offset with carry
- MOV BX,[BP]+Increment ;get the increment
- ADD AX,BX ;Add it into the offset
- ADC CX,0 ; Add the carry to the segment
- ;
- SHL CX,12 ;shift it way over to make a SEG
- ;
- LES BX,[BP]+AddressArg ;get the address of the parameter
- MOV ES:[BX],AX ;put away the offset
- MOV ES:[BX]+2,CX ;store the offset
- ;
- POP DX
- POP CX
- POP BX
- POP AX
- MOV SP,BP
- POP BP
- RET 06H
-
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-5
-
-
- L__AddArith__BlockMove ENDP
- ;
- ;
- INSCR1 = 230H ; Video Input Ctrl/Stat Reg 1
- INSCR2 = 232H ; Video Input Control
- Mask1 = 0080H ; mask the busy bit
- Mask2 = 0FFF0H ; reset write protect bits
- ;
- ;
- S_SetFGRW__BlockMove PROC NEAR ; set the frame grabber to R/W
- ;
- ;
- CALL S__WaitBusy__BlockMove ; wait for the Busy Bit
- MOV DX,INSCR2 ;get the address of Vid In Ctrl Port
- IN AX,DX ;Read the Byte
- MOV PortStore,AX ;Save it
- AND AX,Mask2 ;clear the protection bits
- OUT DX,AX ;and set the FG
- RET
- S_SetFGRW__BlockMove ENDP
- ;
- ;
- ;
- S__ResetFG__BlockMove PROC NEAR ; reset the frame grabber R/W mode
- ;
- ;
- CALL S__WaitBusy__BlockMove ; wait for the Busy Bit
- MOV DX,INSCR2 ;get the address of Vid In Ctrl Port
- MOV AX,PortStore ;get the stored port value
- OUT DX,AX ;and set the FG
- RET
- S__ResetFG__BlockMove ENDP
- ;
- ;
- ;
- S__WaitBusy__BlockMove PROC NEAR ; reset the frame grabber R/W mode
- ;
- ;
- MOV DX,INSCR1 ;get the address of Vid Ctrl Port
- BLoop: IN AX,DX ;read the control port
- TEST AX,Mask1 ;Check for Busy
- JNZ BLoop ;loop till not busy
- RET
- S__WaitBusy__BlockMove ENDP
- ;
- ;
- $INIT__BlockMove PROC FAR
- ;
- ; Load the address of the BlockMoveGDT into GBlockAddress
- ;
- MOV CX,SEG BlockMove_DATA ;GET SEGMENT OF DATA
- MOV DS,CX ;MOVE IT TO DS
- MOV ES,CX ;and ES
- MOV BX,OFFSET BlockMoveGDT__BlockMove ;GET OFFSET OF DATA
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-6
-
-
- MOV ES:GBlockAddress__BlockMove, BX ;STORE THE OFFSET
- MOV ES:GBlockAdrSeg, DS ;STORE THE SEGMENT
- ;
- ; Clear the GDT
- ;
- MOV AX,SEG BlockMoveGDT__BlockMove ;get segment of table
- MOV BX,OFFSET BlockMoveGDT__BlockMove ;get offset of table
- MOV DS,AX ;load DS
- MOV CX,2FH ;SET UP FOR 48 loops
- MOV AL,0 ; set to 0
- Init1: MOV [BX],AL ;clear the GDT
- INC BX ;move the offset
- LOOP Init1 ;Loop until done
- ;
- ; Preset the access rights bytes to 93H
- ;
- MOV AL, 93H ;setup access rights
- MOV SAccessRights, AL ;set the byte
- MOV DAccessRights, AL ;set the byte
-
- RET
- ;
- $INIT__BlockMove ENDP
- $EM__BlockMove:
- BlockMove_TEXT ENDS
-
- BlockMove_DATA SEGMENT WORD PUBLIC 'FAR_BSS'
- ASSUME CS : BlockMove_TEXT
- $BD__BlockMove LABEL FAR
- ;
- PortStore DW ? ;temporary storage for port
- ;
- GBlockAddress__BlockMove DW ? ;holds an address
- GBlockAdrSeg DW ?
- ;
- ; Dummy Descriptor
- ;
- BlockMoveGDT__BlockMove DW ? ;DUMMY TABLE
- DW ? ;
- DB ? ;
- DB ? ;
- DW ? ;RESERVED
- ;
- ; Descriptor for GDT
- ;
- DW ? ;GDT Descriptor TABLE
- DW ? ;
- DB ? ;
- DB ? ;
- DW ? ;RESERVED
- ;
- ; Source Descriptor Table
- ;
- SLength DW ? ;source length
-
-
-
-
-
-
-
-
-
- ; Figure 7b - Assembly code for the BlockMove module 7b-7
-
-
- SAddressL DW ? ;bits 0-15 of source address
- SAddressH DB ? ;bits 16-23 of source address
- SAccessRights DB ? ;
- DW ? ;RESERVED
- ;
- ; Destination Descriptor Table
- ;
- DLength DW ? ;destination length
- DAddressL DW ? ;bits 0-15 of destination address
- DAddressH DB ? ;bits 16-23 of Destination address
- DAccessRights DB ? ;
- DW ? ;RESERVED
- ;
- ; BIOS CS Descriptor
- ;
- DW ? ;table filled by BIOS
- DW ? ;
- DB ? ;
- DB ? ;
- DW ? ;RESERVED
- ;
- ; stack segment descriptor
- ;
- DW ? ;Table filled by BIOS
- DW ? ;
- DB ? ;
- DB ? ;
- DW ? ;RESERVED
- ;
- $ED__BlockMove LABEL FAR
- BlockMove_DATA ENDS
-
- END
- Figure 7b. Assembly code for the module
-