View previous topic :: View next topic |
Author |
Message |
Madf
Joined: 13 Nov 2011 Posts: 179 Location: Moscow
|
Posted: Thu Sep 17, 2015 10:00 am Post subject: Used registers |
|
|
Hi.
Somewhere I saw, I can not find the information...
What are registers used by the compiler Bascom?
All completely R0 to R31?
Or are there that are not used and can be freely used in the assembler inserts (without saving)?
(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Sep 17, 2015 10:59 am Post subject: |
|
|
Hello,
Have a look in the help text "Mixing ASM and BASIC"
Using registers without saving/restoring them is very dangerous and not recommended. A small change to the compiler/libs could change the registers used.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
Madf
Joined: 13 Nov 2011 Posts: 179 Location: Moscow
|
Posted: Thu Sep 17, 2015 11:08 am Post subject: |
|
|
I've seen this page to "help".
There no exact information about it.
Long ago, it was discussed. It seems that it was a reservation R0-R16. I'm not sure, I do not remember. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Sep 17, 2015 11:29 am Post subject: |
|
|
make sure to read it again, it is written in the help topic Ian mentioned. _________________ Mark |
|
Back to top |
|
|
Madf
Joined: 13 Nov 2011 Posts: 179 Location: Moscow
|
Posted: Thu Sep 17, 2015 2:01 pm Post subject: |
|
|
"All other registers are used depending on the used statements." |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Sep 18, 2015 1:00 am Post subject: |
|
|
So what is so hard about saving a register ?
Push at the start of your assembler, pop at the end, making certain the pushes and pops match each other. Thats all there is to it. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Madf
Joined: 13 Nov 2011 Posts: 179 Location: Moscow
|
Posted: Fri Sep 18, 2015 8:51 am Post subject: |
|
|
Yes, it is difficult.
I have a big task on slow microcontrollers.
It is need to optimize the code. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri Sep 18, 2015 3:47 pm Post subject: |
|
|
Madf wrote: | What are registers used by the compiler Bascom? |
These are the registers, which must not to be touched:
Quote: | R4, R5 (frame pointer)
R6 (Flags)
R8, R9 (data pointer)
Y (R28,R29 - stack pointer) |
i.dobson wrote: | Using registers without saving/restoring them is very dangerous and not recommended. A small change to the compiler/libs could change the registers used. |
That's wrong, in regular non-ISR code it's a "don't care", beside the registers mentioned above, of course.
If a Bascom built in routine has ended, all other registers can be destroyed without effect. R6, R8 & R9 can be destroyed, if no Read-commands or no error-reports of certain Bascom-routines are required.
In an ISR it's different however, there all registers used by own code need to be saved and restored. |
|
Back to top |
|
|
Madf
Joined: 13 Nov 2011 Posts: 179 Location: Moscow
|
Posted: Fri Sep 18, 2015 4:06 pm Post subject: |
|
|
If use only the initialization of Bascom periphery and the core code in assembler, then I think we can neglect registers Bascom.
Thank you all for your help.
Clarity some appeared. |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sun Sep 20, 2015 11:23 pm Post subject: |
|
|
If you do that, then yes, you can ignore what regs Bascom uses, since in effect you are not using it at all.
However unless your are doing something really time critical over the whole program, I doubt you will see much speed improvement over what Bascom can do. Bascom code is pretty well optimised already.
Only if you can contain most of the variables you work on in registers, and avoid transferring back and forth to SRAM, will you see much speed improvement. This only works in very special types of program. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Madf
Joined: 13 Nov 2011 Posts: 179 Location: Moscow
|
Posted: Mon Sep 21, 2015 9:07 am Post subject: |
|
|
AdrianJ wrote: | I doubt you will see much speed improvement over what Bascom can do. Bascom code is pretty well optimised already. |
In the settings optimization option is enabled, but ...
Not really. For example, if the transfer of SPI variables more than one byte, Bascom this operation are substantially slower than I've written in assembly language (especially for sending, there is a delay between bytes).
Or no some functions, such as: sending 5-8 channels of UART (simultaneously). |
|
Back to top |
|
|
|