home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_10 / DEVPAC56.ZIP / MATMULT5.S56 < prev    next >
Text File  |  1993-12-20  |  2KB  |  105 lines

  1. ;
  2. ;    MATMULT5.S56 Matrix multiplication as a subroutine
  3. ;    part of the HiSoft DevpacDSP tutorial.
  4. ;    (c) Copyright HiSoft 1993
  5. ;      All rights reserved.
  6.  
  7. HSR    equ    $ffe9
  8. HRX    equ    $ffeb
  9.  
  10. abuffer    equ    $3f00        ; subroutine workspace
  11. bbuffer    equ    $3f00
  12. N    equ     4
  13.     org    P:0
  14. start
  15. ; disable modulo arithmetic
  16.     move    #-1,M0
  17.     move    #-1,M1
  18.     move    M0,M2
  19.     move    M0,M4
  20.     move    M0,M5
  21.  
  22.     movep    X:<<HRX,R0
  23.     
  24.     move    #<Fixed-1,N1
  25.     move    R0,R1
  26.     move    #Fixer+1,N0
  27.     move    (R1)+N1
  28.     movem    R1,P:(R0+N0)
  29.     
  30.     move    #>FixTable,N0
  31.     NOP
  32.     LUA    (R0)+N0,R2    ;point to fix up table
  33. Fixer
  34.     Do    #(FixEnd-FixTable)/2,Fixed
  35.     Movem    P:(R2)+,N1
  36.     move    R0,R1
  37.     movem    P:(R2)+,N0
  38.     move    (R1)+N1
  39.     movem    R1,P:(r0+n0)
  40. Fixed    
  41.         
  42. ; read in the A array from the host port
  43.     move    #abuffer,R0
  44. RefFirstloop
  45.     DO    #N*N,firstloop
  46. ; what until a word is ready
  47. get_first
  48.     jclr    #0,X:HSR,get_first
  49.     movep    X:HRX,X0
  50.     move    X0,X:(R0)+
  51. firstloop    
  52.  
  53. ; read in the B array from the host port
  54.     move    #bbuffer,R0
  55. RefSecondLoop
  56.     DO    #N*N,secondloop
  57. get_second
  58.     jclr    #0,X:HSR,get_second    ; if no data jump to the top
  59.     movep    X:HRX,X0
  60.     move    X0,Y:(R0)+
  61. secondloop    
  62.  
  63. ; do sums here
  64.     move    #bbuffer,R5
  65.     move    #N,N0    
  66.     move    #N,N5
  67. Refiloop
  68.     do    #N,iloop
  69.     move    #abuffer,R1    
  70. Refjloop
  71.     do    #N,jloop
  72.     move    R5,R4
  73.     clr    a         R1,R0    
  74. Refkloop
  75.     do    #N,kloop
  76.     move    X:(R0)+N0,X0    Y:(R4)+,Y0
  77.     mac    x0,y0,A
  78. kloop
  79.     move    (R1)+
  80. ; Now send A    - first A2 then A1    
  81. pxmit    jclr    #1,X:HSR,pxmit
  82.  
  83.     movep    A2,X:HRX
  84. pxmit2    jclr    #1,X:HSR,pxmit2
  85.  
  86.     movep    A1,X:HRX
  87. jloop
  88.     lua    (R5)+N5,R5
  89. iloop
  90.     rti
  91.                 ; Get command from host port
  92.  
  93. FixTable
  94.     dc    firstloop-1,RefFirstloop+1
  95.     dc    get_first,get_first+1
  96.     dc    secondloop-1,RefSecondloop+1
  97.     dc    get_second,get_second+1
  98.     dc    iloop-1,Refiloop+1
  99.     dc    jloop-1,Refjloop+1
  100.     dc    kloop-1,Refkloop+1
  101.     dc    pxmit,pxmit+1
  102.     dc    pxmit2,pxmit2+1
  103. FixEnd        
  104.     end
  105.