help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: major mode for mips assembly


From: Lars Kristiansson
Subject: Re: major mode for mips assembly
Date: Thu, 07 Mar 2002 13:42:00 +0100

Hi!

I don't know if this helps very much, maybe this is something You have
already. I have merged my lisp-files from the Emacs20.7 shipment with my
lisp-files from the University, so I don't know if it's new or not. Moreover I
don't know if it is complete. It's running in my Emacs anyway. Tell me if any
file is missing, and I'll look again.

Here they are anyway. They are located in Emacs20.7/progmodes. Do a recompile
of it for security.

This worked fine when I attended a course using MipsPRO Assembler. I felt
content with it. Anyway it's a start.

jlf wrote:

> hello all, i've gone through recent archives of this mailing list (it
> would be nice to add search capabilities on this.....) but was not able to
> locate a major (or even minor) mode for working with mips assembly.  i've
> searched through google, but without any success.  does anyone have an .el
> that they would share with me?  :-)
>
> thanks in advance,
> -jesse
>
> _______________________________________________
> Help-gnu-emacs mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

--
address@hidden v2.0__

Dr_Xemacs tuggar p氓 en klantig tr盲sko !!
- address@hidden goes krazy]

address@hidden, the one and only!         (aka Lars Kristiansson)
address@hidden           address@hidden
http://hem.fyristorg.com/dr_xemacs            ICQ : 25152178

;;; asm-mode.el --- mode for editing assembler code

;; Copyright (C) 1991 Free Software Foundation, Inc.

;; Author: Eric S. Raymond <address@hidden>
;; Maintainer: FSF
;; Keywords: tools, languages

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; This mode was written by Eric S. Raymond <address@hidden>,
;; inspired by an earlier asm-mode by Martin Neitzel.

;; This minor mode is based on text mode.  It defines a private abbrev table
;; that can be used to save abbrevs for assembler mnemonics.  It binds just
;; five keys:
;;
;;      TAB             tab to next tab stop
;;      :               outdent preceding label, tab to tab stop
;;      comment char    place or move comment
;;                      asm-comment-char specifies which character this is;
;;                      you can use a different character in different
;;                      Asm mode buffers.
;;      C-j, C-m        newline and tab to tab stop
;;
;; Code is indented to the first tab stop level.

;; This mode runs two hooks:
;;   1) An asm-mode-set-comment-hook before the part of the initialization
;; depending on asm-comment-char, and
;;   2) an asm-mode-hook at the end of initialization.

;;; Code:

