(emit-mod-reg-r/m-byte segment #b11 reg (reg-tn-encoding thing)))
(stack
;; Convert stack tns into an index off of EBP.
- (let ((disp (- (* (1+ (tn-offset thing)) n-word-bytes))))
+ (let ((disp (frame-byte-offset (tn-offset thing))))
(cond ((<= -128 disp 127)
(emit-mod-reg-r/m-byte segment #b01 reg #b101)
(emit-byte segment disp))
(emit-word segment value))
(:dword
(emit-dword segment value))))
+
+(defun toggle-word-width (chunk inst stream dstate)
+ (declare (ignore chunk inst stream))
+ (let ((word-width (or (sb!disassem:dstate-get-prop dstate 'word-width)
+ +default-operand-size+)))
+ (setf (sb!disassem:dstate-get-prop dstate 'word-width)
+ (ecase word-width
+ (:word :dword)
+ (:dword :word)))))
+
+;;; This is a "prefix" instruction, which means that it modifies the
+;;; following instruction in some way without having an actual
+;;; mnemonic of its own.
+(define-instruction operand-size-prefix (segment)
+ (:printer byte ((op +operand-size-prefix-byte+))
+ nil ; don't actually print it
+ :control #'toggle-word-width))
\f
;;;; general data transfer
\f
(define-instruction fs-segment-prefix (segment)
+ (:printer byte ((op #b01100100)))
(:emitter
(emit-byte segment #x64)))
+(define-instruction gs-segment-prefix (segment)
+ (:printer byte ((op #b01100101)))
+ (:emitter
+ (emit-byte segment #x65)))
+
;;;; flag control instructions
;;; CLC -- Clear Carry Flag.