assembly in future C standard HCF Gerry Wheeler


    Sponsored Links


  • 1. Restarting my program
    Whatup, I have a program that sometimes I need to restart from within the program itself. Obviously I can store away argc and argv and just call main() again, however this does not reinitialize any static variables in my code and any libraries. How can I achieve this please? Is there some way with setjump()? TIA
  • 2. String: "anti" string oprator
    Hi, The # operator converts a parameter to a string. Is there a way to "anti" string? For e.g. char *p="abc"; char *q="xyz"; #define declare_fun(x) void <anti string>x( void) main() { declare_func(*p); declare_func(*q); } I would like to get the following after the preprocessor is run: main() { void abc(void); void xyz(void); } Is there a way to achieve this? Thanks, Parag
  • 3. Array with no elements
    Hi, What does the C standard say about arrays with no elements? Code: #include <stdio.h> #include <string.h> int arr_test[]={ #ifdef FEATURE_FOO 0, #endif #ifdef FEATURE_BAR 0, #endif }; int main() { printf("output %d\n", sizeof(arr_test)/sizeof(arr_test[0])); return 0; } It is not known apriori if FEATURE_FOO or FEATURE_BAR are defined or not. GCC and .NET compilers give different results. GCC compiles fine. .NET gives the following error. E:\temp>cl test_empty_array.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. test_empty_array.c test_empty_array.c(11) : error C2059: syntax error : '}' test_empty_array.c(15) : warning C4034: sizeof returns 0 What does the C standard say about empty arrays? Is the behavior undefined or implementation specific? To make the program portable and safe, I can add a "dummy" entry to the array, but if possible I would prefer not to do that. Thanks, Parag
  • 4. inline vs. function pointers
    C99 gave us the "inline" keyword and IIRC in standard C (as opposed to certain propriety dialects) it is just a hint for the compiler i.e. there is no guarantee that a function declared "inline" will actually be inlined all the time. Now, here is the problem, a certain C compiler when evoked in ANSI C mode produces an error message when I put pointers to "inline" functions in an array of function pointers. The compiler actually inlines the function code in this case, never putting the functions themselves in the resulting binary and thus renders the pointers invalid. Is that standard conforming behavior? I mean, is there a rule that you are not allowed to use pointers to "inline" functions?

Re: assembly in future C standard HCF Gerry Wheeler

Postby Walter Banks » Sat, 04 Nov 2006 22:35:39 GMT

As this thread wanders off topic this industry was introduced to a new
mnemonic in Byte article about decoding the undocumented
Motorola 6800 instructions. The HCF (Halt Catch Fire) opcode $DD
or $D9. HFC locked up the processor and cycled the address bus
The author of that article was Gerry Wheeler.

Gerry Wheeler, 54, died October 15, 2006, advanced non-Hodgkins
lymphoma cancer. Gerry made significant contributions to the technology
of the embedded systems world and was a key part of the development
of many household name products.

Programmer, Ham KG4NBB, author, father, husband, active commuity
participant Gerry will be missed by all.


Similar Threads:

1.assembly in future C standard

Peter Nilsson < XXXX@XXXXX.COM > wrote:

(Crossposted to comp.std.c, with followups directed there, hopefully
 appropriately.  The original post discussed the possibility of whether
 __asm or something similar to it would be added to the C standard.)

> Contrary to Richard Heathfield's categorical statement, it is not an
> absolute given that there will never be an asm keyword in C. But it
> is unlikely because it's already clear that the asm keyword in C++ has
> not served to truly standardise the syntax of inline assembly.

One idea that was not mentioned in the original thread (I imagine for
good reason, because it's a half-baked and probably stupid idea that
occurred to me reading your post) would be to allow for some kind of
conditional assembly, just perhaps something like

#pragma assemble
#pragma X86 /* Inner pragma's implementation-defined */
  /* Inline assembly, which the implementation can ignore or not */
#pragma no-assemble
  /* Stock C code for implementations that can't or won't accept the
   * assemble pragma: */
  for( i=1; i < 10; i++ ) {
    /* ... */
#pragma end-assemble

The end result would be something like "If the implementation attempts
to inline the assembly code contained within a #pragma assemble
directive, the behavior is implementation-defined.  Otherwise the
assembly code shall be ignored and the C code contained within any
corresponding #pragma no-assemble directive shall be compiled as
though no directives were present."  It would require adding some
duties to the #pragma directive, but it would allow implementors to
take a reasonable shot at using targetted assembly instructions when
appropriate and available, and reverting to ordinary C otherwise.

I'm sure there are reasons why this is stupid and/or impossible, or it
would have been done already :-)

> At the end of the day, the committee could probably spend many man
> weeks deciding issues on an __asm keyword, but for what? Most
> implementations will keep their existing syntax, and most programmers
> who use inline assembly will no doubt continue to prefer the localised
> syntax because it's less cumbersome than any standard syntax.

Indeed, but it's an interesting thought experiment to consider how the
committee *might* add assembly to C if they chose to do so.  (Well,
interesting to me, at least.)

C. Benson Manica           | I *should* know what I'm talking about - if I
cbmanica(at)      | don't, I need to know.  Flames welcome.

Return to c


Who is online

Users browsing this forum: No registered users and 78 guest