[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] subroutine and 8bit types...
From: |
Dmitry |
Subject: |
[avr-gcc-list] subroutine and 8bit types... |
Date: |
Wed, 10 Oct 2001 13:42:09 +0400 |
Fellows,
I have a question about compiler attributes and so.
First of all - small part of code:
=========================================
#include <inttypes.h>
uint32_t __last;
uint32_t getlast()
{
return __last;
}
==========================================
the avr-gcc produces:
---------------------------------
.text
.global getlast
.type getlast,@function
getlast:
/* prologue: frame size=0 */
/* prologue end (size=0) */
lds r24,__last
lds r25,(__last)+1
lds r26,(__last)+2
lds r27,(__last)+3
mov r22,r24
mov r23,r25
mov r24,r26
mov r25,r27
/* epilogue: frame size=0 */
ret
/* epilogue end (size=1) */
/* function getlast size 13 (12) */
-----------------------------------
It seems to me that there are little overhead:
The subroutine returns value of __last in registers r22-r25.
But it loads r24-r27 first and the moves them ro r22-r25.
"lds" allows to load data from data space to any register. So, it seems to me
that
uint32_t getlast()
{
asm volatile(
"lds r22,__last \n\t"
"lds r23,(__last)+1 \n\t"
"lds r24,(__last)+2 \n\t"
"lds r25,(__last)+3 "
);
}
will be more efficient. But compiler complains about void return.
The question is: is it possible to tell the compiler, that within a particular
call only
r22-r25 must be used ?
Thanks in advance
*********************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys
(_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 3148860, 5585314
*********************************************************************
- [avr-gcc-list] subroutine and 8bit types...,
Dmitry <=