Overview
First things first! We absolutely must say ``Hello World!'' in the following manner!
(sassy '((text (mov eax 1) (mov ecx 5) (while (> ecx 0) (begin (mul ecx) (sub ecx 1))))))
Sassy is a portable assembler for the x86 processor which fully supports 32-bit or ``protected-mode'' programming and partially supports 16 bit programming using 32-bit mode addressing.
Sassy is based on Henry Baker's COMFY-65 compiler, which he wrote in PDP-10 Maclisp, subsequently ported to GNU Emacs Elisp, and which targeted the MOS 6502 processor.1
One of the primary selling points of COMFY-65 (besides its small size
and the fact that it employed a syntax based on s-expressions) was its
``comfortable set of control primitives'', such as seq
,
while
, and if
. When the assembly programmer/compiler
writer used the structure inherent in these constructs, they didn't
have to code up a nest of obscure local labels in order to control the
flow of computation. By taking advantage of Lisp's recursive nature,
COMFY-65 managed this in one pass.
Sassy works the same way. Its syntax consists of s-expressions and it features the same set of control primitives, and is a (mostly) one-pass assembler written in about 3,000 lines of Scheme. At the same time, Sassy is similar to traditional assemblers for the x86, with directives for separate heap, data, and text sections, the ability to annotate linker-specific relocation types, and support for labels, locally nested or not (something COMFY-65 lacked; Baker recommended using jump-tables. Sassy uses back-patching). Sassy has a simple macro system, or programmers may write ``escapes'' to Scheme in order to take advantage of Scheme's meta-programming facilities. Sassy is a complete 32-bit assembler for the x86 line and recognizes the full 32-bit instruction set, up to and including the SSE3 extensions.
Sassy is also target- and linker-neutral. Sassy generates a record of objects and information, representing, for instance, the text section, or the alignment requirements of the data section. The programmer may pass the record to an output module that in turn creates the final output suitable for linking or loading. Sassy comes with an output module that creates ELF object files for GNU/Linux with dynamic shared library support, or programmers may use Sassy's API to create their own output modules.
1 Baker's papers:
TEX version of COMFY-65 paper. Some TEXmacros are missing, but the text itself is readable.
printed version of COMFY-65 paper. You'll need access to an ACM membership to get this.
Elisp implementation of COMFY-65