Bmove and BlockMove Commands

Purpose

Copies an area of memory.

Syntax

BMove from%, to%, count%
BlockMove from%, to%, count%

from%, to%:address
count:integer expression

Description

BMove and BlockMove are synonymous and are used to copy memory areas. The copy is performed from address from% to the address to%. The number of bytes to copy is specified in count%.

Example

OpenW # 1

Local i%, j%

Local Double a(3, 3), b(3, 3)

For i% = 0 To 3

For j% = 0 To 3

a(i%, j%) = Random(2000 - 1000)

Next j%

Next i%

Print "BEFORE:"

Print

Print "Array a()"

Print

Mat Print a()

Print "-----------------"

Print "Array b()"

Print

Mat Print b()

Print

BMove V:a(0, 0), V:b(0, 0), Dim?(a()) * 8

Print "AFTER BMove:"

Print

Print "Array a()"

Print

Mat Print a()

Print "-----------------"

Print "Array b()"

Print

Mat Print b()

First, two arrays are dimensioned. Array a() is then filled with random numbers. V: a(0,0) returns the address of the first element in a(), V: b(0,0) the first element in b(). Each floating point variable requires eight bytes of memory. The number of elements in a() is deter-mined with Dim?(a()). Dim?(a())*8 returns then the number of bytes to be copied.

Remarks

The copying of array a() into array b() in the above example can also be done with

For i% = 0 To 3

For j% = 0 To 3

b(i%, j%) = a(i%, j%)

Next j%

Next i%

The BMove and BlockMove commands, however, requires less memory and are - depending on the contents being copied - up to 100 times faster.

See Also

MemCpy

{Created by Sjouke Hamstra; Last updated: 11/01/2017 by James Gaite}