Date: Sun, 29 Aug 2010 21:02:33 -0500 From: Jim Bryant <kc5vdj.freebsd@gmail.com> To: perryh@pluto.rain.com Cc: freebsd-usb@freebsd.org Subject: Re: writing usb drivers under 8.x Message-ID: <4C7B1139.4050106@gmail.com> In-Reply-To: <4c799393.wU/d2YpTieErDrD7%perryh@pluto.rain.com> References: <4C76AB76.4070806@gmail.com> <201008270856.43512.hselasky@c2i.net> <4C777D12.3040900@gmail.com> <201008271053.27731.hselasky@c2i.net> <4C78B0F4.4020002@gmail.com> <4c799393.wU/d2YpTieErDrD7%perryh@pluto.rain.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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]"
perryh@pluto.rain.com wrote:
> Jim Bryant <kc5vdj.freebsd@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.
>
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C7B1139.4050106>
