Search |
 |
|
 |
| Author |
Message |
|
|
Posted: Feb 12, 2012 - 10:47 PM |
|

Joined: Jul 16, 2009
Posts: 1579
|
|
Hi,
Code:
unsigned char Compare(struct AnalyzeType *AFirst, struct AnalyzeType *ASecond)
{
unsigned long ul1;
unsigned long long ull1,ull2;
unsigned char dp1,dp2;
if (AFirst->result>ASecond->result)
return COMP_MORE;
if (AFirst->result<ASecond->result)
return COMP_LESS;
if (AFirst->result==RESULT_UL || AFirst->result==RESULT_OL)
return COMP_EQUAL;
ull1=AFirst->frequency;
dp1=AFirst->dp;
ull2=ASecond->frequency;
dp2=ASecond->dp;
while (dp1<dp2)
{
ul1=1;
while (dp1<dp2 && ul1<1000000000)
{
ul1*=10;
dp1++;
}
ull1*=ul1;
}
while (dp2<dp1)
{
ul1=1;
while (dp2<dp1 && ul1<1000000000)
{
ul1*=10;
dp2++;
}
ull2*=ul1;
}
if (ull1>ull2)
return COMP_MORE;
if (ull1<ull2)
return COMP_LESS;
return COMP_EQUAL;
}
From the LSS there is a CLI at 77a:
Code:
unsigned char Compare(struct AnalyzeType *AFirst, struct AnalyzeType *ASecond)
{
74e: 2f 92 push r2
750: 3f 92 push r3
752: 4f 92 push r4
754: 5f 92 push r5
756: 6f 92 push r6
758: 7f 92 push r7
75a: 8f 92 push r8
75c: 9f 92 push r9
75e: af 92 push r10
760: bf 92 push r11
762: cf 92 push r12
764: df 92 push r13
766: ef 92 push r14
768: ff 92 push r15
76a: 0f 93 push r16
76c: 1f 93 push r17
76e: df 93 push r29
770: cf 93 push r28
772: cd b7 in r28, 0x3d ; 61
774: de b7 in r29, 0x3e ; 62
776: 2e 97 sbiw r28, 0x0e ; 14
778: 0f b6 in r0, 0x3f ; 63
77a: f8 94 cli
77c: de bf out 0x3e, r29 ; 62
77e: 0f be out 0x3f, r0 ; 63
780: cd bf out 0x3d, r28 ; 61
782: fc 01 movw r30, r24
784: 7b 01 movw r14, r22
Is this related to this mystery?
Code:
static __inline__ void __iSeiParam(const uint8_t *__s)
{
sei();
Why are interrupts being disabled for a function call?
Thanks,
Alan |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 10:54 PM |
|


Joined: Jul 23, 2001
Posts: 2438
Location: Osnabrueck, Germany
|
|
|
Quote:
Why are interrupts being disabled for a function call?
The function uses a stack frame and manipulates the stack pointer for that purpose. This manipulation is not atomic and therefore needs to be protected. Interrupts are disabled for only 2 clock cycles. |
_________________ Stefan Ernst
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 11:04 PM |
|

Joined: Jul 16, 2009
Posts: 1579
|
|
Hi,
I see, thanks for the information!
Thanks,
Alan |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 11:09 PM |
|


Joined: Dec 21, 2006
Posts: 1483
Location: Saar-Lor-Lux
|
|
Notice that IRQ status is restored by OUT 0x3f,*
0x3f is SREG.
You get more information by studying the assembler output instead of disassembly: The compiler prints the more enlightning
Code:
in __tmp_reg__,__SREG__
cli
out __SP_H__,r29
out __SREG__,__tmp_reg__
out __SP_L__,r28
Notice that setting I in SREG has a latency of 1 instruction in non-XMEGA — no matter if that happens by SEI, OUT, ST* or RETI. |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 11:17 PM |
|

Joined: Jul 16, 2009
Posts: 1579
|
|
Hi SprinterSB,
Where is the assembler output found? Do you mean something different than the LSS file?
Thanks,
Alan |
|
|
| |
|
|
|
|
|
Posted: Feb 13, 2012 - 12:19 AM |
|

Joined: Oct 29, 2006
Posts: 2651
|
|
|
alank2 wrote:
Where is the assembler output found? Do you mean something different than the LSS file?
If you use -save-temps , you will get a .s file as a sibling of each .o file. |
_________________ Michael Hennebry
Iluvatar is the better part of Valar.
|
| |
|
|
|
|
|
Posted: Feb 13, 2012 - 02:16 AM |
|

Joined: Nov 28, 2004
Posts: 3552
Location: San Diego, Ca
|
|
|
skeeve wrote:
alank2 wrote:
Where is the assembler output found? Do you mean something different than the LSS file?
If you use -save-temps , you will get a .s file as a sibling of each .o file.
If using Studio 4 , go to Configure options -> custom settings -> "all files" and add --save-temps . |
_________________ 1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1
|
| |
|
|
|
|
|
Posted: Feb 13, 2012 - 09:48 AM |
|


Joined: Jul 18, 2005
Posts: 62305
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
Or if using an Mfile template for foo.c use
Code:
make foo.s
to simply generate the compiler's Asm source for that file.
Whether you do this or go the --save-temps route (I use the latter) you may well find that the addition of -fverbose-asm to the CFLAGS is very enlightening as the Asm is then annotated in comments with details of the compiler's internal view of what's going on. For example:
Code:
#include <avr/io.h>
uint8_t i;
int main(void) {
DDRB = 0xFF;
while(1) {
PORTB = i++;
}
}
without -fverbose-asm:
Code:
.file "test.c"
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__CCP__ = 0x34
__tmp_reg__ = 0
__zero_reg__ = 1
.text
.Ltext0:
.global main
.type main, @function
main:
.LFB2:
.LM1:
/* prologue: function */
/* frame size = 0 */
.LM2:
ldi r24,lo8(-1)
out 55-32,r24
lds r24,i
.L2:
.LM3:
out 56-32,r24
subi r24,lo8(-(1))
rjmp .L2
.LFE2:
.size main, .-main
.comm i,1,1
with -fverbose-asm:
Code:
.file "test.c"
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__CCP__ = 0x34
__tmp_reg__ = 0
__zero_reg__ = 1
; GNU C (WinAVR 20100110) version 4.3.3 (avr)
; compiled by GNU C version 3.4.5 (mingw-vista special r3), GMP version 4.2.3, MPFR version 2.4.1.
; GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
; options passed: -fpreprocessed test.i -mmcu=atmega16 -auxbase-strip
; test.o -gdwarf-2 -Os -Wall -Wstrict-prototypes -std=gnu99
; -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
; -fverbose-asm
; options enabled: -falign-loops -fargument-alias -fauto-inc-dec
; -fbranch-count-reg -fcaller-saves -fcommon -fcprop-registers
; -fcrossjumping -fcse-follow-jumps -fdefer-pop -fearly-inlining
; -feliminate-unused-debug-types -fexpensive-optimizations
; -fforward-propagate -ffunction-cse -fgcse -fgcse-lm
; -fguess-branch-probability -fident -fif-conversion -fif-conversion2
; -finline-functions -finline-functions-called-once
; -finline-small-functions -fipa-pure-const -fipa-reference -fivopts
; -fkeep-static-consts -fleading-underscore -fmath-errno
; -fmerge-constants -fmerge-debug-strings -fmove-loop-invariants
; -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls
; -fpack-struct -fpeephole -fpeephole2 -freg-struct-return -fregmove
; -freorder-functions -frerun-cse-after-loop -fsched-interblock
; -fsched-spec -fsched-stalled-insns-dep -fsigned-zeros
; -fsplit-ivs-in-unroller -fsplit-wide-types -fstrict-aliasing
; -fstrict-overflow -fthread-jumps -ftoplevel-reorder -ftrapping-math
; -ftree-ccp -ftree-copy-prop -ftree-copyrename -ftree-dce
; -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im
; -ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=
; -ftree-reassoc -ftree-salias -ftree-scev-cprop -ftree-sink -ftree-sra
; -ftree-store-ccp -ftree-ter -ftree-vect-loop-version -ftree-vrp
; -funit-at-a-time -fvar-tracking -fverbose-asm -fzero-initialized-in-bss
.text
.Ltext0:
; Compiler executable checksum: 61d68a374065d489330774d2533cbbdf
.global main
.type main, @function
main:
.LFB2:
.LM1:
/* prologue: function */
/* frame size = 0 */
.LM2:
ldi r24,lo8(-1) ; tmp47,
out 55-32,r24 ; ,, tmp47
lds r24,i ; i_lsm.7, i
.L2:
.LM3:
out 56-32,r24 ; ,, i_lsm.7
subi r24,lo8(-(1)) ; i_lsm.7,
rjmp .L2 ;
.LFE2:
.size main, .-main
.comm i,1,1
|
_________________
|
| |
|
|
|
|
|
|
|
|