View previous topic :: View next topic |
Author |
Message |
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Tue Mar 26, 2019 3:08 pm Post subject: Memcopy |
|
|
Hi all. I'm doing a routine to remove data (word) from a table and I want to use Memcopy. I did the following example and it does not work for me, I think that memcopy can copy forward as backwards. Any ideas.
Thank you very much and best regards.
Code: |
$regfile = "m2560def.dat"
$crystal = 20000000
$hwstack = 100
$swstack = 100
$framesize = 100
Dim Buf As String * 5 , Aux_word As Word , Aux1 As Byte , Str1(5) As String * 1
Dim Tabla_rx_tx_addr(20) As Word
Dim Origen As Word , Destino As Word , Bytes As Word , Cantidad As Word
Aux1 = 1
For Aux_word = 1 To 20
Tabla_rx_tx_addr(aux_word) = Aux1
Print Tabla_rx_tx_addr(aux_word)
Incr Aux1
Next Aux_word
For Aux_word = 1 To 20
If Tabla_rx_tx_addr(aux_word) = 8 Then
Goto Borrar1
End If
Next Aux_word
Borrar1:
Print Varptr(tabla_rx_tx_addr(20))
Destino = Varptr(tabla_rx_tx_addr(aux_word))
Origen = Varptr(tabla_rx_tx_addr(aux_word + 1))
Cantidad = 20 - Aux_word
Print Cantidad
Cantidad = Cantidad * 2
Print Cantidad
Print Destino
Print Origen
Bytes = Memcopy(origen , Destino , Cantidad)
Print Bytes
For Aux_word = 1 To 20
Print Tabla_rx_tx_addr(aux_word)
Next Aux_word
|
(BASCOM-AVR version : 2.0.8.1 ) |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Wed Mar 27, 2019 3:51 am Post subject: |
|
|
Thank you very much EDC, it works perfectly.
But you can tell me what I did wrong with my code, I used Memcopy on other occasions and I have not had any problems.
Best regards. |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Wed Mar 27, 2019 7:37 am Post subject: |
|
|
Code: | Bytes = Memcopy(origen , Destino , Cantidad) |
This code not work like you suppose. Variables Origen and Destino contain address of the other variable but this no mather and Memcopy takes their addresses (adresses of the Origen and Destino). |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Wed Mar 27, 2019 1:13 pm Post subject: |
|
|
Thank you. |
|
Back to top |
|
|
|