;;; -*-scheme-*- ;;; Mes --- Maxwell Equations of Software ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; ;;; scm.mes: This file is part of Mes. ;;; ;;; Mes is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; Mes is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with Mes. If not, see . (define (i386:puts data length) `( #xba ,@(int->bv32 length) ;; mov $0xe,%edx #xb9 ,@(int->bv32 data) ;; mov $data,%ecx #xbb #x01 #x00 #x00 #x00 ;; mov $0x1,%ebx #xb8 #x04 #x00 #x00 #x00 ;; mov $0x4,%eax #xcd #x80 ;; int $0x80 )) (define (i386:exit code) `( #xbb ,@(int->bv32 code) ;; mov $code,%ebx #xb8 #x01 #x00 #x00 #x00 ;; mov $0x1,%eax #xcd #x80 ;; int $0x80 )) (define data (string->list "Hello, world!\n")) (define (text d) (append (i386:puts d (length data)) (i386:exit 0) )) (define (write-any x) (write-char (if (char? x) x (integer->char x)))) (map write-any (make-elf text data))