Re: GNUH8 mixed C and assembly



On 12 Nov, in article
<1131811847.205254.313210@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
cbarn24050@xxxxxxx wrote:
>Peter Harrison wrote:
>> I am working with HEW4 and GNUH8 5.03 targeted at the H8/3664 and
>> H8/3687 and I can write C programs with only moderate difficulty. I seem
>> to have no problem writing code in .src files and calling it from C.
>> What I seem unable to find out is how to write functions in assembler
>> and then either access the arguments that are passed in, or how to
>> return values to the calling function.

......

>> FWIW, the exact need just now is a soft time delay. These are short
>> delays of a few tens of microseconds I appreciate these are less than
>> ideal in many ways. I can write one in C - as appears in any number of
>> example projects. However, I am nervous about how the optimizer might
.....

>Soft delays are never fixed if they can be interupted, if you need a
>fixed delay use a timer. There are different ways of including assembly
>into your programs. Inline lines or blocks of assy instructions, C
>functions who's code is written in assembler or pure assy routines
>called directly. You need to look at the compiler docs for the syntax.
>You can usually get to a C value from assember by putting an underbar
>in front of the variable name but the H8 instructions mostly work only
>with registers so this method is very limited. The other way is to use

Considering the number of registers and sizes upto 32 bits not as limited
as quite a few processors.

>the frame pointer to acces the stack directly but this requires you to
>fully understand how your compiler works.

GCC/GNU uses R0 to R2 (for 16bit args) or ER0 to ER2 (32bit args) for the
first THREE parameters, the rest are passed on the stack.

> The H8 also has complex assy
>intructions best avoided if humanly possible.

Actually quite easy to use, some of the modes on some instructions
are limiting but a lot can be done in straight assembly. Most users
create their own startup code in assembly.

--
Paul Carpenter | paul@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<http://www.pcserviceselectronics.co.uk/> PC Services
<http://www.gnuh8.org.uk/> GNU H8 & mailing list info
<http://www.badweb.org.uk/> For those web sites you hate

.



Relevant Pages

  • Re: GNUH8 mixed C and assembly
    ... > What I seem unable to find out is how to write functions in assembler ... the exact need just now is a soft time delay. ... it is not uncommon for the optimization ... > understand that that is exactly why soft delays are dodgy. ...
    (comp.arch.embedded)
  • Re: GNUH8 mixed C and assembly
    ... >What I seem unable to find out is how to write functions in assembler ... the exact need just now is a soft time delay. ... it is not uncommon for the optimization ... >understand that that is exactly why soft delays are dodgy. ...
    (comp.arch.embedded)
  • Re: alternate language
    ... compiles to native code ... It will give more satisfaction, and delay the onset of Alzheimer's, far more ... effectively than any of the higher level languages you are contemplating. ... And if you really want a challenge, don't use the assembler, hand code the hex. ...
    (comp.lang.python)
  • Re: GNUH8 mixed C and assembly
    ... What I seem unable to find out is how to write functions in assembler and then either access the arguments that are passed in, or how to return values to the calling function. ... the exact need just now is a soft time delay. ... it is not uncommon for the optimization to completely remove apparently inactive code fragments. ...
    (comp.arch.embedded)
  • Re: Evolution
    ... > inline assembler and larger parts by linking to an assembler ... in the HLL. ... language, particularly in smaller projects. ... > or two instructions if you ...
    (alt.lang.asm)