|
Prev: Loop back fails
Next: china wholesale cheap nike air max 87 90 95 ltd tn shoes bapesta hogan sneakers china suppliers www.voguesonline.net
From: David Brown on 23 Apr 2008 19:43 cbarn24050(a)aol.com wrote: > On Apr 23, 10:03 pm, David Brown > <david.br...(a)hesbynett.removethisbit.no> wrote: >> cbarn24...(a)aol.com wrote: >>> On Apr 23, 7:27�pm, Walter Banks <wal...(a)bytecraft.com> wrote: >>>> Stefan Reuther wrote: >>>>>> register_sp SP; >>>>>> SP = int_value; >>>>> What you're doing here is writing assembly with C syntax. It relies upon >>>>> a heavily non-standard language extension, and makes assumptions about >>>>> how the compiler behaves (you don't want the compiler to use the stack >>>>> before your SP assignment, do you?). So instead of writing assembly in >>>>> C, I prefer using the real thing. >>> Yes, thats what he always does! He can then claim his compiler can >>> beat assembler for speed,code size ect. To Walter if it looks Cish, >>> ends in a semicolon and his compiler can change it into machine code >>> then its C. >>>> I actually agree with you it is very low level C. The purpose of ISO/IEC >>>> 18037 was to define the low level syntax. Most start up code is very processor >>>> family specific. �Writting start up code in C makes good use of C's >>>> optimization like the branch/jump to main. >>> Whats to optimise? Why bother optimising a one time instruction? >>> Sometimes I think you'll say anything to sell a compiler. >> Why would you bother optimising a traditional call to main into a jump? >> On some targets (in particular, several that Bytecraft target), the >> saved stack space is significant - and even the couple of saved flash >> bytes is worth doing (given the negligible cost of the compiler's effort). > > If it is on your project you are allready are allready up a certain > creek without a paddle. In any event you wouldnt use a "traditional" > ie a C type call to main from startup so stack saveing would be > minimal. > First off, Walter writes compilers and their associated libraries - saving a few bytes of stack space there means savings for all his users. We are not talking about individual projects here. Secondly, some processors have small fixed-size hardware stacks (small PIC's and AVR Tiny's are examples). For such devices, a single unnecessary "call" can waste a third of your stack resources.
From: David Brown on 23 Apr 2008 19:45 CBFalconer wrote: > Walter Banks wrote: > ... snip ... >> In our case the first C compiler was written for the C6805 >> and that was based on a 6805 mistral compiler we had written >> a few years earlier. Our initial startup code was written >> in C on a compiler that would support it. >> >> register_sp SP; >> >> SP = int_value; > > In other words you seized a user available identifier, register_sp, > and then recognized that in the code to accept an int_value and > initialize the stack pointer. This is not C, but an extension. > The only thing wrong with that is that it is not marked as an > extension. If the mechanism is also used to read the SP the above > declaration should mark it as volatile. I think it would be better > to use a name reserved for the implementation, such as > __register_sp. > > I am not objecting to extensions. However I believe they should > minimize any effects on standard C. > Personally, I prefer to avoid extra underscores - they make the code look ugly. But it's important that it is possible (through compiler flags and/or choice of include files) to disable any extensions not marked with double underscores.
From: compton75 on 23 Apr 2008 19:53 On Apr 22, 3:50 am, Lax <Lax.Cla...(a)gmail.com> wrote: > Are there any situations where programming an embedded processor > "requires" at least some assembly code? > > How about for AVR, MSP430, 68HC11, 8051(Atmel)? > Can these 4 microcontrollers be programmed fully in C without touching > assembly (even interrupts and etc.)? Can't interface with with external hardware without assembly.
From: CBFalconer on 23 Apr 2008 19:13 Walter Banks wrote: > >> Why would you bother optimising a traditional call to main into >> a jump? > > When C runs on embedded systems processors that are not hosted > main should never return. What if the programmer puts (as he should) a return into main? This means you have to stack an address for that return (possibly the address of main). -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section. ** Posted from http://www.teranews.com **
From: Paul Keinanen on 23 Apr 2008 21:28
On Tue, 22 Apr 2008 01:50:31 -0700 (PDT), Lax <Lax.Clarke(a)gmail.com> wrote: > >Are there any situations where programming an embedded processor >"requires" at least some assembly code? > >How about for AVR, MSP430, 68HC11, 8051(Atmel)? >Can these 4 microcontrollers be programmed fully in C without touching >assembly (even interrupts and etc.)? Why do you ask this ? Do you expect that you could work with embedded systems without learning anything about the hardware architecture and the processor instruction set ? Most embedded project could be written completely in C except for the initialization code, possibly some interrupt preamble code, OS task switching and the use of some processor specific special instructions. In most cases this would be 1-2 pages of assembler code. However, if you are developing embedded applications in C or in other high level languages, you really have to understand what machine instructions are generated and what resources are needed for a specific construction. Also when debugging a program, understanding the instruction set (and assembler) will help a lot. Paul |