home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_10 / DEVPAC56.ZIP / MATMULT3.BAS < prev    next >
BASIC Source File  |  1993-12-20  |  1KB  |  55 lines

  1. '  Tutorial program MATMULT3.BAS supplied with DevpacDSP
  2. '  (c) Copyright HiSoft 1993
  3. '  All rights reserved
  4.  
  5. DEFINT a-z
  6. REM    $NOFNSINLIBS
  7. LIBRARY "falcon"
  8. CONST n=4
  9.  
  10. DEFSNG a-c
  11.  
  12. DIM c(N-1,N-1),c1&(N-1,N*2-1)
  13. abil=Dsp_RequestUniqueAbility
  14.  
  15. IF Dsp_lock THEN
  16.         PRINT "DSP is already in use"
  17.         STOP
  18. END IF
  19. IF Dsp_reserve(&h40+N*N,&h1000+N*N*2) THEN
  20.     PRINT "Can't reserve enough DSP RAM"
  21.     STOP
  22. END IF
  23.  
  24. OPEN "matmult3.p56" FOR INPUT AS #1
  25. progsize&=LOF(1)\3
  26. buffer$=INPUT$(progsize&*3,#1)
  27. CLOSE #1
  28. 'now run the program
  29. '    progsize&=Dsp_LodToBinary&("MATMULT3.LOD",SADD(buffer$))
  30.     Dsp_Execprog SADD(buffer$),progsize&,abil
  31.  
  32. ' get the results back as unpacked long words
  33.     Dsp_BlkUnpacked 0,0,VARPTR(c1&(0,0)),N*N*2
  34. ' now convert them to floating point
  35. FOR i=0 TO N-1
  36.     FOR j=0 TO N-1
  37.     c(i,j)=c1&(i,j*2)*2+c1&(i,j*2+1)/&h800000
  38.     NEXT j
  39. NEXT i
  40.  
  41. Dsp_Unlock
  42.  
  43. showmat c()
  44.  
  45. SUB showmat(c(2))
  46. FOR j= 0 TO N-1
  47.     FOR i=0 TO N-1
  48.         PRINT c(i,j),
  49.     NEXT i
  50.     PRINT
  51. NEXT j
  52. PRINT
  53.  
  54. END SUB
  55.