PDA

View Full Version : Copying one array to another



cc1984
- 22nd September 2010, 18:53
Maybe a dumb question, but here goes anyway:
Is there a way to copy bit one array to another?

I know this method:

g VAR bit[8]
h VAR bit[8]

for i=0 to 7
h(i)=g(i)
next i

I looked at the ARRAYWRITE command, but it says from one byte array to another.

What would be the result of: h=g ?
I tried the h=g method in my code, but I don't think it is working. If anyone can help...Thanks.

aratti
- 22nd September 2010, 22:35
Since your bit array is a byte long use the byte instead.

G VAR BYTE
H VAR BYTE


G = H

Byte H now is equal to Byte G and you can extract the bits indexing the byte

G bit 0 = G.0
G bit 1 = G.1
.
.
.
.
.
G bit 7 = G.7

Naturally the same apply to byte H.

Cheers


Al.

cc1984
- 23rd September 2010, 10:06
Al,
That's how I started, and then I changed to the bit array so that I could do the following:

for i=0 to 7
out_sig=g(i)
pauseus 450
out_sig=g(i+1)
pauseus 50
next i

not sure how to do the same with a byte array, since when using the byte array I can't use a variable to reference the bits .... g.0-g.7 can't be expressed as g.(i)...
Thoughts? Thanks for the reply!

HenrikOlsson
- 23rd September 2010, 12:09
Hi,


G VAR BYTE
i VAR BYTE

For i = 0 to 7
out_sig = G.0[i]
NEXTI think that should do it.

/Henrik.

cc1984
- 23rd September 2010, 14:16
Looks like that works!

Da VAR BYTE
Ea VAR BYTE
i VAR BYTE
Da=%10011100

Ea=Da

FOR i=0 to 6 STEP 2
out_sig=Ea.0(i)
PAUSEUS 100
out_sig=Ea.0(i+1)
pauseus 100
NEXT i

Thanks for you help!