Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- Date: Thu, 10 Mar 2011 16:26:57 +0100
- From: Josh Glover <jmglov@example.com>
- Subject: Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- References: <AANLkTim_-D9CFYC8TNp33ni85zB+QBA7jV=BpLN=4SbZ@example.com> <AANLkTimhSGxdPk45AMZHqX8eo2PS75K-qkuV+xMS7bdH@example.com> <AANLkTimSRkAiworM=O5VRfTVw-jBA4z=iD89OXY9sWxB@example.com> <4D765593.4090409@example.com> <4D76ECFF.30903@example.com> <AANLkTim=he_XLrHsFU2RMEUtq1f30AROO1mYQ7nLJvL3@example.com> <DED1953A-4193-4A6B-9ED4-BF0F676BA509@example.com> <AANLkTikTORsQbrnd0wAu_QwntBmjijBT83s24=5t_h2Z@example.com> <2E17A6AD-8F2B-4AEA-9555-4FB82ADA3B29@example.com> <20110309193326.4c0712da.jep200404@example.com> <4D781FA8.1040102@example.com> <20110309203709.575cbf84.jep200404@example.com> <AANLkTimo9yUpeOUAikpFPg75nEJ0QpHKcsm+VBt+sRKs@example.com> <20110310015425.4d9e751b.jep200404@example.com> <AANLkTinnnmu2qMhJ6EZfdMakURU-okO5r1LhUMRJ0QTZ@example.com> <4D78A467.4060707@example.com>
On 10 March 2011 11:13, Lewske Wada <ryu@example.com> wrote: > How about > > mov bx, ax > shl bx, 3 > sub bx, ax > > to get 7 times ax? : josh@example.com; cat tmp/arithmetic.c int multiply(const int multiplier) { int multiplicand = 12; return multiplicand * multiplicand; } int main(void) { int a = 5; return multiply(a); } : josh@example.com; gcc -O9 -S -o tmp/arithmetic.s tmp/arithmetic.c : josh@example.com; cat tmp/arithmetic.s .file "arithmetic.c" .text .p2align 4,,15 .globl multiply .type multiply, @function multiply: .LFB0: .cfi_startproc movl $144, %eax ret .cfi_endproc .LFE0: .size multiply, .-multiply .p2align 4,,15 .globl main .type main, @function main: .LFB1: .cfi_startproc movl $144, %eax ret .cfi_endproc .LFE1: .size main, .-main .ident "GCC: (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5" .section .note.GNU-stack,"",@progbits Strip out the unnecessary strings and you have a pretty efficient program. Notice that the optimiser didn't even need a register to hold the multiplicand and multiplier, and inlined the function call to boot. gcc's version has to deal with x86 calling conventions, saving main's return value in the %eax register; take that out, and it is comparable to yours. Better in the context of a full program, I'd say, since it knows which variables it can optimise away and not even waste a register on. Cheers, Josh
- Follow-Ups:
- Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- From: Nicolas Limare
- References:
- [tlug] Alternatives to sed + awk
- From: Nguyen Vu Hung
- Re: [tlug] Alternatives to sed + awk
- From: Josh Glover
- Re: [tlug] Alternatives to sed + awk
- From: Nguyen Vu Hung
- Re: [tlug] Alternatives to sed + awk
- From: Raymond Wan
- Re: [tlug] Alternatives to sed + awk
- From: Lewske Wada
- Re: [tlug] Alternatives to sed + awk
- From: Josh Glover
- Re: [tlug] Alternatives to sed + awk
- From: Lewske Wada
- Re: [tlug] Alternatives to sed + awk
- From: Josh Glover
- Re: [tlug] Alternatives to sed + awk
- From: Lewske Wada
- [tlug] Assembly Language v C and Embedded Development (was Re: Alternatives to sed + awk)
- From: jep200404
- Re: [tlug] Assembly Language v C and Embedded Development (was Re: Alternatives to sed + awk)
- From: Lewske Wada
- Re: [tlug] Assembly Language v C and Embedded Development
- From: jep200404
- Re: [tlug] Assembly Language v C and Embedded Development
- From: Josh Glover
- Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- From: jep200404
- Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- From: Josh Glover
- Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- From: Lewske Wada
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Alternatives to sed + awk
- Next by Date: Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- Previous by thread: Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- Next by thread: Re: [tlug] Assembly Language v C and Embedded Development: !gcc for PIC16F84
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links