Set-based languages have emerged as a powerful means for expressing not only programs but also requirements, test cases and so on. However, a uniform compilation schema for sets has not yet been completely developed. The present paper tries to overcome this lack using a set-based logic language, SL( set language), as target. The approach is based on an imperative abstract machine, the SAM( set abstract machine). The translation from SL to SAL (SAM assembly language) is described and all the possible optimizations, both at source code level and at assembly code level, are detailed. The potentials for identifying parallel flows of computations are analysed. Several examples of compilations are presented and discussed.