View previous topic :: View next topic |
Author |
Message |
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Mon Apr 21, 2014 9:32 pm Post subject: Used Registers |
|
|
Hi everybody,
Again I'm in trouble keeping my IRQ-Routine short enough to execute before the next timer interrupt. What would help is the nosave-option and using registers instead of SRAM-variables. But to do this I need to know exactly which registers (more than the sreg) I need to push/pop manually and which I could use for my stuff.
Out of the BASCOM help:
Some registers are used by BASCOM
R4 and R5 are used to point to the stack frame or the temp data storage
R6 is used to store some bit variables:
R6 bit 0 = flag for integer/word conversion
R6 bit 1 = temp bit space used for swapping bits
R6 bit 2 = error bit (ERR variable)
R6 bit 3 = show/noshow flag when using INPUT statement
R8 and R9 are used as a data pointer for the READ statement.
All other registers are used depending on the used statements.
"Depending on the used statements". Well!
Is there any overview available which tells my which register is used by what? Including the libraries, maybe?
Does anybody know about an article like "saving mcu-cycles with bascom"? I've just found out that "if bytevar > 0 then" needs 2 more clocks than "if bytevar <> 0 then"...
Thanks for your help
Ralph
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
Neill
Joined: 08 Dec 2008 Posts: 50
|
Posted: Tue Apr 22, 2014 3:14 am Post subject: |
|
|
I use the AVR Studio software to look at the .obj file that Bascom outputs.
Using Studio you can view your code as assembly language line by line. You will see which registers are manipulated.
Here is a link to the latest version
http://www.atmel.com/microsite/atmel_studio6/
However if you can get hold of an earlier version like 4.x The new version is massive and uses .NET. For what you want version 4 would be fine. |
|
Back to top |
|
|
ViacheslavMezentsev
Joined: 28 Oct 2013 Posts: 16
|
Posted: Tue Apr 22, 2014 10:47 pm Post subject: |
|
|
In this project, I kept all the registers.
You can use this utility to view the assembler listing of the object file (objdump -S myproject.obj).
r29:r28 - pointer to swstack.
For ISR I think it is enough to save: r5:r4 (frames), r6 (status), r8, r9, r29:28 (swstack). If using other registers, then they must be saved too. _________________ Russia forever!
Viacheslav N. Mezentsev |
|
Back to top |
|
|
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Wed Apr 23, 2014 7:24 am Post subject: |
|
|
Hi Neill, hi Viacheslav,
Thank you very much for your replies. So I have to disassemble to see used registers... Whew! Hoped to avoid this...
Neill, I've downloaded AVR Studio 4. Nice result so far, even though it freaks out when it comes to data lines.
Viacheslav, your tool is great and small and quite easy to use. I like the comments in AVR Studio but the lst files do have their advantage, too.
Well, let's work through assembler stuff...
Thanks
Ralph |
|
Back to top |
|
|
ViacheslavMezentsev
Joined: 28 Oct 2013 Posts: 16
|
Posted: Wed Apr 23, 2014 10:53 am Post subject: |
|
|
Thanks, Ralph. In the new version I'll add comments too. _________________ Russia forever!
Viacheslav N. Mezentsev |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Wed Apr 23, 2014 11:38 am Post subject: Re: Used Registers |
|
|
That's a lot of complicated software you guys are posting here to do something that can be done VERY easy in Bascom.
Rahalph wrote: |
"Depending on the used statements". Well!
Is there any overview available which tells my which register is used by what? Including the libraries, maybe?
|
This is only necessary for the used statements in your isr.
To determine what registers are used in the isr, simple step ( F8 ) trough your program in Bascom simulator and watch the register window which register become red (changed) when your entering the isr.
These register are used by the statements in the isr and need to be pushed on the stack. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Wed Apr 23, 2014 2:59 pm Post subject: |
|
|
Hi Evert,
Thanks for your message. You're right, to find out which registers are changed in my ISR (and to know what needs to be pushed), I can use Bascom. That is, btw., what I already did.
The question regarding the overview was more, because I wanted to USE registers instead of SRAM-Variables. So I need to know what registers Bascom uses in the rest of my code. And I don't want to step through all of that stuff...
I've already found that Bascom has a lot of registers in use. The only free ones are R6, R8, R9 and R12-R15. These are, btw., the only registers that Bascom doesn't push by default. Maybe R2, R3 and R7 are also free. They are pushed by default but they don't seem to be used in MY program.
Meanwhile I've changed my code using registers and pushing only needed stuff. My ISR turned out half as long as it originally was and is now fast enough and it works.
Thank you all for your help!!!
Ralph |
|
Back to top |
|
|
ViacheslavMezentsev
Joined: 28 Oct 2013 Posts: 16
|
Posted: Wed Apr 23, 2014 8:25 pm Post subject: |
|
|
Quote: | Viacheslav, your tool is great and small and quite easy to use. I like the comments in AVR Studio but the lst files do have their advantage, too. |
Comments added.
_________________ Russia forever!
Viacheslav N. Mezentsev |
|
Back to top |
|
|
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Thu Apr 24, 2014 6:36 am Post subject: |
|
|
Hi Viacheslav,
Great Work! Can you provide a zip file for download? Downloading each single file of the source code is a bit annoying...
Could you make the parameter "-S" case-insensitve, too?
Another parameter (maybe "-nolc") could delete the line comments of the original code. Because you indent the Bascom-code a lot the comments wrap into the next line when printing the lst-file. But only the comments behind the Bascom code, not the comment lines...
*As better the tool, as more wishes there are*
Regards
Ralph |
|
Back to top |
|
|
ViacheslavMezentsev
Joined: 28 Oct 2013 Posts: 16
|
Posted: Thu Apr 24, 2014 10:10 am Post subject: |
|
|
Rahalph wrote: | Hi Viacheslav,
Great Work! Can you provide a zip file for download? Downloading each single file of the source code is a bit annoying... |
Use TortoiseSVN for download sources. They placed in the svn repository.
Rahalph wrote: |
Could you make the parameter "-S" case-insensitve, too?
|
Wiki:
objdump (part of the GNU Binutils) is a program for displaying various information about object files. For instance, it can be used as a disassembler to view executable in assembly form. It is part of the GNU Binutils for fine-grained control over executable and other binary data.
-s - reserved:
Code: | objdump [-a|--archive-headers]
[-b bfdname|--target=bfdname]
[-C|--demangle[=style] ]
[-d|--disassemble]
[-D|--disassemble-all]
[-z|--disassemble-zeroes]
[-EB|-EL|--endian={big | little }]
[-f|--file-headers]
[--file-start-context]
[-g|--debugging]
[-e|--debugging-tags]
[-h|--section-headers|--headers]
[-i|--info]
[-j section|--section=section]
[-l|--line-numbers]
[-S|--source]
[-m machine|--architecture=machine]
[-M options|--disassembler-options=options]
[-p|--private-headers]
[-r|--reloc]
[-R|--dynamic-reloc]
[-s|--full-contents]
[-W|--dwarf]
[-G|--stabs]
[-t|--syms]
[-T|--dynamic-syms]
[-x|--all-headers]
[-w|--wide]
[--start-address=address]
[--stop-address=address]
[--prefix-addresses]
[--[no-]show-raw-insn]
[--adjust-vma=offset]
[--special-syms]
[-V|--version]
[-H|--help]
objfile... |
Only -S works for now.
Rahalph wrote: |
Another parameter (maybe "-nolc") could delete the line comments of the original code. Because you indent the Bascom-code a lot the comments wrap into the next line when printing the lst-file. But only the comments behind the Bascom code, not the comment lines... |
I'll think about it. _________________ Russia forever!
Viacheslav N. Mezentsev |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Mon Aug 04, 2014 2:08 am Post subject: |
|
|
Hi Viacheslav,
I tried to download your OBJDUMP.EXE, but the website is not responding...
Please you can post the utility again ?
Thanks !
Paulo |
|
Back to top |
|
|
|