[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

progress with native code generation in guile

From: Stefan Israelsson Tampe
Subject: progress with native code generation in guile
Date: Sat, 9 Jun 2012 19:47:15 +0200


On linux, x86-64 I can now write,

(use-modules (native aschm))

(define b (asm
           (inst mov rbx 1000000000) ;rbx = 1000,000,000
           (inst cmp rbx 0)
           (inst jmp #:eq out:)
           (inst dec rbx)
           (inst jmp loop:)
           (inst mov rax 2)          ; return value in register rax
           (inst pop rbx)            ; we pushed the return adress before
           (inst jmp rbx)))          ; jump back

(mk-rwx b)                           ; Make the memory pages read write and
                                     ;   execute

(run-native b)                       ; run the code using a simple scheme

And the code loops and return 0 (2).

So it is possible to generate assembler from whithin guile and execute it which is pretty cool.

If you have the right architecture, you can play with it at:

Have fun

reply via email to

[Prev in Thread] Current Thread [Next in Thread]