Guidance
指路人
g.yi.org
software / rapidq / Examples / ASM / rqasm / vector_asm.rq

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' Uses assembler code to calculate sum of 10000 vectors

     $RESOURCE VAddProc AS "vector.bin"

     DECLARE FUNCTION GetTickCount LIB "kernel32" ALIAS "GetTickCount" AS LONG
     DECLARE FUNCTION CallBinProc LIB "user32" ALIAS "CallWindowProcA" _
      (Proc AS LONG, A1 AS LONG, A2 AS LONG, A3 AS LONG, A4 AS LONG) AS LONG


' load the procedure into memory
     DIM VAdd AS QMEMORYSTREAM
     VAdd.ExtractRes(RESOURCE(VAddProc))

' prepare data
     DEFINT i, Tmr, Vectors(1 TO 30000), Result(1 TO 3)

     RANDOMIZE 666
     FOR i = 1 TO 30000
      Vectors(i) = RND * 10
     NEXT i

' calculate
     Tmr = GetTickCount
     CallBinProc VAdd.Pointer, 10000, VARPTR(Vectors(1)), VARPTR(Result(1)), 0
     Tmr = GetTickCount - Tmr

' display the result
     PRINT "The result is {", Result(1), ", ", Result(2), ", ", Result(3), "}"
     PRINT "Elapsed time: ", Tmr, " ms"
掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:42:30