home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / cmplngmg / cl_jun89.arc / JOHNSTON < prev    next >
Text File  |  1989-05-24  |  36KB  |  1,293 lines

  1.                                                                         1
  2.  
  3.  
  4.      
  5.      PROCEDURE ValueDemo(A: CARDINAL; B: INTEGER; F: REAL;
  6.                                    Str: String20);
  7.                          .
  8.                          .
  9.      -----------------------------------------------------
  10.                          .
  11.                          .
  12.      A := 1;                       {A is a CARDINAL}
  13.      B := -1;                      {B is an INTEGER}
  14.      F := 10.384;                  {F is a REAL}
  15.      Str := 'Hello There!';   {Str is an ARRAY[0..19] OF CHAR}
  16.      ValueDemo(a, B, F, Str);
  17.      
  18.      
  19.      
  20.      At the call to ValueDemo the stack is set up as follows:
  21.      
  22.      
  23.                +---------+---------+
  24.      BP + 14H  | Value of A        |
  25.                +---------+---------+
  26.      BP + 12H  | Value of B        |
  27.                +---------+---------+
  28.                | Word 1 of F       |
  29.                +---------+---------+
  30.                | Word 2 of F       |
  31.                +---------+---------+
  32.                | Word 3 of F       |
  33.                +---------+---------+
  34.      BP + 0AH  | Word 4 of F       |
  35.                +---------+---------+
  36.                | Seg of Str        |
  37.                +---------+---------+
  38.      BP + 06H  | Ofst of Str       |
  39.                +---------+---------+
  40.      BP + 04H  |  Return Segment   |
  41.                +---------+---------+
  42.      BP + 02H  |  Address Offset   |
  43.                +---------+---------+
  44.      BP + 00H  |  Old  BP          |
  45.                +---------+---------+
  46.      
  47.      Figure 1. Procedure code and stack for a procedure whose parameters
  48.                  are called by value.
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                                                                         2
  68.  
  69.  
  70.      
  71.      
  72.      PROCEDURE OpenArrayProc(VAR TestArray: ARRAY OF CHAR;
  73.                                  OtherArray : ARRAY OF CHAR);
  74.                     .
  75.                     .
  76.      ----------------------------------------------------------
  77.                     .
  78.                     .
  79.      VAR
  80.       TestArray,
  81.       OtherArray: ARRAY[0..19] OF CHAR;
  82.                               .
  83.                               .
  84.                               .
  85.      TestArray  := 'This is a Test';
  86.      OtherArray := 'This is the other array';
  87.      OpenArrayProc(TestArray, OtherArray);
  88.      
  89.      
  90.      
  91.      At the call to ValueDemo the stack is set up as follows:
  92.      
  93.      
  94.                +---------+---------+
  95.      BP + 10H  | Max Index of      |
  96.                |         TestArray |
  97.                +---------+---------+
  98.                | Seg of TestArray  |
  99.                +---------+---------+
  100.      BP + 0CH  | Ofst of TestArray |
  101.                +---------+---------+
  102.      BP + 0AH  | Max Index of      |
  103.                |         OtherArray|
  104.                +---------+---------+
  105.                | Seg of OtherArray |
  106.                +---------+---------+
  107.      BP + 06H  | Ofst of OtherArray|
  108.                +---------+---------+
  109.      BP + 04H  |   Return Segment  |
  110.                +---------+---------+
  111.      BP + 02H  |  Address Offset   |
  112.                +---------+---------+
  113.      BP + 00H  |     Old  BP       |
  114.                +---------+---------+
  115.      
  116.      Figure 2. Procedure code and stack for a procedure whose arguments
  117.                 are open arrays.
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                                                                         3
  134.  
  135.  
  136.      FOREIGN DEFINITION MODULE NetNNN;
  137.      
  138.      (*
  139.      Title   : NetNNN
  140.      LastEdit: 4-May-88 13:33
  141.      Author  : J. C. Johnston
  142.      System  : Network Tools  No-wait Name Procedures
  143.      Compiler: LOGITECH MODULA-2 V3.03
  144.      *)
  145.      
  146.      FROM NetDefs IMPORT NetNameStr;
  147.      
  148.      EXPORT QUALIFIED
  149.        NNNADD, NNNADG, NNNRMV;
  150.      
  151.      
  152.        PROCEDURE NNNADD(VAR NTErr, NTErr1, Adapter : INTEGER;
  153.                         VAR NetName: NetNameStr;
  154.                         VAR NameNumber : INTEGER);
  155.        (* Alternate No-Wait Add a name *)
  156.                         
  157.        PROCEDURE NNNADG(VAR NTErr, NTErr1, Adapter: INTEGER;
  158.                         VAR GrpName : NetNameStr;
  159.                         VAR GrpNum  : INTEGER);
  160.        (* Alternate No-wait add a group name *)
  161.                         
  162.        PROCEDURE NNNRMV(VAR NTErr, NTErr1, Adapter : INTEGER;
  163.                         VAR NetName : NetNameStr);
  164.        (* Alternate No-wait Remove a group name *)
  165.      
  166.      END NetNNN.
  167.      
  168.      Figure 4. Example Definition Module for Network Tools code.
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.                                                                         4
  200.  
  201.  
  202.      
  203.      ;
  204.      
  205.      ; Notice that the following variable is in the code segment
  206.      ;
  207.      DStore    DW   ?                   ; hold the DS Register
  208.      ;
  209.      ;
  210.      L__FGDrawLines__IRISGraf PROC FAR               ;
  211.      ;
  212.      ;
  213.      ; PROCEDURE FGDrawLines(FrameNo, PointCount : CARDINAL;
  214.      ;                       VAR PointArray: ILUTArrayType): CARDINAL;
  215.      ;   (* draws a line through each point specified in the array *)
  216.      ;
  217.      ;
  218.      PArray    =    6
  219.      PCount    =    PArray+4
  220.      FrameNo   =    PCount+2
  221.      ;
  222.           PUSH BP
  223.           MOV  BP,SP
  224.           MOV  CS:DStore,DS             ;save the Current DS
  225.           MOV  AX,[BP]+FrameNo          ;get the parameter
  226.           PUSH AX                       ;push it
  227.           MOV  AX,[BP]+PCount           ;get the parameter
  228.           PUSH AX                       ;push it
  229.           LDS  AX,[BP]+PArray
  230.           PUSH DS
  231.           PUSH AX
  232.           CALL IS_DRAW_LINES            ;
  233.           MOV  DS,CS:DStore             ;get DS back
  234.           MOV  SP,BP                    ; reset stack pointer
  235.           POP  BP                       ;restore BP
  236.           RET  08H
  237.      ;
  238.      L__FGDrawLines__IRISGraf ENDP
  239.      
  240.      Figure 5. Building an Iris call from a Modula-2 call.
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.                                                                         1
  266.  
  267.  
  268.      PAGE ,132
  269.              .LALL
  270.      ;
  271.      ;IRISINIT - M2 Interface for DT-IRIS isinit module
  272.      ;-----------------
  273.      ;
  274.      ;Interface for Data Translation IRIS isinit Module
  275.      ;to LOGITECH MODULA Version 3
  276.      ;
  277.      ;       The purpose of this module is to provide an interface between
  278.      ;        the Logitech M2 compiler and the DT-IRIS library. The DT-IRIS
  279.      ;        library is written to link to the Microsoft Pascal Compiler.
  280.      ;        The library code, as supplied by Data Translation, assumes the
  281.      ;        use of FAR calls to reach the library functions and NEAR
  282.      ;        references to parameters passed by reference.
  283.      ;
  284.      ;       The Modula compiler uses FAR calls to communicate with procedures
  285.      ;        in external modules but passes parameters by reference using
  286.      ;        FAR references.
  287.      ;
  288.      ;       In an effort to correct for this mismatch, all of the variables
  289.      ;        passed from by reference between the DT-IRIS library and the
  290.      ;        Modula program will be defined in a seperate module. This
  291.      ;        should insure that all of the data will be in the same
  292.      ;        data segment.
  293.      ;
  294.      ;       Modula strings are ASCIIZ as are DT-IRIS strings. MS Pascal
  295.      ;        strings use the 0th element to hold the string length. If
  296.      ;        this presents a problem, it may have to be dealt with here also.
  297.      ;
  298.      ;
  299.      ;*****************************************************************
  300.      ;*                                                               *
  301.      ;*   Author:  Chris Johnston (March 1988)                        *
  302.      ;*              Microgravity Materials Science Laboratory        *
  303.      ;*              NASA Lewis Research Center                       *
  304.      ;*              21000 Brookpark Road    MS 105-1                 *
  305.      ;*              Cleveland, Ohio 44132                            *
  306.      ;*              (216) 433-5029                                   *
  307.      ;*                                                               *
  308.      ;*****************************************************************
  309.      ;
  310.      ;
  311.      ;
  312.              TITLE   IRISInit
  313.      ;
  314.      DGROUP  GROUP   DATA
  315.      ;
  316.      ;       Exported Procedures
  317.      ;       
  318.              PUBLIC  L__FGInit__IRISInit
  319.              PUBLIC  L__FGAbort__IRISInit
  320.              PUBLIC  L__FGConfig__IRISInit
  321.              PUBLIC  L__FGReset__IRISInit
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.                                                                         2
  332.  
  333.  
  334.              PUBLIC  L__FGEnd__IRISInit
  335.              PUBLIC  L__FGTest__IRISInit
  336.      ;
  337.      ;
  338.      ;       Initialization Entry point
  339.      ;       
  340.              PUBLIC  $INIT__IRISInit
  341.              PUBLIC  $BODY__IRISInit
  342.      ;
  343.      ;
  344.      ;       Exported Variables
  345.      ;
  346.      ; Cardinals
  347.      ;
  348.              PUBLIC  ExternTriggerStatus__IRISInit, IVal__IRISInit
  349.              PUBLIC  RedVal__IRISInit, GreenVal__IRISInit, BlueVal__IRISInit
  350.              PUBLIC  RowAddr__IRISInit, ColAddr__IRISInit, RowPos__IRISInit
  351.              PUBLIC  ColumnPos__IRISInit     
  352.      ;
  353.      ; Frame ID array
  354.      ;
  355.              PUBLIC  FrameID__IRISInit
  356.      ;
  357.      ; Long Integers
  358.      ;
  359.              PUBLIC  FGMemFailAddr__IRISInit, RsltSum__IRISInit
  360.      ;
  361.      ; Config Array
  362.      ;
  363.              PUBLIC  FGConfiguration__IRISInit
  364.      ;
  365.      ; ILUT arrays
  366.      ;
  367.              PUBLIC  PointArray__IRISInit
  368.              PUBLIC  ILUTArray__IRISInit, RedArray__IRISInit
  369.              PUBLIC  GreenArray__IRISInit, BlueArray__IRISInit
  370.      ;
  371.      ;
  372.      ; Bin Array
  373.      ;
  374.              PUBLIC  BinArray__IRISInit
  375.      ;
  376.      ; FGCA variables
  377.      ;
  378.              PUBLIC  CharArray__IRISInit
  379.      ;
  380.      ; Array Addresses
  381.      ;
  382.              PUBLIC   SourceArrayAddr__IRISInit, DestArrayAddr__IRISInit
  383.      ;
  384.      ; FileName String
  385.      ;
  386.              PUBLIC  FGFileName__IRISInit
  387.      ;
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.                                                                         3
  398.  
  399.  
  400.      ;
  401.              PUBLIC  $BM__IRISInit, $EM__IRISInit  ;beginning and end of module
  402.              PUBLIC  $BD__IRISInit, $BD__IRISInit  ;beginning and end of data
  403.      ;
  404.      ;       The symbol KEY__<dateSYMfile>_OF_<modulename> is needed for
  405.      ;        version checking and can be set to zero
  406.      ;       Do a:
  407.      ;        DIR IRISInit.SYM
  408.      ;        to get the time and date of compilation of the .DEF file
  409.      ;       Assemble with:
  410.      ;        ASMMOD IRISInit
  411.              
  412.              PUBLIC  KEY__13apr88_1005_OF_IRISInit
  413.      ;       
  414.      KEY__13apr88_1005_OF_IRISInit   EQU     0
  415.      ;
  416.      CR      =       0DH
  417.      ;
  418.      ;----------------------------------------------------------------------
  419.      ;
  420.      ;               External definitions
  421.      ;
  422.      ;----------------------------------------------------------------------
  423.      ;
  424.              EXTRN IS_INITIALIZE:FAR, IS_CONFIGURATION:FAR, IS_RESET:FAR
  425.              EXTRN IS_ABORT:FAR, IS_TEST:FAR, IS_END:FAR
  426.              EXTRN I$DRIVER_HANDLE:BYTE, I$FLAGS:BYTE, I$ERROR_TABLE_END:WORD
  427.              EXTRN I$MAX_BUFFERS_AVAILABLE:BYTE
  428.      ;
  429.      ;----------------------------------------------------------------------
  430.      ;
  431.      ;               Macro definitions
  432.      ;
  433.      ;----------------------------------------------------------------------
  434.      ;
  435.              IF1                             ;DEFINE ON FIRST PASS ONLY
  436.      SetCall MACRO                           ; set up for an IRIS call
  437.              PUSH    BP
  438.              MOV     BP,SP
  439.              MOV     CS:DStore,DS            ;Save the Current DS
  440.              MOV     AX,SEG I$FLAGS          ; get the segment of the IRIS data
  441.              MOV     DS,AX                   ; flag data and set up DS
  442.              ENDM
  443.      ;
  444.      SetVarCall      MACRO
  445.              PUSH    BP
  446.              MOV     BP,SP
  447.              MOV     CS:DStore,DS            ;save the Current DS
  448.              ENDM
  449.      ;
  450.      Recover MACRO
  451.              MOV     DS,CS:DStore            ;get DS back
  452.              MOV     SP,BP                   ; reset stack pointer
  453.              POP     BP                      ;restore BP
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.                                                                         4
  464.  
  465.  
  466.              ENDM
  467.      ;
  468.      RecoverVar      MACRO
  469.              MOV     SP,BP
  470.              POP     BP
  471.              ENDM
  472.              ENDIF
  473.      ;
  474.      ;
  475.      ;----------------------------------------------------------------------
  476.      ;
  477.      ;               Implementation Code for Modula 2/86
  478.      ;
  479.      ;----------------------------------------------------------------------
  480.      ;
  481.      ;
  482.      ;
  483.      IRISInit_TEXT SEGMENT BYTE PUBLIC 'CODE'
  484.              ASSUME  CS:IRISInit_TEXT
  485.              ASSUME  DS:NOTHING
  486.      ;
  487.      $BM__IRISInit:
  488.      ;
  489.      
  490.              ORG     0
  491.      ;
  492.      ;----------------------------------------------------------------------
  493.      ;
  494.      ;DSeg   LABEL   WORD
  495.      ;
  496.      ;
  497.      ;
  498.      DStore          DW      ?               ;space for DS storage
  499.      ;
  500.      ;VParam1        DW      ?               ;space for VALUE
  501.      ;VParam2        DW      ?               ;  Params
  502.      ;RParam1        DD      ?               ;Space for REFERENCE
  503.      ;RParam2        DD      ?               ;  long
  504.      ;RParam3        DD      ?               ;   pointers
  505.      ;
  506.      ;
  507.      ;**********************************************************************
  508.      ;
  509.      ;               Procedure Code
  510.      ;
  511.      ;**********************************************************************
  512.      ;
  513.      ;
  514.      L__FGInit__IRISInit     PROC FAR               ;INITIALIZE grabber
  515.      ;
  516.      ;
  517.      ; PROCEDURE FGInit(): CARDINAL;
  518.      ;  (* This procedure initializes the frame grabber *)
  519.      ;
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.                                                                         5
  530.  
  531.  
  532.              SetCall
  533.              CALL    IS_INITIALIZE           ;CALL IRIS Init
  534.              Recover
  535.              RET     
  536.      ;
  537.      L__FGInit__IRISInit     ENDP
  538.      ;
  539.      ;
  540.      L__FGAbort__IRISInit    PROC FAR            ;grabber ABORT
  541.      ;
  542.      ;
  543.      ; PROCEDURE FGAbort(): CARDINAL;
  544.      ;  (* This procedure causes an immediate abort of the
  545.      ;      current grabber function *)
  546.      ;
  547.      ;
  548.              SetCall
  549.              CALL    IS_ABORT                ;CALL IRIS ABORT
  550.              Recover
  551.              RET     
  552.      ;
  553.      L__FGAbort__IRISInit    ENDP
  554.      ;
  555.      ;
  556.      L__FGConfig__IRISInit   PROC FAR            ;report grabber CONFIG
  557.      ;
  558.      ;
  559.      ; PROCEDURE FGConfig(VAR FGConfiguration: FGConfArray): CARDINAL;
  560.      ;  (* this procedure returns the grabber configuration *)
  561.      ;
  562.      Array   =       6
  563.      ;
  564.              SetVarCall
  565.              LDS     DI,[BP]+Array
  566.              PUSH    DI
  567.      ;       MOV     AX,SEG I$FLAGS
  568.              CALL    IS_CONFIGURATION        ;call the IRIS routine
  569.              Recover
  570.              RET     04H
  571.      ;
  572.      L__FGConfig__IRISInit   ENDP
  573.      ;
  574.      ;
  575.      L__FGReset__IRISInit     PROC FAR            ;SEND
  576.      ;
  577.      ;
  578.      ; PROCEDURE FGReset(): CARDINAL;
  579.      ;  (* This procedure resets the frame grabber *)
  580.      ;
  581.      ;
  582.              SetCall
  583.              CALL    IS_RESET                ;reset the frame grabber
  584.              Recover
  585.              RET                             ;
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.                                                                         6
  596.  
  597.  
  598.      ;
  599.      L__FGReset__IRISInit    ENDP
  600.      ;
  601.      ;
  602.      L__FGEnd__IRISInit      PROC FAR    ;grabber END
  603.      ;
  604.      ;
  605.      ; PROCEDURE FGEnd(): CARDINAL;
  606.      ;  (* This procedure wipes out all connection to the grabber. It closes
  607.      ;      the channel to the device driver, and deallocates all frame buffers
  608.      ;      and temporary intermediate buffers *)
  609.      ;
  610.              SetCall
  611.              CALL    IS_END                  ;END it all
  612.              Recover
  613.              RET                             
  614.      ;
  615.      L__FGEnd__IRISInit      ENDP
  616.      ;
  617.      ;
  618.      L__FGTest__IRISInit     PROC FAR    ;grabber TEST
  619.      ;
  620.      ;
  621.      ; PROCEDURE FGTest(VAR FGMemFailAddr: LONGINT): CARDINAL;
  622.      ;  (* This procedure stops, tests and resets the grabber. The address
  623.      ;      of the first bad byte of menory is returned in FGMemFailAddr *)
  624.      ;
  625.      TAddr   =       6
  626.      ;
  627.              SetVarCall
  628.              LDS     DI,[BP]+TAddr           ;get address of variable
  629.              PUSH    DI                      ; push offest
  630.              CALL    IS_TEST                 ;CALL IRIS Test
  631.              Recover
  632.              RET     04H
  633.      ;
  634.      L__FGTest__IRISInit     ENDP
  635.      ;
  636.      ;
  637.      $BODY__IRISInit PROC FAR                ;module body code
  638.      ;
  639.              RET                             ;just leave
  640.      ;
  641.      $BODY__IRISInit ENDP
  642.      ;
  643.      ;
  644.      ;
  645.      $INIT__IRISInit PROC FAR        ;Module Init Code
  646.      ;
  647.              MOV     ax,0            ;CLEAR ax
  648.              MOV     I$FLAGS,AL      ;clear I$FLAGS
  649.              RET
  650.      ;
  651.      $INIT__IRISInit ENDP
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.                                                                         7
  662.  
  663.  
  664.      ;
  665.      ;
  666.      $EM__IRISInit:
  667.      ;
  668.      IRISInit_TEXT   ENDS
  669.      ;
  670.      ;
  671.      IRISInit_DATA   SEGMENT WORD PUBLIC 'FAR_BSS'
  672.              ASSUME  CS:IRISInit_TEXT
  673.      ;
  674.      $BD__IRISInit   LABEL FAR
  675.      
  676.      $ED__IRISInit   LABEL FAR
  677.      IRISInit_DATA   ENDS
  678.      ;
  679.      ;
  680.      ;       This DATA segment should be merged with the segment of
  681.      ;        the same name in isinit.obj
  682.      ;
  683.      DATA    SEGMENT WORD PUBLIC 'DATA'
  684.      ;
  685.      ExternTriggerStatus__IRISInit   DW  ?           ;Define the Cardinals
  686.      IVal__IRISInit                  DW  ?           ;
  687.      RedVal__IRISInit                DW  ?           ;
  688.      GreenVal__IRISInit              DW  ?           ;
  689.      BlueVal__IRISInit               DW  ?           ;
  690.      RowAddr__IRISInit               DW  ?           ;
  691.      ColAddr__IRISInit               DW  ?           ;
  692.      RowPos__IRISInit                DW  ?           ;
  693.      ColumnPos__IRISInit             DW  ?           ;
  694.      ;
  695.      FrameID__IRISInit               DW  2 DUP(?)    ;Frame ID type
  696.      ;
  697.      FGMemFailAddr__IRISInit         DD  ?           ;Long Integers
  698.      RsltSum__IRISInit               DD  ?           ;
  699.      ;
  700.      FGConfiguration__IRISInit       DW  20 DUP(?)   ;Configuration Array
  701.      ;
  702.      PointArray__IRISInit            DW  256 DUP(?)  ;Point Arrays
  703.      ILUTArray__IRISInit             DW  256 DUP(?)  ;ILUT Arrays
  704.      RedArray__IRISInit              DW  256 DUP(?)  ;
  705.      GreenArray__IRISInit            DW  256 DUP(?)  ;
  706.      BlueArray__IRISInit             DW  256 DUP(?)  ;
  707.      ;
  708.      BinArray__IRISInit              DD  256 DUP(?)  ;Bin Arrays
  709.      ;
  710.      CharArray__IRISInit             DB  256 DUP(?)  ;Char Array
  711.      ;
  712.      SourceArrayAddr__IRISInit       DD  ?           ;holds addresses
  713.      DestArrayAddr__IRISInit         DD  ?           ;
  714.      ;
  715.      FGFileName__IRISInit            DB  30 DUP(?)   ;holds the filename
  716.      ;
  717.      DATA    ENDS
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.                                                                         8
  728.  
  729.  
  730.      
  731.      INIT_FLAG_DATA SEGMENT WORD PUBLIC 'FAR_DATA'
  732.      ;
  733.      $FLAG__IRISInit DB      0
  734.      ;
  735.      INIT_FLAG_DATA  ENDS
  736.      ;
  737.              END
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.      DEFINITION MODULE BlockMove;
  797.      (*
  798.      Title   : BlockMove - Move Data to/from memory and frame grabber
  799.      LastEdit: 9-May-88 12:26
  800.      Author  : J. C. Johnston
  801.      System  : Telescience
  802.      Compiler: LOGITECH MODULA-2 V3.03
  803.      *)
  804.      
  805.      FROM SYSTEM IMPORT BYTE, ADDRESS;
  806.      
  807.      EXPORT QUALIFIED
  808.        BlockGDTType, GBlockAddress, BlockMoveGDT,
  809.        MoveMem2FG, MoveFG2Mem, AddArith;
  810.      
  811.      TYPE
  812.       BlockGDTType  = ARRAY[0..47] OF BYTE;
  813.      
  814.      VAR
  815.       GBlockAddress : ADDRESS;
  816.       BlockMoveGDT  : BlockGDTType;
  817.      
  818.      PROCEDURE MoveMem2FG(Source, Destination: ADDRESS; Length: CARDINAL);
  819.       (* This procedure set up and executes a block move from
  820.          system memory to the Frame Grabber memory *)
  821.      
  822.      PROCEDURE MoveFG2Mem(Source, Destination: ADDRESS; Length: CARDINAL);
  823.       (* This procedure set up and executes a block move from the Frame
  824.          Grabber memory to system memory *)
  825.      
  826.      PROCEDURE AddArith(VAR AddressArg: ADDRESS; Increment: CARDINAL);
  827.       (* This procedure adds the increment to AddressArg and returns the
  828.           new Address in AddredssArg. Use this procedure to do arithmetic
  829.           on ADDRESS type variables to handle overflow of the OFFSET into
  830.           the SEGMENT *)
  831.      
  832.      END BlockMove.
  833.      Figure 7a. Definition module for an assembly language module
  834.      -------------------------------------
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859. ;    Figure 7b - Assembly code for the BlockMove module 7b-1
  860.  
  861.  
  862.      ;
  863.      PAGE ,132
  864.           .LALL
  865.           .286
  866.      ;******************************************************************
  867.      ;       Module  :    BlockMove, move a block between DOS memory
  868.      ;               and Frame Grabber Memory
  869.      ;
  870.              TITLE    BlockMove
  871.      
  872.              PUBLIC  L__MoveMem2FG__BlockMove
  873.              PUBLIC  L__MoveFG2Mem__BlockMove
  874.              PUBLIC  L__AddArith__BlockMove
  875.      ;
  876.      ;    Set the KEY symbol to the compilation date for the def module.
  877.      ;     the compilation date can be obtained by executing the command:
  878.      ;    DIR BlockMove.sym
  879.      ;
  880.              PUBLIC  KEY__23may88_1724_OF_BlockMove
  881.      
  882.      KEY__23may88_1724_OF_BlockMove EQU 0
  883.      
  884.              PUBLIC  $INIT__BlockMove
  885.              PUBLIC  $BM__BlockMove, $EM__BlockMove
  886.              PUBLIC  $BD__BlockMove, $ED__BlockMove
  887.      
  888.      
  889.      BlockMove_TEXT SEGMENT BYTE PUBLIC 'CODE'
  890.                      ASSUME  CS:BlockMove_TEXT
  891.                      ASSUME  DS:NOTHING
  892.      $BM__BlockMove:
  893.      
  894.      ;-----------------------------------------------------------
  895.      L__MoveMem2FG__BlockMove PROC    FAR
  896.      ;-----------------------------------------------------------
  897.      ;
  898.      ;PROCEDURE MoveMem2FG(Source, Destination: ADDRESS; Length: CARDINAL);
  899.      ; (* This procedure set up and executes a block move from
  900.      ;    system memory to the Frame Grabber memory *)
  901.      ;
  902.      MLength        = 6
  903.      destination    = MLength + 2
  904.      source         = destination + 4
  905.      ;
  906.           PUSH BP
  907.           MOV  BP,SP
  908.           PUSH DS
  909.           PUSH AX
  910.           PUSH BX
  911.           PUSH CX
  912.           PUSH DX
  913.           MOV  AX, SEG BlockMove_DATA
  914.           MOV  DS,AX
  915.      ;
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925. ;    Figure 7b - Assembly code for the BlockMove module 7b-2
  926.  
  927.  
  928.           CALL S_SetFGRW__BlockMove     ; set the frame grabber to R/W
  929.      ;
  930.           LES  CX,[BP]+source
  931.           MOV  AX,ES               ;get ES into AX
  932.           SHL  AX,4                ;shift 4 bits
  933.           MOV  BX,ES               ;Move ES into BX
  934.           SHR  BX,12               ;shift high part
  935.           ADD  AX,CX               ;add offset and shifted source
  936.           ADC  BX,0                ;add BX with carry
  937.           MOV  SAddressL,AX        ;store the low source address
  938.           MOV  SAddressH,BL        ;store the high source address
  939.      ;
  940.           LES  CX,[BP]+destination
  941.           MOV  AX,ES               ;get ES into AX
  942.           SHL  AX,4                ;shift 4 bits
  943.           MOV  BX,ES               ;Move ES into BX
  944.           SHR  BX,12               ;shift high part
  945.           ADD  AX,CX               ;add offset and shifted destination
  946.           ADC  BX,00A0H            ;add BX and offset with carry
  947.           MOV  DAddressL,AX        ;store the low destination address
  948.           MOV  DAddressH,BL        ;store the high destination address
  949.      ;
  950.           MOV  AX,[BP]+MLength          ;get the length to move
  951.           MOV  SLength,AX               ;store it in the GDT
  952.           MOV  DLength,AX               ;store it in the GDT
  953.      ;
  954.           MOV  CX,AX                    ;load the length into CX
  955.           SHR  CX,1                     ; get the number of words
  956.           MOV  AX,GBlockAdrSeg          ;get the segment of the GDT
  957.           MOV  ES,AX                    ; into ES
  958.           MOV  SI,GBlockAddress__BlockMove
  959.           MOV  AH,87H                   ;get the command
  960.           INT  15H                 ;do the call
  961.      ;
  962.           CALL S__ResetFG__BlockMove    ;Reset the Frame Grabber planes
  963.           POP  DX
  964.           POP  CX
  965.           POP  BX
  966.           POP  AX
  967.           POP  DS
  968.           MOV  SP,BP
  969.           POP  BP
  970.           RET  0AH
  971.      
  972.      L__MoveMem2FG__BlockMove ENDP
  973.      
  974.      ;-----------------------------------------------------------
  975.      L__MoveFG2Mem__BlockMove PROC    FAR
  976.      ;-----------------------------------------------------------
  977.      ;
  978.      ;PROCEDURE MoveFG2Mem(Source, Destination: ADDRESS; Length: CARDINAL);
  979.      ; (* This procedure set up and executes a block move from
  980.      ;    system memory to the Frame Grabber memory *)
  981.      ;
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991. ;    Figure 7b - Assembly code for the BlockMove module 7b-3
  992.  
  993.  
  994.      MLength        = 6
  995.      destination    = MLength + 2
  996.      source         = destination + 4
  997.      ;
  998.           PUSH BP
  999.           MOV  BP,SP
  1000.           PUSH DS
  1001.           PUSH AX
  1002.           PUSH BX
  1003.           PUSH CX
  1004.           PUSH DX
  1005.           MOV  AX, SEG BlockMove_DATA
  1006.           MOV  DS,AX
  1007.      ;
  1008.           CALL S_SetFGRW__BlockMove     ; set the frame grabber to R/W
  1009.      ;
  1010.           LES  CX,[BP]+source
  1011.           MOV  AX,ES               ;get ES into AX
  1012.           SHL  AX,4                ;shift 4 bits
  1013.           MOV  BX,ES               ;Move ES into BX
  1014.           SHR  BX,12               ;shift high part
  1015.           ADD  AX,CX               ;add offset and shifted source
  1016.      ;    ADC  BX,00A4H            ;add BX with carry
  1017.           ADC  BX,00A0H            ;add BX with carry
  1018.           MOV  SAddressL,AX        ;store the low source address
  1019.           MOV  SAddressH,BL        ;store the high source address
  1020.      ;
  1021.           LES  CX,[BP]+destination
  1022.           MOV  AX,ES               ;get ES into AX
  1023.           SHL  AX,4                ;shift 4 bits
  1024.           MOV  BX,ES               ;Move ES into BX
  1025.           SHR  BX,12               ;shift high part
  1026.           ADD  AX,CX               ;add offset and shifted destination
  1027.           ADC  BX,0                ;add BX and offset with carry
  1028.           MOV  DAddressL,AX        ;store the low destination address
  1029.           MOV  DAddressH,BL        ;store the high destination address
  1030.      ;
  1031.           MOV  AX,[BP]+MLength          ;get the length to move
  1032.      ;    SHR  CX,1                     ; get the number of words
  1033.           MOV  SLength,AX               ;store it in the GDT
  1034.           MOV  DLength,AX               ;store it in the GDT
  1035.      ;
  1036.           MOV  CX,[BP]+MLength          ;load the length
  1037.           SHR  CX,1                     ; get the number of words
  1038.           MOV  AX,GBlockAdrSeg          ;get the segment of the GDT
  1039.           MOV  ES,AX                    ; into ES
  1040.           MOV  SI,GBlockAddress__BlockMove
  1041.           MOV  AH,87H                   ;get the command
  1042.           INT  15H                      ;do the call
  1043.      ;
  1044.           CALL S__ResetFG__BlockMove    ;Reset the Frame Grabber planes
  1045.           POP  DX
  1046.           POP  CX
  1047.           POP  BX
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057. ;    Figure 7b - Assembly code for the BlockMove module 7b-4
  1058.  
  1059.  
  1060.           POP  AX
  1061.           POP  DS
  1062.           MOV  SP,BP
  1063.           POP  BP
  1064.           RET  0AH
  1065.      
  1066.      L__MoveFG2Mem__BlockMove ENDP
  1067.      ;
  1068.      ;-----------------------------------------------------------
  1069.      L__AddArith__BlockMove PROC    FAR
  1070.      ;-----------------------------------------------------------
  1071.      ;
  1072.      ;PROCEDURE AddArith(VAR AddressArg: ADDRESS; Increment: CARDINAL);
  1073.      ; (* This procedure adds the increment to AddressArg and returns the
  1074.      ;     new Address in AddredssArg. Use this procedure to do arithmetic
  1075.      ;     on ADDRESS type variables to handle overflow of the OFFSET into
  1076.      ;     the SEGMENT *)
  1077.      ;
  1078.      Increment = 6
  1079.      AddressArg     = MLength + 2
  1080.      ;
  1081.           PUSH BP
  1082.           MOV  BP,SP
  1083.           PUSH AX
  1084.           PUSH BX
  1085.           PUSH CX
  1086.           PUSH DX
  1087.      ;
  1088.           LES  BX,[BP]+AddressArg  ;get the address of the parameter
  1089.           LES  BX,ES:[BX]          ;get the parameter itself
  1090.           MOV  AX,ES               ;get SEG into AX
  1091.           SHL  AX,4                ;shift SEG 4 bits left
  1092.           MOV  CX,ES               ;Move SEG into BX
  1093.           SHR  CX,12               ;isolate the high nybble
  1094.           ADD  AX,BX               ;add OFFSET (in BX) and Lshifted SEG
  1095.           ADC  CX,0                ;add Rshifted SEG and offset with carry
  1096.           MOV  BX,[BP]+Increment   ;get the increment
  1097.           ADD  AX,BX               ;Add it into the offset
  1098.           ADC  CX,0                ; Add the carry to the segment
  1099.      ;
  1100.           SHL  CX,12               ;shift it way over to make a SEG
  1101.      ;
  1102.           LES  BX,[BP]+AddressArg  ;get the address of the parameter
  1103.           MOV  ES:[BX],AX          ;put away the offset
  1104.           MOV  ES:[BX]+2,CX        ;store the offset
  1105.      ;
  1106.           POP  DX
  1107.           POP  CX
  1108.           POP  BX
  1109.           POP  AX
  1110.           MOV  SP,BP
  1111.           POP  BP
  1112.           RET  06H
  1113.      
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123. ;    Figure 7b - Assembly code for the BlockMove module 7b-5
  1124.  
  1125.  
  1126.      L__AddArith__BlockMove ENDP
  1127.      ;
  1128.      ;
  1129.      INSCR1         = 230H         ; Video Input Ctrl/Stat Reg 1
  1130.      INSCR2         = 232H         ; Video Input Control
  1131.      Mask1          = 0080H        ; mask the busy bit
  1132.      Mask2          = 0FFF0H       ; reset write protect bits
  1133.      ;
  1134.      ;
  1135.      S_SetFGRW__BlockMove     PROC NEAR ; set the frame grabber to R/W
  1136.      ;
  1137.      ;
  1138.           CALL S__WaitBusy__BlockMove   ; wait for the Busy Bit
  1139.           MOV  DX,INSCR2                ;get the address of Vid In Ctrl Port
  1140.           IN   AX,DX                    ;Read the Byte
  1141.           MOV  PortStore,AX             ;Save it
  1142.           AND  AX,Mask2                 ;clear the protection bits
  1143.           OUT  DX,AX                    ;and set the FG
  1144.           RET
  1145.      S_SetFGRW__BlockMove     ENDP
  1146.      ;
  1147.      ;
  1148.      ;
  1149.      S__ResetFG__BlockMove    PROC NEAR ; reset the frame grabber R/W mode
  1150.      ;
  1151.      ;
  1152.           CALL S__WaitBusy__BlockMove   ; wait for the Busy Bit
  1153.           MOV  DX,INSCR2                ;get the address of Vid In Ctrl Port
  1154.           MOV  AX,PortStore             ;get the stored port value
  1155.           OUT  DX,AX                    ;and set the FG
  1156.           RET
  1157.      S__ResetFG__BlockMove    ENDP
  1158.      ;
  1159.      ;
  1160.      ;
  1161.      S__WaitBusy__BlockMove   PROC NEAR ; reset the frame grabber R/W mode
  1162.      ;
  1163.      ;
  1164.                MOV  DX,INSCR1           ;get the address of Vid Ctrl Port
  1165.      BLoop:    IN   AX,DX               ;read the control port
  1166.                TEST AX,Mask1            ;Check for Busy
  1167.                JNZ  BLoop               ;loop till not busy
  1168.                RET
  1169.      S__WaitBusy__BlockMove   ENDP
  1170.      ;
  1171.      ;
  1172.      $INIT__BlockMove   PROC  FAR
  1173.      ;
  1174.      ;    Load the address of the BlockMoveGDT into GBlockAddress
  1175.      ;
  1176.           MOV  CX,SEG BlockMove_DATA                   ;GET SEGMENT OF DATA
  1177.           MOV  DS,CX                                   ;MOVE IT TO DS
  1178.           MOV  ES,CX                                   ;and ES
  1179.           MOV  BX,OFFSET BlockMoveGDT__BlockMove       ;GET OFFSET OF DATA
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189. ;    Figure 7b - Assembly code for the BlockMove module 7b-6
  1190.  
  1191.  
  1192.           MOV  ES:GBlockAddress__BlockMove, BX         ;STORE THE OFFSET
  1193.           MOV  ES:GBlockAdrSeg, DS ;STORE THE SEGMENT
  1194.      ;
  1195.      ;    Clear the GDT
  1196.      ;
  1197.                MOV  AX,SEG BlockMoveGDT__BlockMove     ;get segment of table
  1198.                MOV  BX,OFFSET BlockMoveGDT__BlockMove  ;get offset of table
  1199.                MOV  DS,AX                         ;load DS
  1200.                MOV  CX,2FH                        ;SET UP FOR 48 loops
  1201.                MOV  AL,0                          ; set to 0
  1202.      Init1:    MOV  [BX],AL                       ;clear the GDT
  1203.                INC  BX                            ;move the offset
  1204.                LOOP Init1                         ;Loop until done
  1205.      ;
  1206.      ;    Preset the access rights bytes to 93H
  1207.      ;
  1208.           MOV  AL, 93H                       ;setup access rights
  1209.           MOV  SAccessRights, AL             ;set the byte
  1210.           MOV  DAccessRights, AL             ;set the byte
  1211.      
  1212.           RET
  1213.      ;
  1214.      $INIT__BlockMove   ENDP
  1215.      $EM__BlockMove:
  1216.      BlockMove_TEXT ENDS
  1217.      
  1218.      BlockMove_DATA         SEGMENT WORD PUBLIC 'FAR_BSS'
  1219.                            ASSUME  CS : BlockMove_TEXT
  1220.      $BD__BlockMove         LABEL   FAR
  1221.      ;
  1222.      PortStore           DW   ?    ;temporary storage for port
  1223.      ;
  1224.      GBlockAddress__BlockMove DW   ?    ;holds an address
  1225.      GBlockAdrSeg             DW   ?
  1226.      ;
  1227.      ;    Dummy Descriptor
  1228.      ;
  1229.      BlockMoveGDT__BlockMove       DW   ?    ;DUMMY TABLE
  1230.                          DW   ?    ;
  1231.                          DB   ?    ;
  1232.                          DB   ?    ;
  1233.                          DW   ?    ;RESERVED
  1234.      ;
  1235.      ;    Descriptor for GDT
  1236.      ;
  1237.                          DW   ?    ;GDT Descriptor TABLE
  1238.                          DW   ?    ;
  1239.                          DB   ?    ;
  1240.                          DB   ?    ;
  1241.                          DW   ?    ;RESERVED
  1242.      ;
  1243.      ;    Source Descriptor Table
  1244.      ;
  1245.      SLength             DW   ?    ;source length
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255. ;    Figure 7b - Assembly code for the BlockMove module 7b-7
  1256.  
  1257.  
  1258.      SAddressL           DW   ?    ;bits 0-15 of source address
  1259.      SAddressH           DB   ?    ;bits 16-23 of source address
  1260.      SAccessRights       DB   ?    ;
  1261.                          DW   ?    ;RESERVED
  1262.      ;
  1263.      ;    Destination Descriptor Table
  1264.      ;
  1265.      DLength             DW   ?    ;destination length
  1266.      DAddressL           DW   ?    ;bits 0-15 of destination address
  1267.      DAddressH           DB   ?    ;bits 16-23 of Destination address
  1268.      DAccessRights       DB   ?    ;
  1269.                          DW   ?    ;RESERVED
  1270.      ;
  1271.      ;    BIOS CS Descriptor
  1272.      ;
  1273.                          DW   ?    ;table filled by BIOS
  1274.                          DW   ?    ;
  1275.                          DB   ?    ;
  1276.                          DB   ?    ;
  1277.                          DW   ?    ;RESERVED
  1278.      ;
  1279.      ;    stack segment descriptor
  1280.      ;
  1281.                          DW   ?    ;Table filled by BIOS
  1282.                          DW   ?    ;
  1283.                          DB   ?    ;
  1284.                          DB   ?    ;
  1285.                          DW   ?    ;RESERVED
  1286.      ;
  1287.      $ED__BlockMove         LABEL  FAR
  1288.      BlockMove_DATA         ENDS
  1289.      
  1290.              END
  1291.      Figure 7b. Assembly code for the module
  1292.      
  1293.