assembly in future C standard HCF Gerry Wheeler


    Sponsored Links


  • 1. Opened files
    Is there a way to get to know if a file is opened by a process?
  • 2. Generalized function for deallocating and setting pointer to NULL
    I've been trying to write a function capable of checking if a pointer value is set to NULL, and if it isn't, of deallocating and setting it's value to NULL regardless of the pointer's type. I thought "void ** " should do the trick, but I kept getting the following warning message from gcc: warning: passing argument 1 of 'free_var' from incompatible pointer type which obviously could be solved by doing an explicit cast to (void **) in the argument list when calling the fuction. That however would put an extra burden on the programmer, so I invented the following solution which works quite well apparently. Please give me your opinions on this issue. void free_var(void *vptr) { void **ptr = (void **) vptr; if (ptr != NULL) { if (*ptr != NULL) { free(*ptr); *ptr = NULL; } } } Thank you.
  • 3. An intereting rider in C
    A rider who is on a horse cruse around.the array is 15*15,and he was located in (7,7).His horse only can go in "/"or"\". eg.when he was in (7,7),next,he may go (5,8),(5,6),(6,9),(6,5),(8,9),(8,5) (9,8),or(9,6) . IF he has three steps,please caculate the location he would be . here is my programn,i imitated the 8 Quessn `s way,however,nothing gain. I am puzzled by the Return function here and there,where should i straighten it up ? #define MAX 3 static int array[15][15]; static int x,y; static int a,b; static int x0=7; static int y0=7; int g,h; /* void showchess() { //printf("%d\n",array[a][b]); for(int i=0;i<15;i++) { for(int j=0;j<15;j++) { printf("%3d",array[i][j]); } printf("\n"); } } */ int check(int a,int b,int c) /* c is the number of step*/ { int x,y; for(x=a-2;x<=a+2;x++) for(y=b-2;y<=b+2;y++) { if ((x-a)*(x-a)+(y-b)*(y-b)==5) { c=c+1; printf(" x=%d,y=%d\n",x,y); g=x; h=y; return 1; } } return 0; } void putchess(int x0,int y0,int n) { int z; array[x0][x0]=1; if(check(x0,y0,n+1)==1) { if(n==MAX-1) printf("ok"); //showchess(); else putchess(g,h,n+1); } } int main() { putchess(x0,y0,0); return 1; }
  • 4. New to C, "Undefined reference's"
    Hi, I am trying to compile a sample program using gcc. The program requires headers so I put the header files and corresponding source files into one folder. Then I ran the command 'gcc prog.c -o prog.exe.' It then gives me errors such as "undefined reference to '_N_VNew'" where N_VNew is in the header files I put in the folder. Usually gcc file.c -o file.exe worked for a c program that include no user defined headers. I've never dealt with headers before, is there some gcc command I need to use? btw, I doubt there is a problem in the source code calling the headers. Thank You

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