[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] How to stop avr-gcc from replacing my code with ellipsis
From: |
Omar Choudary |
Subject: |
Re: [avr-chat] How to stop avr-gcc from replacing my code with ellipsis |
Date: |
Tue, 22 May 2012 13:11:35 +0100 |
Thanks a lot.
Yes David, that is exactly what I needed.
I don't really need a delay, I am interested in doing some power
measurements and therefore I want a precise sequence of instructions,
including NOPs.
I have been using both assembler inlined in C code and an aseembler
file. The code I shown earlier was from an assembler (.S) file,
compiled with avr-gcc.
The listing file is generated by applying avr-objdump on the resulting
.elf file.
With the --disassemble-zeros switch I get what I want:
4dac: 2f 93 push r18
4dae: 2f b7 in r18, 0x3f ; 63
4db0: f8 94 cli
4db2: 00 00 nop
4db4: 00 00 nop
4db6: 00 00 nop
4db8: 00 00 nop
4dba: 00 00 nop
4dbc: 00 00 nop
4dbe: 00 00 nop
4dc0: 00 00 nop
4dc2: 00 00 nop
4dc4: 00 00 nop
4dc6: 86 9a sbi 0x10, 6 ; 16
4dc8: 8e 9a sbi 0x11, 6 ; 17
4dca: 00 00 nop
4dcc: 00 00 nop
4dce: 00 00 nop
4dd0: 00 00 nop
4dd2: 00 00 nop
4dd4: 00 00 nop
4dd6: 00 00 nop
4dd8: 00 00 nop
4dda: 00 00 nop
4ddc: 00 00 nop
4dde: 2f bf out 0x3f, r18 ; 63
4de0: 2f 91 pop r18
4de2: 08 95 ret
Using inline assembler it seems that I also get what I wanted:
asm volatile("nop\n\t"
d34: 00 00 nop
d36: 00 00 nop
d38: 00 00 nop
d3a: 00 00 nop
d3c: 00 00 nop
d3e: 00 00 nop
d40: 00 00 nop
"nop\n\t"
"nop\n\t"
::);
asm volatile("sbi %[port], %[bit]" "\n\t"
d42: 86 9a sbi 0x10, 6 ; 16
:/* NO OUTPUTS */
:[port] "I" (_SFR_IO_ADDR(VPORT0.DIR)), [bit] "I" (PIN6_bp)
);
asm volatile("sbi %0, %1" "\n\t"
d44: 8e 9a sbi 0x11, 6 ; 17
:/* NO OUTPUTS */
:"I" (_SFR_IO_ADDR(VPORT0.OUT)), "I" (PIN6_bp)
);
asm volatile("nop"::);
d46: 00 00 nop
asm volatile("nop"::);
d48: 00 00 nop
asm volatile("nop"::);
d4a: 00 00 nop
asm volatile("nop"::);
d4c: 00 00 nop
}
d4e: 08 95 ret
I feel that for my purposes using the assembler file seems clearer,
but it looks like both approaches are equally fine.
Thanks,
Omar
On Mon, May 21, 2012 at 8:23 PM, Weddington, Eric
<address@hidden> wrote:
>
>
>> -----Original Message-----
>> From: address@hidden [mailto:avr-chat-
>> address@hidden On Behalf Of David Kelly
>> Sent: Monday, May 21, 2012 1:20 PM
>> To: address@hidden
>> Subject: Re: [avr-chat] How to stop avr-gcc from replacing my code with
>> ellipsis
>>
>>
>> On May 21, 2012, at 1:43 PM, Weddington, Eric wrote:
>>
>> > Hi Omar,
>> >
>> > How are you writing and compiling your code?
>>
>> He said,
>> >> However when the code is compiled I get the following in the listing
>> >> file (generated with avr-objdump):
>
> Sure, but just because somebody says it's compiled doesn't mean that it is.
> It could have been "assembled" using the assembler directly.
>
>>
>> The NOPs are there, the addresses jump properly.
>>
>> Reading the man page for avr-objdump I suspect this is the switch he wants:
>>
>> -z
>> --disassemble-zeroes
>> Normally the disassembly output will skip blocks of zeroes. This
>> option directs the disassembler to disassemble those blocks, just
>> like any other data.
>>
>
> Oh, you're very probably correct! :-)
>
> Eric
>
> _______________________________________________
> AVR-chat mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/avr-chat