
  'Example of matrix layout mapped to an array of 4x4 cells
  '
  '  0 4 8 C
  '  1 5 9 D
  '  2 6 A E
  '  3 7 B F
  '

  '----------------------------------------
  sub MatrixMul(MatrixType *a,*b,*c, sys n)
  '========================================
  '
  '
  #if typecodeof a=0x64
    % OneStep 4
    % ColStep 16
    % mtype single
  #endif
  '
  #if typecodeof a=0x68
    % OneStep 8
    % ColStep 32
    % mtype double
  #endif

  sys pa=@a, pb=@b, pc=@c

  mov ecx,pa
  mov edx,pb
  mov eax,pc

  mov esi,n
  (
  call column : dec esi : jg repeat
  )
  exit sub

  column:
  '======

  mov edi,n
  (
  call cell : dec edi : jg repeat
  )
  add edx,ColStep
  sub ecx,ColStep
  ret

  cell: ' row A * column B
  '=======================

  'matrix data is stored ascending vertically then horizontally
  'thus rows are minor, columns are major
  '
  push  ecx
  push  edx
  push  eax
  mov   eax,4
  fldz
  (
  fld   mtype [ecx]
  fmul  mtype [edx]
  faddp st1
  add   ecx,ColStep 'next column of matrix A
  add   edx,OneStep 'next row of matrix B
  dec eax
  jnz repeat
  )
  pop eax
  fstp mtype [eax] 'assign to next row of matrix C
  '
  pop edx
  pop ecx
  add   eax,OneStep 'next cell in column of matrix C (columns then rows)
  add   ecx,OneStep 'next row of matrix A
  ret
  '
  end sub

       

  '-----------------------------------------------
  sub getrow4S(MatrixType* matrix, MarixType *row)
  '===============================================
  '
  indexbase 0
  row<=matrix[0],matrix[4],matrix[8],matrix[12]
  end sub


  