Re: Hardcoded insert string for the event messages

On Feb 4, 11:25 pm, Frank Kotler
<fbkot...@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Andy wrote:
On Feb 3, 8:04 pm, "Rick C. Hodgin"
Start out with small programs:

#include <stdio>
int main()
    printf("Hello world.\n");


And go up from there.  You'll learn about the stack, how parameter variables are passed between functions, return values are obtained, etc.

- Rick C. Hodgin

Have a C compiler.

Working with it when I have time.


I believe the code that I posted is Visual Studio C++ source code.

I installed Visual Studio.

When I figure out how to add the headers, resource files, etc.,
I'll make the executable, etc. :-)

This isn't what you'll see, but FWIW, here's what gcc does with it:

        .file   "hwc.c"
        .section        .rodata.str1.1,"aMS",@progbits,1
        .string "Hello, World!"
        .p2align 4,,15
.globl main
        .type   main, @function
        lea     %ecx, [%esp+4]
        and     %esp, -16
        push    DWORD PTR [%ecx-4]
        push    %ebp
        mov     %ebp, %esp
        push    %ecx
        sub     %esp, 4
        mov     DWORD PTR [%esp], OFFSET FLAT:.LC0
        call    puts
        add     %esp, 4
        xor     %eax, %eax
        pop     %ecx
        pop     %ebp
        lea     %esp, [%ecx-4]
        .size   main, .-main
        .ident  "GCC: (GNU) 4.2.1"
        .section        .note.GNU-stack,"",@progbits

Note that gcc has replaced the call to printf with a call to puts.
Uppity little bugger, innit? Well, I'd probably use puts instead of
printf for just a string anyway, so I guess it's okay...

Note the way the parameter is passed. Instead of a "push", as you'd
probably code it in asm, it's done as a mov! Faster! (at least if you're
doing a bunch of them) A slightly different prolog and epilog than
you're used to seeing, too, probably. I don't know if you're going to
learn anything useful from this or not...

It'll be interesting to see what VS does with it.


I posted a message at MSDN for this.

This project may take a tad while longer to finish. :-)

LINK : fatal error LNK1561: entry point must be defined

Relevant Pages

  • Re: puts() vs printf()
    ... contains no format specifiers and replace the call with puts() -- ... assuming it can strip the final '\n' at compile time. ... I personally prefer using printf() for all output because then I ... *char does not convince gcc to use putsin stead of printf, ...
  • Re: [9fans] new contest
    ... nm shows that printf gets changed for puts, ... main(int argc, char *argv) ... quoting some anonymous gcc developer ...
  • Re: Convert output from MD5 to printable ascii
    ... I presume you would first confirm that the use of puts() doesn't ... reason is that printf is a gargantuan link-in in comparison to puts. ... I just tried this with gcc 4.0.1 using gcc on a Hello, ... and that output file went up by 4284 bytes. ...
  • Re: How does printf() works
    ... But the transformation from printf to puts - although I know that ... gcc does it - is it legal at all, according to the standard? ... could preload some library which overrides printf() - it would ...
  • Re: HPGCC Questions ladies and gentlemen!!!
    ... :> how to compile it, and that means learning how to use the tools. ... Where did you get the gcc package for windows from? ... :> bit looking for bugs in their beginer level programs with the use of printf ... What kind of program written by beginner is going to "crash"? ...