branch: externals/beardbolt commit 5ab75b7f56c7f2c9e675e744d622cc9bb6500da2 Author: Jay Kamat <jaygka...@gmail.com> Commit: Jay Kamat <jaygka...@gmail.com>
Add stubs for dissasembly --- rmsbolt.el | 97 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/rmsbolt.el b/rmsbolt.el index eaf1772cd8..5247984008 100644 --- a/rmsbolt.el +++ b/rmsbolt.el @@ -29,12 +29,6 @@ (require 'subr-x) (require 'map) -(defconst +rmsbolt-compile-name+ "rmsbolt-compile") - -(defconst +rmsbolt-assembler-pattern+ (rx bol (1+ space) - "." (1+ (not (any ";"))) - (0+ space) eol)) - ;;; Code: ;;;; Variables: (defvar rmsbolt-temp-dir nil @@ -50,6 +44,7 @@ (defvar rmsbolt-filter-asm-directives t) (defvar rmsbolt-filter-unused-labels t) (defvar rmsbolt-filter-comment-only t) +(defvar rmsbolt-dissasemble nil) ;;;; Regexes @@ -64,9 +59,8 @@ (0+ (any "a-zA-Z0-9$_.")))) (defvar rmsbolt-assignment-def (rx bol (0+ space) - (group - (any ".a-zA-Z_$") - (1+ (any "a-zA-Z0-9$_."))) + (group (any ".a-zA-Z_$") + (1+ (any "a-zA-Z0-9$_."))) (0+ space) "=")) (defvar rmsbolt-has-opcode (rx bol (0+ space) (any "a-zA-Z"))) @@ -305,47 +299,52 @@ int main() { (setq completed t)))) labels-used))) -(defun rmsbolt--process-asm-lines (asm-lines) +(defun rmsbolt--process-dissasembled-lines (asm-lines) + ) + +(cl-defun rmsbolt--process-asm-lines (asm-lines) "Process and filter a set of asm lines." - (let ((used-labels (rmsbolt--find-used-labels asm-lines)) - (result nil) - (prev-label nil)) - (dolist (line asm-lines) - (let* ((raw-match (or (string-match rmsbolt-label-def line) - (string-match rmsbolt-assignment-def line))) - (match (when raw-match - (match-string 1 line))) - (used-label (cl-find match used-labels :test #'equal))) - (cl-tagbody - ;; End block, reset prev-label and source - (when (string-match-p rmsbolt-endblock line) - (setq prev-label nil)) - - (when (and rmsbolt-filter-comment-only - (string-match-p rmsbolt-comment-only line)) - (go continue)) - - ;; continue means we don't add to the ouptut - (when match - (if (not used-label) - ;; Unused label - (when rmsbolt-filter-unused-labels - (go continue)) - ;; Real label, set prev-label - (setq prev-label raw-match))) - (when (and rmsbolt-filter-asm-directives - (not match)) - (if (and (string-match-p rmsbolt-data-defn line) - prev-label) - ;; data is being used - nil - (when (string-match-p rmsbolt-directive line) - (go continue)))) - (push line result) - continue))) - (mapconcat 'identity - (nreverse result) - "\n"))) + (if rmsbolt-dissasemble + (rmsbolt--process-dissasembled-lines asm-lines) + (let ((used-labels (rmsbolt--find-used-labels asm-lines)) + (result nil) + (prev-label nil)) + (dolist (line asm-lines) + (let* ((raw-match (or (string-match rmsbolt-label-def line) + (string-match rmsbolt-assignment-def line))) + (match (when raw-match + (match-string 1 line))) + (used-label (cl-find match used-labels :test #'equal))) + (cl-tagbody + ;; End block, reset prev-label and source + (when (string-match-p rmsbolt-endblock line) + (setq prev-label nil)) + + (when (and rmsbolt-filter-comment-only + (string-match-p rmsbolt-comment-only line)) + (go continue)) + + ;; continue means we don't add to the ouptut + (when match + (if (not used-label) + ;; Unused label + (when rmsbolt-filter-unused-labels + (go continue)) + ;; Real label, set prev-label + (setq prev-label raw-match))) + (when (and rmsbolt-filter-asm-directives + (not match)) + (if (and (string-match-p rmsbolt-data-defn line) + prev-label) + ;; data is being used + nil + (when (string-match-p rmsbolt-directive line) + (go continue)))) + (push line result) + continue))) + (mapconcat 'identity + (nreverse result) + "\n")))) ;;;;; Handlers (defun rmsbolt--handle-finish-compile (buffer _str)