home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH08 / XPRODUCT.ASM < prev   
Encoding:
Assembly Source File  |  1994-10-24  |  2.2 KB  |  105 lines

  1. ; XProduct.ASM-
  2. ;
  3. ;    This file contains the cross-product module.
  4.  
  5.         .386
  6.         option    segment:use16
  7.  
  8.         .nolist
  9.         include        stdlib.a
  10.         includelib    stdlib.lib
  11.         .list
  12.  
  13.         include    matrix.a
  14.  
  15. ; Local variables for this module.
  16.  
  17. dseg        segment    para public 'data'
  18. DV        dword    ?
  19. RowNdx        integer    ?
  20. ColNdx        integer    ?
  21. RowCntr        integer    ?
  22. ColCntr        integer    ?
  23. dseg        ends
  24.  
  25.  
  26. cseg        segment    para public 'code'
  27.         assume    ds:dseg
  28.  
  29. ; CrossProduct- Computes the cartesian product of two vectors.
  30. ;        On entry:
  31. ;
  32. ;            FS:BP-    Points at the row matrix.
  33. ;            GS:BX-    Points at the column matrix.
  34. ;            DS:CX-    Points at the dope vector for the destination.
  35. ;
  36. ;        This code assume ds points at dseg.
  37. ;        This routine only preserves the segment registers.
  38.  
  39. RowMat        textequ    <fs:[bp]>
  40. ColMat        textequ    <gs:[bx]>
  41. DVP        textequ    <ds:[bx].DopeVec>
  42.  
  43. CrossProduct    proc    near
  44.  
  45.         ifdef    debug
  46.         print
  47.         char    "Entering CrossProduct routine",cr,lf,0
  48.         endif
  49.  
  50.         xchg    bx, cx        ;Get dope vector pointer
  51.         mov    ax, DVP.Dim1    ;Put Dim1 and Dim2 values
  52.         mov    RowCntr, ax    ; where they are easy to access.
  53.         mov    ax, DVP.Dim2
  54.         mov    ColCntr, ax
  55.         xchg    bx, cx
  56.  
  57.  
  58. ; Okay, do the cross product operation.  This is defined as follows:
  59. ;
  60. ;    for RowNdx := 0 to NumRows-1 do
  61. ;        for ColNdx := 0 to NumCols-1 do
  62. ;        Result[RowNdx, ColNdx] = Row[RowNdx] op Col[ColNdx];
  63.  
  64.         mov    RowNdx, -1    ;Really starts at zero.
  65. OutsideLp:    add    RowNdx, 1
  66.         mov    ax, RowNdx
  67.         cmp    ax, RowCntr
  68.         jge    Done
  69.  
  70.         mov    ColNdx, -1    ;Really starts at zero.
  71. InsideLp:    add    ColNdx, 1
  72.         mov    ax, ColNdx
  73.         cmp    ax, ColCntr
  74.         jge    OutSideLp
  75.  
  76.         mov    di, RowNdx
  77.         add    di, di
  78.         mov    ax, RowMat[di]
  79.  
  80.         mov    di, ColNdx
  81.         add    di, di
  82.         mov    dx, ColMat[di]
  83.  
  84.         push    bx        ;Save pointer to column matrix.
  85.         mov    bx, cx        ;Put ptr to dope vector where we can
  86.                     ; use it.
  87.  
  88.         call    DVP.Func    ;Compute result for this guy.
  89.  
  90.         mov    di, RowNdx    ;Index into array is
  91.         imul    di, DVP.Dim2    ; (RowNdx*Dim2 + ColNdx) * ElementSize
  92.         add    di, ColNdx
  93.         imul    di, DVP.ESize
  94.  
  95.         les    bx, DVP.Data    ;Get base address of array.
  96.         mov    es:[bx][di], ax    ;Save away result.
  97.  
  98.         pop    bx        ;Restore ptr to column array.
  99.         jmp    InsideLp
  100.  
  101. Done:        ret
  102. CrossProduct    endp
  103. cseg        ends
  104.         end
  105.