ummmm.. you were saying???

8:58:44pm  orb(19): cat bs3.c
#include <stdio.h>

int main(void)
{
 int toshiftornottoshift = 0x8000;

 printf("%d\n", toshiftornottoshift);

 return(0);
}
8:58:48pm  orb(20): cc -S -O2 -o bs3.s bs3.c
8:58:53pm  orb(21): cat bs3.s
       .file   "bs3.c"
       .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
       .string "%d\n"
       .text
       .p2align 4,,15
.globl main
       .type   main, @function
main:
.LFB3:
       subq    $8, %rsp
.LCFI0:
/*
*      this doesn't look like the compiler generates a shift to me.
*/
       movl    $32768, %esi
       movl    $.LC0, %edi
       xorl    %eax, %eax
       call    printf
       xorl    %eax, %eax
       addq    $8, %rsp
       ret
.LFE3:
       .size   main, .-main
       .section        .eh_frame,"a",@progbits
.Lframe1:
       .long   .LECIE1-.LSCIE1
.LSCIE1:
       .long   0x0
       .byte   0x1
       .string "zR"
       .uleb128 0x1
       .sleb128 -8
       .byte   0x10
       .uleb128 0x1
       .byte   0x3
       .byte   0xc
       .uleb128 0x7
       .uleb128 0x8
       .byte   0x90
       .uleb128 0x1
       .align 8
.LECIE1:
.LSFDE1:
       .long   .LEFDE1-.LASFDE1
.LASFDE1:
       .long   .LASFDE1-.Lframe1
       .long   .LFB3
       .long   .LFE3-.LFB3
       .uleb128 0x0
       .byte   0x4
       .long   .LCFI0-.LFB3
       .byte   0xe
       .uleb128 0x10
       .align 8
.LEFDE1:
       .ident  "GCC: (GNU) 4.2.1 20070719  [FreeBSD]"

per...@pluto.rain.com wrote:
Jim Bryant <kc5vdj.free...@gmail.com> wrote:

what kind of idiot defines a constant assignment for a 32k buffer as a 15 bit left shift of 1?

clever, yes.  but in production, stupid.

a constant should be just that, a constant, and thus require no computation at runtime.

Er, did you bother to look at the generated code before spouting off?
Most compilers, even as far back as K&R 1st edition, will compute
constant expressions like that at compile time.

_______________________________________________
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"

Reply via email to