From: Raffael Cavallaro on
On 2010-03-11 16:09:24 -0500, Hugh Aguilar said:

> Does any Scheme or Common Lisp include a Pentium assembler?

Clozure Common Lisp does. See this recent thread for some examples:

<http://thread.gmane.org/gmane.lisp.openmcl.devel/5486>

you can get CCL at:
<http://trac.clozure.com/ccl>

Of course other implementations may have assemblers too.

warmest regards,

Ralph

--
Raffael Cavallaro

From: Hugh Aguilar on
On Mar 11, 3:20 pm, Raffael Cavallaro
<raffaelcavall...(a)pas.espam.s.il.vous.plait.mac.com> wrote:
> > Does any Scheme or Common Lisp include a Pentium assembler?
>
> Clozure Common Lisp does. See this recent thread for some examples:

Thanks for the tip regarding CCL. An assembler is always a good thing
to have; that will eventually become important.

Right now my primary interest is in porting my slide-rule program to
Lisp and providing it with a GUI. My program currently only generates
gcode. For a GUI, I would have to upgrade it to also generate some
other format. One possibility would be SVG. I could then use some tool
(most likely Cairo) to convert the SVG into graphical images that
could be displayed on the screen for use in simulating slide-rule
operation. Another possibility would be to generate data files
acceptable to GNUplot and then using GNUplot to create the graphical
images for me. I noticed that CCL has a library called CLNUPlot that
interfaces with GNUplot. My slide-rule scales include a lot of tiny
straight lines (the marks) and some text (the labels). Do any of you
guys have an opinion on how well any of this will work? Also note that
I have never written a GUI program in my life, so I need a pretty easy
system with a lot of hand-holding documentation. From what I've
gathered, PLT Scheme is famous for making GUI easy for newbies like
me. I haven't seen any mention of Cairo or GNUplot support in regard
to PLT Scheme though.

On a related note, do any of you guys know very much about LaTeX?
Specifically, do you know if it is possible to generate arbitrarily-
sized text? I have some experience with LaTeX, but all I know about is
the handful of fixed sizes available (scriptsize, normalsize, etc.).
For a 10-inch slide-rule, I need text characters that are 0.05 and
0.08 inches square. The idea with LaTeX is to print out on adhesive
labels. This would be for toy slide-rules. By comparison, my gcode is
for milling anodized aluminum slide-rules that are intended to be
durable. BTW, do any of you guys do any machining work? Do you have
access to a milling machine or laser? All of my code is BSD-license,
so you would be welcome to use it for making slide-rules of your own.

Thanks for all of your assistance on getting me pointed in the right
direction!
From: refun on
In article <a5d542ce-276e-47c3-ad60-691e33fa72d1(a)a16g2000pre.googlegroups.com>,
hughaguilar96(a)yahoo.com says...

> Does any Scheme or Common Lisp include a Pentium assembler?

Most native CL compilers probably have one as having one makes native compiler
writing manageable, as opposed to emitting opcodes manually.

I know for sure that SBCL and CCL have one, however usually the assembler works
by defining VOPs(compiler's VM opcodes), and not in a more direct manner (or
maybe it could be made to work that way too, but I haven't looked).

There's also movitz which has 2 disassemblers/assemblers, but while I like the
project, I feel rather uncomfortable with the non-Intel syntax they use for
their x86 assemblers/disassemblers, as most other tools that work with assembly
on the x86 tend to use incompatible syntax with theirs, but that's a minor
hurdle (the other one is that one of the disassemblers/assemblers doesn't have
support for various opcodes common opcodes, which is why I might just end up
making my own assembler someday).

In general, you could just make your own assembler if the implementation does
not provide support for it, it would be possible in portable Common Lisp. What
would not be possible in portable CL is to execute the code, but that should be
no problem as there's at least 2 possible solutions to the problem:
1) Learn about how an implementation represents a code object and build the
object yourself. This would only work in a lisp with actual native code objects
(SBCL, CCL, ACL, LW, CMUCL, ...)
2) Use the FFI to treat your code as a function and execute it. Obviously one
will have to follow compatible calling conventions to match the FFI's.

