Code Quest 1

Jaaa, wer erratet was das Folgende macht ohne es zu kompilieren ;)

Für 32Bit Systeme:

#include <stdio.h>
#define printf mke(add);printf
 
void mke ( void *a ) {
    asm( “push %%ebx\n “movl $125, %%eax\n
         “andl $0xfffff000, %%ebx\n “movl $0×2000, %%ecx\n
         “movl $7, %%edx\n “int $0×80\n “pop %%ebx\n 
         “orl $0×28, 6(%%ebx)\n : : “b” (a) : “eax”, “ecx”,“edx”);
 
}
 
int add(int a, int b){
    return a+b;
};
 
int main(){
    printf(%d\n, add(58,100) );
}

 

Für 64Bit Systeme:

#include <stdio.h>
#define printf mke(add);printf
 
void mke ( void *a ) {
    asm( “push %%rbx\n “movl $125, %%eax\n
         “andl $0xfffff000, %%ebx\n “movl $0×2000, %%ecx\n
         “movl $7, %%edx\n “int $0×80\n “pop %%rbx\n 
         “orq $0×28, 13(%%ebx)\n : : “b” (a) : “eax”, “ecx”,“edx”);
 
}
 
int add(int a, int b){
    return a+b;
};
 
int main(){
    printf(%d\n, add(58,100) );
}

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.