3 ;;; Mes --- Maxwell Equations of Software
4 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; scm.mes: This file is part of Mes.
8 ;;; Mes is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; Mes is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
21 (define (i386:puts data length)
23 #xba ,@(int->bv32 length) ;; mov $0xe,%edx
24 #xb9 ,@(int->bv32 data) ;; mov $data,%ecx
25 #xbb #x01 #x00 #x00 #x00 ;; mov $0x1,%ebx
26 #xb8 #x04 #x00 #x00 #x00 ;; mov $0x4,%eax
27 #xcd #x80 ;; int $0x80
30 (define (i386:exit code)
32 #xbb ,@(int->bv32 code) ;; mov $code,%ebx
33 #xb8 #x01 #x00 #x00 #x00 ;; mov $0x1,%eax
34 #xcd #x80 ;; int $0x80
38 (string->list "Hello, world!\n"))
42 (i386:puts d (length data))
46 (define (write-any x) (write-char (if (char? x) x (integer->char x))))
47 (map write-any (make-elf text data))