registers.lisp 2.83 KB
Newer Older
1 2
;;;;------------------------------------------------------------------
;;;; 
3
;;;;    Copyright (C) 2000, 2004,
4
;;;;    Department of Computer Science, University of Tromso, Norway
5
;;;; 
6
;;;; Filename:      registers.lisp
7 8 9 10 11
;;;; Description:   
;;;; Author:        Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at:    Tue Aug  1 10:24:59 2000
;;;; Distribution:  See the accompanying file COPYING.
;;;;                
12
;;;; $Id: registers.lisp,v 1.2 2004/01/16 11:54:14 ffjeld Exp $
13 14 15
;;;;                
;;;;------------------------------------------------------------------

16
(in-package #:ia-x86)
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

;;; ----------------------------------------------------------------
;;;                    Register sets
;;; ----------------------------------------------------------------

(defvar *register-decoder-sets* (make-hash-table :test #'eq))
(defvar *register-encoder-sets* (make-hash-table :test #'eq))

(defmacro def-register-set (name-list set)
  `(let ((dec-set (make-decoder-set ,@set))
	 (enc-set (make-encoder-set ,@set)))
     (loop for name in ',name-list
	 do (setf (gethash name *register-decoder-sets*) dec-set)
	    (setf (gethash name *register-encoder-sets*) enc-set))))

(defun find-register-decode-set (name)
  (let ((rs (gethash name *register-decoder-sets*)))
    (unless rs (error "Register set ~A not found." name))
    rs))

(defun find-register-encode-set (name)
  (let ((rs (gethash name *register-encoder-sets*)))
    (unless rs (error "Register set ~A not found." name))
    rs))

(def-register-set (r/m32-00)
    ((0 eax) 
     (1 ecx)
     (2 edx)
     (3 ebx)
     (6 esi)
     (7 edi)))

(def-register-set (r/m32-01 sib-index)
    ((0 eax) 
     (1 ecx)
     (2 edx)
     (3 ebx)
     (5 ebp)
     (6 esi)
     (7 edi)))

(def-register-set (sib-base-00)
    ((0 eax) 
     (1 ecx)
     (2 edx)
     (3 ebx)
     (4 esp)
     (6 esi)
     (7 edi)))

(def-register-set (r32 +r32 r/m32 sib-base)
    ((0 eax) 
     (1 ecx)
     (2 edx)
     (3 ebx)
     (4 esp)
     (5 ebp)
     (6 esi)
     (7 edi)))

(def-register-set (r8 +r8 r/m8)
    ((0 al)
     (1 cl)
     (2 dl)
     (3 bl)
     (4 ah)
     (5 ch)
     (6 dh)
     (7 bh)))

(def-register-set (r16 +r16 r/m16)
    ((0 ax)
     (1 cx)
     (2 dx)
     (3 bx)
     (4 sp)
     (5 bp)
     (6 si)
     (7 di)))

(def-register-set (sreg)		; page 11-9 in IISR
    ((0 es)
     (1 cs)
     (2 ss)
     (3 ds)
     (4 fs)
     (5 gs)))

(def-register-set (r/m-16bit)
    ((0 (bx . si))
     (1 (bx . di))
     (2 (bp . si))
     (3 (bp . di))
     (4 (si . nil))
     (5 (di . nil))
     (6 (bp . nil))
     (7 (bx . nil))))

(def-register-set (mm mm/m64)
    ((0 mm0)
     (1 mm1)
     (2 mm2)
     (3 mm3)
     (4 mm4)
     (5 mm5)
     (6 mm6)
     (7 mm7)))

(def-register-set (xmm xmm/m128 xmm/m64 xmm/m32)
    ((0 xmm0)
     (1 xmm1)
     (2 xmm2)
     (3 xmm3)
     (4 xmm4)
     (5 xmm5)
     (6 xmm6)
     (7 xmm7)))