Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Using .def with same name but different registers in indepen

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

Bascom Member



Joined: 03 Oct 2006
Posts: 40

germany.gif
PostPosted: Sun Aug 09, 2020 6:58 pm    Post subject: Using .def with same name but different registers in indepen Reply with quote

Hello

I have written 2 small Libs. In both i have defined an alias for a register. But the register are different.
Have a look at these 2 libs:

In lib 1 I've written
Code:
[Test1]
   .def rTmp = r18

   Test1:
      LDI rTmp,$11
      RET
[End]


and in the lib 2 I've written:
Code:
[Test2]
   .def rTmp = r16

   Test2:
      LDI rTmp,$22
      RET
[End]


In main-program both libs are included with "$LIB".

Wenn I call the routine test1 and test2 only register r18 ist set. Tested with simulator.
It seems so that only 1 alias (.def) ist used, not both.

Can I not use the same alias in diffrernt libs?

Then the Libs are compiled, then it works correct. But not with using the lib-file.

Is it not possible in Bascom?

(BASCOM-AVR version : 2.0.8.3 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5098
Location: Holland

blank.gif
PostPosted: Sun Aug 09, 2020 8:06 pm    Post subject: Reply with quote

the register def is global so you can not have the same name in multiple libs. that is correct.
_________________
Mark
Back to top
View user's profile Visit poster's website
Micha

Bascom Member



Joined: 03 Oct 2006
Posts: 40

germany.gif
PostPosted: Mon Aug 10, 2020 6:42 am    Post subject: Reply with quote

Ok.
But then .def ist global, why did not occur an Error then a name is already used?
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5098
Location: Holland

blank.gif
PostPosted: Mon Aug 10, 2020 11:27 am    Post subject: Reply with quote

that is a good question. i will check that.
a redefinition is allowed but a redefinition with a different register should raise an error.

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

Bascom Member



Joined: 03 Oct 2006
Posts: 40

germany.gif
PostPosted: Tue Aug 11, 2020 3:18 pm    Post subject: Reply with quote

Have you checked that?

Do you need a sample code?
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5098
Location: Holland

blank.gif
PostPosted: Tue Aug 11, 2020 9:17 pm    Post subject: Reply with quote

yes i checked it. and i changed it.
_________________
Mark
Back to top
View user's profile Visit poster's website
Micha

Bascom Member



Joined: 03 Oct 2006
Posts: 40

germany.gif
PostPosted: Wed Aug 12, 2020 8:33 am    Post subject: Reply with quote

Thank you!
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