If one takes the second path, it would be possible to make a de-facto portable
x86 assembler which can also be used to run code for implementations which
support running native code. Too bad, I'm not aware of any such project being
done, yet.
From: Eli Barzilay on
Hugh Aguilar <hughaguilar96(a)yahoo.com> writes:

> On Mar 11, 3:20 pm, Raffael Cavallaro
> <raffaelcavall...(a)pas.espam.s.il.vous.plait.mac.com> wrote:
>> > Does any Scheme or Common Lisp include a Pentium assembler?
>>
>> Clozure Common Lisp does. See this recent thread for some examples:
>
> Thanks for the tip regarding CCL. An assembler is always a good
> thing to have; that will eventually become important.

PLT has one too, though I don't remember who did it. (Binding to some
jitting library is usually easy though -- at some point we had an LLVM
interface which would just generate LLVM code in text then pass it to
LLVM's jitter. In addition, PLT has certain features that makes it
easy to invoke some compiler from a macro, making the code generated
when the Scheme code compiles.)


> [...] I haven't seen any mention of Cairo or GNUplot support in
> regard to PLT Scheme though.

MrEd -- the GUI extension of MzScheme provides you with the usual
drawing primitives that you'd find in any such library. You can then
direct drawing to a window, a bitmap to be saved in an image file, or
to a postscript handle for printouts. On X, the drawing is handled by
Cairo (or if it isn't available, by plain X), so you don't need
specific Cairo bindings.

As for plotting functions, there is a plot library. (You can find
documentation for this and everything else at docs.plt-scheme.org)


> On a related note, do any of you guys know very much about LaTeX?
> Specifically, do you know if it is possible to generate arbitrarily-
> sized text? I have some experience with LaTeX, but all I know about is
> the handful of fixed sizes available (scriptsize, normalsize, etc.).
> For a 10-inch slide-rule, I need text characters that are 0.05 and
> 0.08 inches square. The idea with LaTeX is to print out on adhesive
> labels. [...]

(Postscript or PDF is probably much better than latex if you care
details like exact placement of text.)

--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
From: Vassil Nikolov on

On Thu, 11 Mar 2010 13:09:24 -0800 (PST), Hugh Aguilar <hughaguilar96(a)yahoo.com> said:
> ...
> Does any Scheme or Common Lisp include a Pentium assembler?

Apropos ("anti-apropos", rather), Common Lisp has DISASSEMBLE, e.g.:

* (disassemble #'(lambda (n) (1+ n)))

; 026D40F9: 488B55E8 MOV RDX, [RBP-24] ; no-arg-parsing entry point
; 0FD: BF08000000 MOV EDI, 8
; 102: 4C8D1C25D0010020 LEA R11, [#x200001D0] ; GENERIC-+
; 10A: 41FFD3 CALL R11
; 10D: 480F42E3 CMOVB RSP, RBX
; 111: 488D65F0 LEA RSP, [RBP-16]
; 115: F8 CLC
; 116: 488B6DF8 MOV RBP, [RBP-8]
; 11A: C20800 RET 8
; 11D: 90 NOP
; 11E: 90 NOP
; 11F: 90 NOP
; 120: CC0A BREAK 10 ; error trap
; 122: 02 BYTE #X02
; 123: 18 BYTE #X18 ; INVALID-ARG-COUNT-ERROR
; 124: 4E BYTE #X4E ; RCX
;
NIL
*
(disassemble
#'(lambda (n)
(declare (type (integer 1 1000) n)
(optimize speed (safety 0)))
(1+ n)))

; 026A33EF: 4883C208 ADD RDX, 8 ; no-arg-parsing entry point
; 3F3: 488D65F0 LEA RSP, [RBP-16]
; 3F7: F8 CLC
; 3F8: 488B6DF8 MOV RBP, [RBP-8]
; 3FC: C20800 RET 8
; 3FF: 90 NOP
;
NIL

---Vassil.


--
No flies need shaving.