<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">You can also use the FFI to call C functions, and you can use the RUN-PROGRAM function to invoke gcc. So you can write a little compiler that translates a Lispy DSL into C, compiles it, and runs the resulting code completely transparently.<div><br></div><div>rg<br><div><br><div><div>On Apr 18, 2020, at 5:34 AM, Bill St. Clair <<a href="mailto:wws@clozure.com">wws@clozure.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">CCL's optimizers do a pretty good job, if you tell them to:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style=""><font face="monospace">CL-USER> (defun add (x y)<br> (declare (fixnum x y) (optimize (speed 3) (safety 0)))<br> (the fixnum (+ x y)))<br>ADD<br>CL-USER> (disassemble 'add)<br> (recover-fn-from-rip) ; [0]<br> (pushq (% rbp)) ; [7]<br> (movq (% rsp) (% rbp)) ; [8]<br> (pushq (% arg_y)) ; [11]<br> (pushq (% arg_z)) ; [12]<br> (movq (@ -8 (% rbp)) (% arg_y)) ; [13]<br> (movq (@ -16 (% rbp)) (% arg_z)) ; [17]<br> (addq (% arg_y) (% arg_z)) ; [21]<br> (movq (% rbp) (% rsp)) ; [24]<br> (popq (% rbp)) ; [27]<br> (retq) ; [28]<br>NIL</font><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 18, 2020 at 6:43 AM MichaĆ "phoe" Herda <<a href="mailto:phoe@disroot.org">phoe@disroot.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I would like to use arithmetic primitives (add, mul, sub, div, ..) in<br>
ccl, is this possible?<br>
<br>
Hey!<br>
<br>
I assume that you mean using the raw CPU assembly instructions of the<br>
architecture on which you are. This means that you will not only need<br>
raw assembly instructions, but you will also need raw machine integers;<br>
basically writing assembly in CCL.<br>
<br>
It's possible to write LAP (short for Lisp Assembly Program) functions<br>
for Clozure Common Lisp; see<br>
<a href="https://github.com/Clozure/ccl/blob/275105afd94706d95ac955178316074931822c42/level-0/X86/X8632/x8632-numbers.lisp" rel="noreferrer" target="_blank">https://github.com/Clozure/ccl/blob/275105afd94706d95ac955178316074931822c42/level-0/X86/X8632/x8632-numbers.lisp</a><br>
for example number-operating functions for x32. I am not aware if there<br>
any tutorials or documentation for these, though.<br>
<br>
~phoe<br>
<br>
_______________________________________________<br>
Openmcl-devel mailing list<br>
<a href="mailto:Openmcl-devel@clozure.com" target="_blank">Openmcl-devel@clozure.com</a><br>
<a href="https://lists.clozure.com/mailman/listinfo/openmcl-devel" rel="noreferrer" target="_blank">https://lists.clozure.com/mailman/listinfo/openmcl-devel</a><br>
</blockquote></div>
_______________________________________________<br>Openmcl-devel mailing list<br><a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>https://lists.clozure.com/mailman/listinfo/openmcl-devel<br></blockquote></div><br></div></div></body></html>