Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

How to pass label address to sub or function?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat Mar 31, 2018 10:33 am    Post subject: How to pass label address to sub or function? Reply with quote

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
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sat Mar 31, 2018 2:36 pm    Post subject: Reply with quote

ByLabel maybe?
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Wed Apr 04, 2018 11:16 am    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Apr 04, 2018 11:39 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Apr 04, 2018 12:03 pm    Post subject: Reply with quote

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
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Apr 04, 2018 12:19 pm    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Apr 04, 2018 12:26 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Apr 04, 2018 1:09 pm    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Apr 04, 2018 1:21 pm    Post subject: Reply with quote

your sample seems ok.
the pdf you can get with tools, pdf update

_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Apr 04, 2018 1:55 pm    Post subject: Reply with quote

albertsm wrote:
your sample seems ok.

Good Very Happy
Quote:
the pdf you can get with tools, pdf update

Ok, noticed.
Thanks.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum