assembly in future C standard HCF Gerry Wheeler


    Sponsored Links


  • 1. Why can I not alloc memory in called function?
    Hello I am passing a char* pointer into a function and in the function I malloc but when the function returns the pointer seems to go out of scope? I thought that if I passed a pointer, then I would allocate memory to the pointer? What am I doing wrong? #include <stdlib.h> void doit(char* allostring) { allostring = malloc(6); memcpy(allostring, "Hello\0", 6); } int main() { char* strtopass = 0; doit(strtopass); free(strtopass); return 0; }
  • 2. Macro to assign unique number to a source file
    Greetings I use a macro below to get a guaranteed unique number to identify source files for asserts in a system with very little memory. This works fine, but sometimes braindead compilers do not optimise away the dummy function, so it appears in the object file. Is there another way of checking for no duplicates in "C"? #define FILENUM(n) \ void errorHandlerDummyFunctionForCheckingFileNumber_##n(void) {} \ enum { F_NUM = (n) } TomH
  • 3. Describing a tree
    A possibly dumb question: Given a labeled or unlabeled tree (in the sense of graphs), how could one best use C to describe it? (I don't exactly know but have the impression that this might be rather simple in Lisp.) Thanks. M. K. Shen
  • 4. code review: read in ps(1) result
    /*thank you for your time*/ /*read in ps(1) result*/ #include <stdio.h> #include <errno.h> #include <sys/types.h> #define M 256 #define N 32 #define str(n) #n /*from pete's*/ #define xstr(n) str(n) int main(void) { char uid[N + 1]; pid_t pid; pid_t ppid; char stime[N + 1]; char cmd[M + 1]; char *ps = "ps -ef"; FILE *fp; int errnum; int n; errno = 0; if (!(fp = popen(ps, "r"))){ errnum = errno; fprintf(stderr, "%s\n", strerror(errnum)); return 1; } errno = 0; while((n = fscanf(fp, "%"xstr(N)"s %d %d %*s " "%"xstr(N)"s %*s %*s %"xstr(M)"[^\n]", uid, &pid, &ppid, stime, cmd)) != EOF){ if (n != 5){ fscanf(fp, "%*[^\n]"); continue; } fprintf(stdout, "%s, %d, %d, %s, %s\n", uid, (int)pid, (int)ppid, stime, cmd); errno = 0; } errnum = errno; if (errnum) fprintf(stderr, "%s\n", strerror(errnum)); pclose(fp); return 0 }

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 72 guest