assembly in future C standard HCF Gerry Wheeler


    Sponsored Links


  • 1. dynamic declaration of struct array
    Why won't the declaration of a struct array work if I do it like this: 1 typedef struct 2 { 3 int pens; 4 int pencils; 5 } Stationers; 6 ......... 7 int main(void) 8 { 9 int num; ...........num defined in code........ 10 11 Stationers stats[num]; 12 } The error message says "constant expression required" and highlights line 11. I want to declare it dynamically during runtime, could someone explain how to do this please.
  • 2. piping/reading stdin quirks.
    FBSD 4.8/GCC //////// C-CODE: //////// char c; while ( 1 ) { read(0, &c, 1); printf("%02x ", c); close(0); open("/dev/stdin", O_RDWR, S_IRUSR|S_IWUSR); } ////////// Question: ////////// this is confusing to me. 'open' doesn't reopen 'stdin' ('errno' keeps getting set, and no new characters are ever read - after the 1st one). i have a function that opens, reads, and closes a file. i would like to use this function to read a file piped from 'stdin' as well as from disk. the problem is i can't re-open 'stdin' after the file reading function closes '/dev/stdin'. is there any way to "reset" /dev/stdin so that it functions normally after being close(2)'d?
  • 3. Troll Alert: why not use C?
    Something that calls itself hongky wrote: > language C is so good computer language... > why not use it, why use C++, > in Unix, i just like program with C This is an obvious troll. Please ignore it.
  • 4. Basic Array Question
    What do you do in C so that you have two arrays that point to the same values (ie. changing one array would also change the other)? Can something like this work? int a[]; int b[]; b = a Or maybe this? int a[]; int *b; b = a; In either case, would something like a[0] = 1 be the same as b[0] = 1 (and a[0] == b[0] would be true)? -- I am only a mirage.
  • 5. Pointer to memory
    How does on "point" a pointer at a specific memory address? I have a program where I've malloc'd some memory and need to move around and make changes. I know I can move a pointer in the malloc'd storage by incrementing a pointer. However, in this malloc'd storage, I have stored addresses of other locations and would like to "jump" from one memory location to another based on what I find in certain memory ranges. Don't worry, I've taken care of word aligning, etc. etc. So to recap: 1. I have malloc'd storage 2. I have written blocks of data into this storage (I know it's there because I can traverse the entire storage and output the information alas, by incrementing the pointer) 3. I need to jump from run location to another based on some of the data I've added. Thanks, Mark

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