I've just been trying to use avra, but it outputs coff or something, so obdump has trouble disassembling it. I am also not sure how to link the result(ihex have no symbol info). So now I believe the thing is next to unusable. Someone correct me if I am wrong, plz. Are there any other, usable alternatives to Gas that have usable macro constructs (+labels)?
[AVR] What assembler to use?
Started by ●June 16, 2018
Reply by ●June 17, 20182018-06-17
On 16/06/18 09:37, Johann Klammer wrote:> I've just been trying to use avra, but it outputs coff or something, > so obdump has trouble disassembling it. I am also not sure > how to link the result(ihex have no symbol info). > So now I believe the thing is next to unusable. > Someone correct me if I am wrong, plz. > Are there any other, usable alternatives to Gas that have usable > macro constructs (+labels)? >Why do you want an alternative to gas? It does pretty much everything you could want from an assembler, as far as I know. It is a long time since I have seen much need to write whole programs in assembly - C (or even C++) is just so much more efficient when your task is to write correct, readable, maintainable code in a reasonable amount of development time.
Reply by ●June 18, 20182018-06-18
On 06/17/2018 07:29 PM, David Brown wrote:> > Why do you want an alternative to gas? It does pretty much everything you could want from an assembler, as far as I know. > > It is a long time since I have seen much need to write whole programs in assembly - C (or even C++) is just so much more efficient when your task is to write correct, readable, maintainable code in a reasonable amount of development time. >gas can't handle labels inside macros, and gcc had disappeared nops the last time I wrote sthg timing critical. So I'm looking for alternatives now and then. (I just need a macro assembler) At closer inspection it seems that avra only supports absolute addresses... so using it together with ld won't work... would have to rewrite parts of it for that... The weird thing is that they have an example in their repository which consists of multiple asm files, but I can't tell how that would be compiled down to a single hex, as it basically outputs 1 hex for 1 asm.
Reply by ●June 18, 20182018-06-18
On 18.6.18 10:07, Johann Klammer wrote:> On 06/17/2018 07:29 PM, David Brown wrote: >> >> Why do you want an alternative to gas? It does pretty much everything you could want from an assembler, as far as I know. >> >> It is a long time since I have seen much need to write whole programs in assembly - C (or even C++) is just so much more efficient when your task is to write correct, readable, maintainable code in a reasonable amount of development time. >> > gas can't handle labels inside macros, and gcc had disappeared nops > the last time I wrote sthg timing critical. > So I'm looking for alternatives now and then. > (I just need a macro assembler) > > At closer inspection it seems that avra only supports > absolute addresses... so using it together with ld won't work... > would have to rewrite parts of it for that... > > The weird thing is that they have an example in their > repository which consists of multiple asm files, but I > can't tell how that would be compiled down to a single hex, > as it basically outputs 1 hex for 1 asm. >Did you declare the gcc nop as volatile? There are instructions in the manual stating that. -- -TV
Reply by ●June 18, 20182018-06-18
On 18/06/18 09:07, Johann Klammer wrote:> On 06/17/2018 07:29 PM, David Brown wrote: >> >> Why do you want an alternative to gas? It does pretty much >> everything you could want from an assembler, as far as I know. >> >> It is a long time since I have seen much need to write whole >> programs in assembly - C (or even C++) is just so much more >> efficient when your task is to write correct, readable, >> maintainable code in a reasonable amount of development time. >> > gas can't handle labels inside macros,Yes it can. Use ".altmacro" instead of ".macro", and you can make local names and labels using "LOCAL name". You can also use numeric local labels, or \@ for a macro invocation number.> and gcc had disappeared nops > the last time I wrote sthg timing critical.gcc does not remove nops if you write them correctly - but it does remove useless code if it is not marked appropriately. Post some code, and I can see if I can help. Note that you don't need an assembler if you are mixing assembly and C - inline assembly within the C code is usually sufficient for the few snippets of code that you need in assembly.> So I'm looking for > alternatives now and then. (I just need a macro assembler) > > At closer inspection it seems that avra only supports absolute > addresses... so using it together with ld won't work... would have to > rewrite parts of it for that... > > The weird thing is that they have an example in their repository > which consists of multiple asm files, but I can't tell how that would > be compiled down to a single hex, as it basically outputs 1 hex for 1 > asm. >
Reply by ●June 18, 20182018-06-18
Johann Klammer wrote:> > [...] > The weird thing is that they have an example in their > repository which consists of multiple asm files, but I > can't tell how that would be compiled down to a single hex, > as it basically outputs 1 hex for 1 asm.Are you sure that the files are not simply included and the result then processed in a single assembler run?
Reply by ●June 18, 20182018-06-18
On 06/18/2018 09:27 AM, David Brown wrote:> > Yes it can. > > Use ".altmacro" instead of ".macro", and you can make local names and > labels using "LOCAL name". You can also use numeric local labels, or > \@ for a macro invocation number. >LOCAL seems to work... I remember having problems with the numeric labels before...nesting? It's maybe best to just forget about avra then...
Reply by ●June 18, 20182018-06-18
On 18/06/18 09:18, Tauno Voipio wrote:> On 18.6.18 10:07, Johann Klammer wrote: >> On 06/17/2018 07:29 PM, David Brown wrote: >>> >>> Why do you want an alternative to gas? It does pretty much >>> everything you could want from an assembler, as far as I know. >>> >>> It is a long time since I have seen much need to write whole programs >>> in assembly - C (or even C++) is just so much more efficient when >>> your task is to write correct, readable, maintainable code in a >>> reasonable amount of development time. >>> >> gas can't handle labels inside macros, and gcc had disappeared nops >> the last time I wrote sthg timing critical. >> So I'm looking for alternatives now and then. >> (I just need a macro assembler) >> >> At closer inspection it seems that avra only supports >> absolute addresses... so using it together with ld won't work... >> would have to rewrite parts of it for that... >> >> The weird thing is that they have an example in their >> repository which consists of multiple asm files, but I >> can't tell how that would be compiled down to a single hex, >> as it basically outputs 1 hex for 1 asm. >> > > Did you declare the gcc nop as volatile? > > There are instructions in the manual stating that. >An extended syntax inline asm statement doesn't actually need to be declared volatile if there is no output, so this is okay: asm ("nop" :::) However, I think it is good practice to include the "volatile". It is also important to note that compiler can re-order and re-arrange assembly instructions and other code, within certain limitations. If the OP can post the code he was trying to use, I am confident that we can help him out with the correct syntax. (Of course, he could just read the manual - the avr-libc documentation has a lot of useful information. But sometimes it can be hard to digest.)
Reply by ●June 18, 20182018-06-18
On 18/06/18 10:40, Johann Klammer wrote:> On 06/18/2018 09:27 AM, David Brown wrote: >> >> Yes it can. >> >> Use ".altmacro" instead of ".macro", and you can make local names and >> labels using "LOCAL name". You can also use numeric local labels, or >> \@ for a macro invocation number. >> > LOCAL seems to work... I remember having problems > with the numeric labels before...nesting? >If you have nested macros in your assembly with multiple loops, you are probably over-complicating things.> It's maybe best to just forget about avra then... >I'd say so, yes. But I would also recommend forgetting about gas - and forgetting about writing code in assembly. You need a really god reason to be writing anything more than tiny snippets in assembly these days.
Reply by ●June 18, 20182018-06-18
On Mon, 18 Jun 2018 10:18:09 +0300, Tauno Voipio wrote:> gas can't handle labels inside macros,I think that's incorrect---you can use local numeric labels, or if you use asm() inline assembly, you can use autogeneration with %= http://www.nongnu.org/avr-libc/user-manual/inline_asm.html#asm_macros