(defgroup asm nil
  "Mode for editing assembler code."
  :group 'languages)

(defcustom asm-comment-char ?\;
  "*The comment-start character assumed by Asm mode."
  :type 'character
  :group 'asm)

(defvar asm-mode-syntax-table nil
  "Syntax table used while in Asm mode.")

(defvar asm-mode-abbrev-table nil
  "Abbrev table used while in Asm mode.")
(define-abbrev-table 'asm-mode-abbrev-table ())

(defvar asm-mode-map nil
  "Keymap for Asm mode.")

(if asm-mode-map
    nil
  (setq asm-mode-map (make-sparse-keymap))
  ;; Note that the comment character isn't set up until asm-mode is called.
  (define-key asm-mode-map ":"          'asm-colon)
  (define-key asm-mode-map "\C-c;"      'comment-region)
  (define-key asm-mode-map "\C-i"       'tab-to-tab-stop)
  (define-key asm-mode-map "\C-j"       'asm-newline)
  (define-key asm-mode-map "\C-m"       'asm-newline)
  )

(defconst asm-font-lock-keywords
 '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\)?"
    (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t))
   ("^\\s +\\(\\(\\sw\\|\\s_\\)+\\)" 1 font-lock-keyword-face))
 "Additional expressions to highlight in Assembler mode.")

(defvar asm-code-level-empty-comment-pattern nil)
(defvar asm-flush-left-empty-comment-pattern nil)
(defvar asm-inline-empty-comment-pattern nil)

;;;###autoload
(defun asm-mode ()
  "Major mode for editing typical assembler code.
Features a private abbrev table and the following bindings:

\\[asm-colon]\toutdent a preceding label, tab to next tab stop.
\\[tab-to-tab-stop]\ttab to next tab stop.
\\[asm-newline]\tnewline, then tab to next tab stop.
\\[asm-comment]\tsmart placement of assembler comments.

The character used for making comments is set by the variable
`asm-comment-char' (which defaults to `?\\;').

Alternatively, you may set this variable in `asm-mode-set-comment-hook',
which is called near the beginning of mode initialization.

Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization.

Special commands:
\\{asm-mode-map}
"
  (interactive)
  (kill-all-local-variables)
  (setq mode-name "Assembler")
  (setq major-mode 'asm-mode)
  (setq local-abbrev-table asm-mode-abbrev-table)
  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults '(asm-font-lock-keywords))
  (make-local-variable 'asm-mode-syntax-table)
  (setq asm-mode-syntax-table (make-syntax-table))
  (set-syntax-table asm-mode-syntax-table)

  (run-hooks 'asm-mode-set-comment-hook)
  ;; Make our own local child of asm-mode-map
  ;; so we can define our own comment character.
  (use-local-map (nconc (make-sparse-keymap) asm-mode-map))
  (local-set-key (vector asm-comment-char) 'asm-comment)

  (modify-syntax-entry  asm-comment-char
                        "<" asm-mode-syntax-table)
  (modify-syntax-entry  ?\n
                         ">" asm-mode-syntax-table)
  (let ((cs (regexp-quote (char-to-string asm-comment-char))))
    (make-local-variable 'comment-start)
    (setq comment-start (concat cs " "))
    (make-local-variable 'comment-start-skip)
    (setq comment-start-skip (concat cs "+[ \t]*"))
    (setq asm-inline-empty-comment-pattern (concat "^.+" cs "+ *$"))
    (setq asm-code-level-empty-comment-pattern (concat "^[\t ]+" cs cs " *$"))
    (setq asm-flush-left-empty-comment-pattern (concat "^" cs cs cs " *$"))
    )
  (make-local-variable 'comment-end)
  (setq comment-end "")
  (make-local-variable 'comment-column)
  (setq comment-column 32)
  (setq fill-prefix "\t")
  (run-hooks 'asm-mode-hook))

(defun asm-colon ()
  "Insert a colon; if it follows a label, delete the label's indentation."
  (interactive)
  (save-excursion
    (beginning-of-line)
    (if (looking-at "[ \t]+\\(\\sw\\|\\s_\\)+$")
        (delete-horizontal-space)))
  (insert ":")
  (tab-to-tab-stop)
  )

(defun asm-newline ()
  "Insert LFD + fill-prefix, to bring us back to code-indent level."
  (interactive)
  (if (eolp) (delete-horizontal-space))
  (insert "\n")
  (tab-to-tab-stop)
  )

(defun asm-line-matches (pattern &optional withcomment)
  (save-excursion
    (beginning-of-line)
    (looking-at pattern)))

(defun asm-pop-comment-level ()
  ;; Delete an empty comment ending current line.  Then set up for a new one,
  ;; on the current line if it was all comment, otherwise above it
  (end-of-line)
  (delete-horizontal-space)
  (while (= (preceding-char) asm-comment-char)
    (delete-backward-char 1))
  (delete-horizontal-space)
  (if (bolp)
      nil
    (beginning-of-line)
    (open-line 1))
  )


(defun asm-comment ()
  "Convert an empty comment to a `larger' kind, or start a new one.
These are the known comment classes:

   1 -- comment to the right of the code (at the comment-column)
   2 -- comment on its own line, indented like code
   3 -- comment on its own line, beginning at the left-most column.

Suggested usage:  while writing your code, trigger asm-comment
repeatedly until you are satisfied with the kind of comment."
  (interactive)
  (cond

   ;; Blank line?  Then start comment at code indent level.
   ((asm-line-matches "^[ \t]*$")
    (delete-horizontal-space)
    (tab-to-tab-stop)
    (insert asm-comment-char comment-start))

   ;; Nonblank line with no comment chars in it?
   ;; Then start a comment at the current comment column
   ((asm-line-matches (format "^[^%c\n]+$" asm-comment-char))
    (indent-for-comment))

   ;; Flush-left comment present?  Just insert character.
   ((asm-line-matches asm-flush-left-empty-comment-pattern)
    (insert asm-comment-char))

   ;; Empty code-level comment already present?
   ;; Then start flush-left comment, on line above if this one is nonempty. 
   ((asm-line-matches asm-code-level-empty-comment-pattern)
    (asm-pop-comment-level)
    (insert asm-comment-char asm-comment-char comment-start))

   ;; Empty comment ends line?
   ;; Then make code-level comment, on line above if this one is nonempty. 
   ((asm-line-matches asm-inline-empty-comment-pattern)
    (asm-pop-comment-level)
    (tab-to-tab-stop)
    (insert asm-comment-char comment-start))

   ;; If all else fails, insert character
   (t
    (insert asm-comment-char))

   )
  (end-of-line))

(provide 'asm-mode)

;;; asm-mode.el ends here
;ELC
;;; Compiled by address@hidden on Mon Jun 12 21:40:03 2000
;;; from file /u2/emacs-20.7/lisp/progmodes/asm-mode.el
;;; in Emacs version 20.7.1
;;; with bytecomp version 2.56
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
         (< (aref emacs-version (1- (length emacs-version))) ?A)
         (or (and (boundp 'epoch::version) epoch::version)
             (string-lessp emacs-version "19.29")))
    (error "`asm-mode.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(custom-declare-group 'asm nil "Mode for editing assembler code." :group 
'languages)
address@hidden *The comment-start character assumed by Asm mode.
(custom-declare-variable 'asm-comment-char '59 '(#$ . -691) :type 'character 
:group 'asm)
address@hidden Syntax table used while in Asm mode.
(defvar asm-mode-syntax-table nil (#$ . 837))
address@hidden Abbrev table used while in Asm mode.
(defvar asm-mode-abbrev-table nil (#$ . 926))
(define-abbrev-table 'asm-mode-abbrev-table nil)
address@hidden Keymap for Asm mode.
(defvar asm-mode-map nil (#$ . 1064))
(byte-code "\204%\301 
\302\303\304#\210\302\305\306#\210\302\307\310#\210\302\311\312#\210\302\313\312#\210\301\207"
 [asm-mode-map make-sparse-keymap define-key ":" asm-colon ";" comment-region 
"    " tab-to-tab-stop "\n" asm-newline "
"] 4)
address@hidden Additional expressions to highlight in Assembler mode.
(defconst asm-font-lock-keywords '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[    
]*\\(\\sw+\\)?" (1 font-lock-function-name-face) (3 font-lock-keyword-face nil 
t)) ("^\\s +\\(\\(\\sw\\|\\s_\\)+\\)" 1 font-lock-keyword-face)) (#$ . 1377))
(byte-code "\304\300!\204\305\300    B\304\302!\204\305\302      
B\304\303!\204 \305\303      B\305\207" 
[asm-code-level-empty-comment-pattern current-load-list 
asm-flush-left-empty-comment-pattern asm-inline-empty-comment-pattern boundp 
nil] 2)
address@hidden Major mode for editing typical assembler code.
Features a private abbrev table and the following bindings:

\[asm-colon]    outdent a preceding label, tab to next tab stop.
\[tab-to-tab-stop]      tab to next tab stop.
\[asm-newline]  newline, then tab to next tab stop.
\[asm-comment]  smart placement of assembler comments.

The character used for making comments is set by the variable
`asm-comment-char' (which defaults to `?\;').

Alternatively, you may set this variable in `asm-mode-set-comment-hook',
which is called near the beginning of mode initialization.

Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization.

Special commands:
\{asm-mode-map}

(defalias 'asm-mode #[nil "\306 
\210\307\310\n\311\304!\210\312\311\305!\210\313 \314
!\210\315\316!\210\317\320 )\244!\210\321\322*!\323\"\210\324*\325
#\210\324\326\327
#\210\330\331*!!+\311\332!\210+\333P\311\334!\210+\335P\336+\337Q,\340+\211\341R-\342+\211\211\341\260.)\311\343!\210\344#\311\345!\210\346%\347/\315\350!\207"
 [mode-name major-mode asm-mode-abbrev-table local-abbrev-table 
font-lock-defaults asm-mode-syntax-table kill-all-local-variables "Assembler" 
asm-mode make-local-variable (asm-font-lock-keywords) make-syntax-table 
set-syntax-table run-hooks asm-mode-set-comment-hook use-local-map 
make-sparse-keymap local-set-key vector asm-comment modify-syntax-entry "<" 10 
">" regexp-quote char-to-string comment-start " " comment-start-skip "+[       
]*" "^.+" "+ *$" "^[     ]+" " *$" "^" comment-end "" comment-column 32 "       
" asm-mode-hook asm-mode-map asm-comment-char cs 
asm-inline-empty-comment-pattern asm-code-level-empty-comment-pattern 
asm-flush-left-empty-comment-pattern fill-prefix] 5 (#$ . 1910) nil])
address@hidden Insert a colon; if it follows a label, delete the label's 
indentation.
(defalias 'asm-colon #[nil "\212\300y\210\301\302!\203
\303 \210)\304c\210\305 \207" [0 looking-at "[         ]+\\(\\sw\\|\\s_\\)+$" 
delete-horizontal-space ":" tab-to-tab-stop] 2 (#$ . 3641) nil])
address@hidden Insert LFD + fill-prefix, to bring us back to code-indent level.
(defalias 'asm-newline #[nil "l\203\300 \210\301c\210\302 \207" 
[delete-horizontal-space "\n" tab-to-tab-stop] 1 (#$ . 3910) nil])
(defalias 'asm-line-matches #[(pattern &optional withcomment) 
"\212\301y\210\302!)\207" [pattern 0 looking-at] 2])
(defalias 'asm-pop-comment-level #[nil "\301\210\302 
\210hU\203\303\304!\210\202\302 \210n?\205!\305y\210\306\304!\207" 
[asm-comment-char nil delete-horizontal-space delete-backward-char 1 0 
open-line] 2])
address@hidden Convert an empty comment to a `larger' kind, or start a new one.
These are the known comment classes:

   1 -- comment to the right of the code (at the comment-column)
   2 -- comment on its own line, indented like code
   3 -- comment on its own line, beginning at the left-most column.

Suggested usage:  while writing your code, trigger asm-comment
repeatedly until you are satisfied with the kind of comment.
(defalias 'asm-comment #[nil "\305\306!\203\307 \210\310 \210        
\261\210\202X\305\311\312\"!\203#\313 
\210\202X\305\n!\203/c\210\202X\305!\203A\314 \210\211 
\261\210\202X\305\f!\203U\314 \210\310 \210 \261\210\202Xc\210\315\207" 
[asm-comment-char comment-start asm-flush-left-empty-comment-pattern 
asm-code-level-empty-comment-pattern asm-inline-empty-comment-pattern 
asm-line-matches "^[         ]*$" delete-horizontal-space tab-to-tab-stop 
format "^[^%c\n]+$" indent-for-comment asm-pop-comment-level nil] 4 (#$ . 4444) 
nil])
(provide 'asm-mode)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]