From: plugd Date: Mon, 15 Nov 2021 11:38:02 +0000 (+0100) Subject: Added get/set obj attribute functions. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=47796b39b839f4deef292d8c7ef293b72712d414;p=ez.git Added get/set obj attribute functions. --- diff --git a/ez.el b/ez.el index ac40980..549b8f0 100644 --- a/ez.el +++ b/ez.el @@ -196,6 +196,25 @@ (t (ez-mem-set-word (+ prop-addr 1) value))))) +(defun ez-get-obj-attr (obj attr) + (let* ((byte-num (/ attr 8)) + (bit-num (mod attr 8)) + (bit-mask (lsh 1 (- 7 bit-num)))) + (if (> (logand bit-mask (ez-mem-ref-byte (+ (ez-get-obj-addr obj) byte-num))) 0) + 1 + 0))) + +(defun ez-set-obj-attr (obj attr val) + (let* ((byte-num (/ attr 8)) + (bit-num (mod attr 8)) + (bit-mask (lsh 1 (- 7 bit-num))) + (byte-addr (+ (ez-get-obj-addr obj) byte-num)) + (byte (ez-mem-ref-byte byte-addr)) + (current-set (> (logand bit-mask byte) 0))) + (if (or (and current-set (= val 0)) + (and (not current-set) (> val 0))) + (ez-mem-set-byte byte-addr (logxor byte bit-mask))))) + ;; Z-strings (defvar ez-zstring-alphabets @@ -378,7 +397,9 @@ operand-types '(w))) ((<= #xB0 opbyte #xBF) (setq optype '0op - opcode (- opbyte #xb0))) + opcode (- opbyte #xb0) + operands '() + operand-types '())) ((<= #xC0 opbyte #xDF) (error "Unsupported op %x" opbyte)) ((<= #xE0 opbyte #xFF) @@ -392,8 +413,8 @@ (error "Unsupported op PC:%x Optype:%s Opcode:%x Operands:%s Operand-types:%s" instr-pc optype opcode operands operand-types)) (let ((mnemonic (elt table-row 1))) - (message "PC:%x Optype:%s Opcode:%x Mnemonic:%s Operands:%s" - instr-pc optype opcode mnemonic operands)) + (message "PC:%x Optype:%s Opcode:%x Mnemonic:%s Operands:%s Operand-types:%s" + instr-pc optype opcode mnemonic operands operand-types)) (funcall (elt table-row 2) operands operand-types)))) (defun ez-read-var-operands-and-inc () @@ -413,8 +434,7 @@ (let ((type4 (logand #b11))) (if (= type4 #b11) nil - (list type4))))))))))))) - (operands nil)) + (list type4)))))))))))))) (cons (mapcar (lambda (type)