View previous topic :: View next topic |
Author |
Message |
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sat Mar 31, 2018 10:33 am Post subject: How to pass label address to sub or function? |
|
|
How do I pass label address to sub or function to read data?
Regards Paul
(BASCOM-AVR version : 2.0.8.1 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sat Mar 31, 2018 2:36 pm Post subject: |
|
|
ByLabel maybe? |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Wed Apr 04, 2018 11:16 am Post subject: |
|
|
Thankyou MWS
But that was not working until I worked out the error in the example
No ! before the assembler code
But this only works for chips up to 64K how to do it above that?
Would be good to have it work on all chips.
Regards Paul |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Apr 04, 2018 11:39 am Post subject: |
|
|
you can use : Var = LOADLABEL(label )
when var is a DWORD, it will be loaded with the proper 24 bit address
the dword you can pass as usual. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Apr 04, 2018 12:03 pm Post subject: |
|
|
Paulvk wrote: | But this only works for chips up to 64K how to do it above that? |
Depends on...
If data fits within the first 64kB, simply keep it there, place it first and jump over it.
User-code coming first is compiled first and put first in flash, no difference is made between $data and code.
Don't put an 'end' to the end of your code, otherwise you get errors about not placing data at the end.
Code: | ' startup code
Goto DataEnd
$Data 1, 2, 3, 4, 5
DataEnd: |
If it's lots of data, then it may be better to swap it to an external file.
Code: | ' startup code
Goto DataEnd
$Include "datalines.bas"
DataEnd: |
Another way would to extend ByLabel with the RAMPZ-info, not sure if can made to work cleanly.
Third option is to ask Mark.
Surly depends on how important/urgent your requirement is, how many others will need it, a.s.o., thus whether there's an benefit for all. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Apr 04, 2018 12:19 pm Post subject: |
|
|
albertsm wrote: | the dword you can pass as usual. |
Maybe one should mention, that an dword address alone means little, if the command in question can not handle it.
Correct me in case I miss something, because I did not compile/check.
For the ByLabel-sample it should look somehow like that:
Code: | Dim DW As DWord
' ...
Sub Somesub(Mylabel As DWord)
DW = Mylabel ' this points to the BYTE address of the
data
!Lds _dptrl,{DW} ' point to
!LDS _dptrh,{DW+1}
!LDS RAMPZ,{DW+2}
Read B : Print B
End Sub |
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Apr 04, 2018 12:26 pm Post subject: |
|
|
from the help for loadlabel : When you assign a DWORD variable, the 24 bit address will be loaded into the variable.
which means the page is loaded as well.
it was improved in 2080 so you might have missed it. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Apr 04, 2018 1:09 pm Post subject: |
|
|
albertsm wrote: | which means the page is loaded as well. |
Oh, this was already perfectly to understand from your reply, my concern was about my virtual extension of the ByLabel-sample.
Quote: | it was improved in 2080 so you might have missed it. |
Missed an actual bascavr.pdf, as more ver 2.0.8.1 seems not to download it into the ...\MCS Electronics\BASCOM-AVR\PDF folder. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Apr 04, 2018 1:21 pm Post subject: |
|
|
your sample seems ok.
the pdf you can get with tools, pdf update _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Apr 04, 2018 1:55 pm Post subject: |
|
|
albertsm wrote: | your sample seems ok. |
Good
Quote: | the pdf you can get with tools, pdf update |
Ok, noticed.
Thanks. |
|
Back to top |
|
|
|