[SP-pm] Algumas duvidas sobre Perl

Suissa jnascimento at gmail.com
Wed Sep 22 16:39:00 PDT 2010


Entendi. Só gostaria que alguém formulasse um conceito que diferencie bem os
compiladores de interpretadores já que há uma linha tenue entre eles.

On Wed, Sep 22, 2010 at 8:36 PM, breno <breno em rio.pm.org> wrote:

> 2010/9/22 Suissa <jnascimento em gmail.com>:
> > sei q em C eh facilimo utilizar codigos asm
> >
>
> Sim, mas ainda assim o código assembly é compilado, não interpretado.
>
> Caso alguém tenha ficado curioso:
>
> ---------8<----------
> #include <stdio.h>
>
> int main (void) {
>   int arg1=9, arg2=16, add, sub;
>
>   __asm__ ( "addl %%ebx, %%eax;" : "=a" (add) : "a" (arg1) , "b" (arg2) );
>   __asm__ ( "subl %%ebx, %%eax;" : "=a" (sub) : "a" (arg1) , "b" (arg2) );
>
>   printf( "%d + %d = %d\n", arg1, arg2, add );
>   printf( "%d - %d = %d\n", arg1, arg2, sub );
>
>   return 0;
> }
> --------->8----------
>
> Apenas a título de curiosidade, em Perl dá até pra usar diferentes
> assemblers no mesmo código ;-)
>
> ---------8<----------
> say "9 + 16 = " . add(9, 16);
> say "9 - 16 = " . subtract(9, 16);
>
> use Inline ASM => 'DATA',
>           AS => 'as',
>           PROTO => {add => 'int(int,int)'};
>
> use Inline ASM => 'DATA',
>           AS => 'nasm',
>           ASFLAGS => '-f elf',
>           PROTO => {subtract => 'int(int,int)'};
>
> __END__
> __ASM__
>
> .text
> .globl    add
>
> add:      movl 4(%esp),%eax
>          addl 8(%esp),%eax
>          ret
> __ASM__
>          GLOBAL subtract
>          SECTION .text
>
> subtract: mov eax,[esp+4]
>          sub eax,[esp+8]
>          ret
> --------->8----------
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>



-- 
Jean C. Nascimento aka Suissa
Prof. Análise e Soluções Web Fafit/Facic - Itararé - SP

gtalk/msn: jnascimento em gmail.com

WebDeveloper - www.wgbnet.com.br/
NoSQL Evangelist - MongoDB Contributor - nosqlbr.com.br/
iGrape Evangelist - Coordenador Geral - http://igrape.org
TheWebMind Evangelist - Coordenador de Interface & NoSQL -
http://thewebmind.org/
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20100922/46871992/attachment.html>


More information about the SaoPaulo-pm mailing list