ia-x86-test.lisp 1.24 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;    Copyright (C) 2003, Frode Vatvedt Fjeld <frodef@acm.org>
;; 
;; Filename:      ia-x86-test.lisp
;; Description:   Regression tests for the assembler
;; Author:        Nikodemus Siivola
;; Created at:    Wed Oct 20 23:13:46 1999
;;                
;; $Id: ia-x86-test.lisp,v 1.1.1.1 2004/01/12 14:19:00 ffjeld Exp $
;;                
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defpackage :ia-x86-test
  (:use :cl :ia-x86 :rt))

(in-package :ia-x86-test)

(deftest asm.1
    (asm :movl :eax :ebx)
  #C(#x89C3 #x2))

(defvar *proglist-1* '((:movl 10 :eax) loop 
		       (:decl :eax) 
		       (:je 'exit) 
		       (:jmp 'loop) exit))

(deftest read-proglist.1
    ;; KLUDGE: it's just simpler to compare the printed version here...
    (equal (with-output-to-string (s)
	     (prin1 (read-proglist *proglist-1*) s))
	  "(#<asm MOVL #xA => %EAX> LOOP #<asm DECL %EAX> #<asm JE 'EXIT> #<asm JMP 'LOOP>
 EXIT)")
  t)

(deftest proglist-encode.1
    (multiple-value-bind (a b) 
	(proglist-encode :octet-list :32-bit 0 (read-proglist *proglist-1*))
      (and (equal a '(#xB8 #xA #x0 #x0 #x0 #x48 #x74 #x2 #xEB #xFB))
	   (equal b '((EXIT . #xA) (LOOP . #x5)))))
  t)