From d6a1a234777d52614885de62fd64d1f3119d238b Mon Sep 17 00:00:00 2001 From: hachti Date: Mon, 24 Dec 2007 07:20:57 +0000 Subject: [PATCH] *** empty log message *** --- Makefile | 2 +- bin/asm | 8 +- bin/asm_original | 8 +- bin/frtn | 47 +++- bin/frtn_original | 60 +--- bin/mklink.sh | 2 +- lib/fortran/Makefile | 2 +- programs/first-steps/Makefile | 4 +- programs/fortran/Makefile | 3 +- programs/mandelbrot/Makefile | 5 +- programs/plotter/Makefile | 2 + programs/punchomat/Makefile | 33 ++- programs/small-things/Makefile | 13 +- programs/tools/Makefile | 13 +- resources/dap16-mode.el | 489 +++++++++++++++++++++++++++++++++ systems/dap/Makefile | 2 +- 16 files changed, 590 insertions(+), 103 deletions(-) create mode 100644 resources/dap16-mode.el diff --git a/Makefile b/Makefile index 8bf28a4..62e8d98 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SUBDIRS=pc-tools # Now we build the libraries which are always rebuild using the original compiler and # assembler tapes -SUBDIRS+=lib/iolib lib/fortran \ +SUBDIRS+=lib # Here we link the assembler - via a trick SUBDIRS+=systems/dap diff --git a/bin/asm b/bin/asm index d686a53..0fabd8d 100755 --- a/bin/asm +++ b/bin/asm @@ -2,11 +2,11 @@ # Assembler wrapper for simh h316 if [ ! $1 ] ; then - echo "Argument missing!" + echo -e "Assembler: Input file missing!" exit 2 fi -echo -e "\nAssembler: Translating \"$1\":" +echo -en "Assembler: Translating \"$1\":" for n in $*; do if [ $n == "/v" ]; then @@ -51,11 +51,11 @@ if cat $name.lst | grep "NO ERRORS IN ABOVE ASSEMBLY">/dev/null 2>&1; then rm -f $name.par rm -f $name.go fi - echo "Assembler: Success." + echo " Success." exit 0 fi cat $name.lst -echo -e "Assembler: Failed." +echo -e " FAILED!" rm -f $name.obj exit 77 diff --git a/bin/asm_original b/bin/asm_original index f6becc4..bc3f959 100755 --- a/bin/asm_original +++ b/bin/asm_original @@ -2,11 +2,11 @@ # Assembler wrapper for simh h316 if [ ! $1 ] ; then - echo "Argument missing!" + echo "Assembler (Original): Input file missing!" exit 2 fi -echo -e "\nAssembler: Translating \"$1\" (Original DAP-16 8K SLST):" +echo -en "Assembler (Original): Translating \"$1\":" for n in $*; do if [ $n == "/v" ]; then @@ -52,11 +52,11 @@ if cat $name.lst | grep "NO ERRORS IN ABOVE ASSEMBLY">/dev/null 2>&1; then rm -f $name.par rm -f $name.go fi - echo "Assembler: Success." + echo " Success." exit 0 fi cat $name.lst -echo -e "Assembler: Failed." +echo -e " Failed." rm -f $name.obj exit 77 diff --git a/bin/frtn b/bin/frtn index f89f7d1..31195a8 100755 --- a/bin/frtn +++ b/bin/frtn @@ -1,18 +1,57 @@ #!/bin/sh # FORTRAN IV compiler wrapper for simh h316 +if [ "$FRTN_ORIGINAL" ]; then + LOGNAME="FORTRAN IV COMPILER (Original):" +else + LOGNAME="FORTRAN IV COMPILER:" +fi + if [ ! $1 ] ; then - echo "Argument missing!" + echo "$LOGNAME Input file missing!" exit 2 fi name=`basename $1 .f` +if [ ! -f "$1" ]; then + echo "$LOGNAME Input file \"$name\" not found!" + exit 2 +fi + + listfile=$name.lst cat $1 | tab | paron > $name.par rm -f $name.lst rm -f $name.obj +echo -n "$LOGNAME Compiling \"$1\":" + +if [ "$FRTN_ORIGINAL" ]; then + +cat > $name.go < $name.go < /dev/null if cat $name.lst | egrep "[*]{36,40}">/dev/null 2>&1; then cat $name.lst - echo -e "\n\nFORTRAN IV compilation FAILED!" + echo -e " FAILED!" rm -f $name.obj exit 77 fi @@ -47,7 +88,7 @@ if [ ! $2 ]; then rm -f $name.par fi -echo "FORTRAN IV compilation successfull." +echo " Success." exit 0 diff --git a/bin/frtn_original b/bin/frtn_original index eb0faa9..2dfeede 100755 --- a/bin/frtn_original +++ b/bin/frtn_original @@ -1,59 +1,7 @@ -#!/bin/sh -# FORTRAN IV compiler wrapper for simh h316 - -if [ ! $1 ] ; then - echo "Argument missing!" - exit 2 -fi - -echo "Compiling $1 with original FORTRAN 8K!" - -name=`basename $1 .f` -listfile=$name.lst - -cat $1 | tab | paron > $name.par -rm -f $name.lst -rm -f $name.obj - -cat > $name.go < /dev/null - -if cat $name.lst | egrep "[*]{36,40}">/dev/null 2>&1; then - cat $name.lst - echo -e "\n\nFORTRAN IV compilation FAILED!" - rm -f $name.obj - exit 77 -fi - -if [ ! $2 ]; then - rm $name.lst - rm -f $name.go - rm -f $name.par - -fi -echo "FORTRAN IV compilation successfull." -exit 0 +#!/bin/bash +export FRTN_ORIGINAL=1 +frtn $@ +exit $? diff --git a/bin/mklink.sh b/bin/mklink.sh index 6c1a1d4..792a098 100755 --- a/bin/mklink.sh +++ b/bin/mklink.sh @@ -49,4 +49,4 @@ for nb in `ls $H316/lib/common | grep -v CVS`; do ln -s -f "$H316/lib/common/$n" $H316/lib/iolib ln -s -f "$H316/lib/common/$n" $H316/lib/hachti done - \ No newline at end of file + diff --git a/lib/fortran/Makefile b/lib/fortran/Makefile index fac03b8..d2c768c 100644 --- a/lib/fortran/Makefile +++ b/lib/fortran/Makefile @@ -57,7 +57,7 @@ $(OBJECT_FILES) : $(OBJ_DIR)/%.obj : $(SRC_DIR)/%.asm @ cd $(OBJ_DIR) && $(LDC_COMMAND) $(notdir $(subst $$,\$$,$@)) $(LIBS):$(LIB_DIR)/%.lib: $(RECIPE_DIR)/%$(RECIPE_SUFFIX) $(ORG_OBJECTS) $(OBJECTS) - ./buildlib.sh genlib $(RECIPE_DIR)/$(basename $(notdir $@))$(RECIPE_SUFFIX) + @./buildlib.sh genlib $(RECIPE_DIR)/$(basename $(notdir $@))$(RECIPE_SUFFIX) clean: # @echo Cleaning up. diff --git a/programs/first-steps/Makefile b/programs/first-steps/Makefile index 17cd216..9720a05 100644 --- a/programs/first-steps/Makefile +++ b/programs/first-steps/Makefile @@ -14,11 +14,11 @@ default: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.f @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(FRTN_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(FRTN_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.asm @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(ASM_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(ASM_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) clean : @rm -rf *.obj $(BUILD_DIR)/ *.lst *.go *.par diff --git a/programs/fortran/Makefile b/programs/fortran/Makefile index 9ce37a0..9676c7f 100644 --- a/programs/fortran/Makefile +++ b/programs/fortran/Makefile @@ -21,5 +21,4 @@ build/%.obj:src/%.f build/%.obj:src/%.asm @if [ ! -d build ]; then mkdir build; fi - $(ASM) '$^' - mv '$(notdir $@)' build + @ $(ASM) '$^' && mv '$(notdir $@)' build diff --git a/programs/mandelbrot/Makefile b/programs/mandelbrot/Makefile index 17cd216..52bf585 100644 --- a/programs/mandelbrot/Makefile +++ b/programs/mandelbrot/Makefile @@ -1,6 +1,5 @@ # Universal Makefile for X16 code - ASM_CMD=$(H316)/bin/asm FRTN_CMD=$(H316)/bin/frtn SRC_DIR=src @@ -14,11 +13,11 @@ default: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.f @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(FRTN_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(FRTN_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.asm @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(ASM_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(ASM_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) clean : @rm -rf *.obj $(BUILD_DIR)/ *.lst *.go *.par diff --git a/programs/plotter/Makefile b/programs/plotter/Makefile index ecbc0a4..199adff 100644 --- a/programs/plotter/Makefile +++ b/programs/plotter/Makefile @@ -14,10 +14,12 @@ $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.f @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi $(FRTN_CMD) $< $(LISTING) && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.asm @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi $(ASM_CMD) $< $(LISTING)&& mv $(notdir $(basename $<)).obj $(BUILD_DIR) + clean : @rm -rf *.obj $(BUILD_DIR)/ *.lst *.go *.par diff --git a/programs/punchomat/Makefile b/programs/punchomat/Makefile index 0301d13..686e7d1 100644 --- a/programs/punchomat/Makefile +++ b/programs/punchomat/Makefile @@ -1,20 +1,27 @@ -# Makefile für Apfelmännchenprogramm +# Universal Makefile for X16 code -ASM=$(H316)/bin/asm -FRTN=$(H316)/bin/frtn +ASM_CMD=$(H316)/bin/asm +FRTN_CMD=$(H316)/bin/frtn +SRC_DIR=src +BUILD_DIR=build -build/punchomat.obj : src/punchomat.f - @if [ ! -d build ]; then mkdir build; fi - $(FRTN) src/punchomat.f && mv punchomat.obj build +PROGRAMS=$(foreach n, $(wildcard $(SRC_DIR)/*.f $(SRC_DIR)/*.asm),$(notdir $(basename $(n)))) -clean : - @rm -rf *.obj build/ *.lst *.go *.par +default: all + +all: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) -.PHONY: default clean +$(BUILD_DIR)/%.obj:$(SRC_DIR)/%.f + @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi + @$(FRTN_CMD) "$(subst $$,\$$,$^)" &&\ + mv "$(notdir $(basename $(subst $$,\$$,$^))).obj" $(BUILD_DIR) +$(BUILD_DIR)/%.obj:$(SRC_DIR)/%.asm + @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi + @$(ASM_CMD) "$(subst $$,\$$,$^)" &&\ + mv "$(notdir $(basename "\"$(subst $$,\$$,$^)\"")).obj" $(BUILD_DIR) -%.obj:%.f - $(FRTN) $^ +clean : + @rm -rf *.obj $(BUILD_DIR)/ *.lst *.go *.par -%.obj:%.asm - $(ASM) $^ \ No newline at end of file +.PHONY: default clean all diff --git a/programs/small-things/Makefile b/programs/small-things/Makefile index 17cd216..686e7d1 100644 --- a/programs/small-things/Makefile +++ b/programs/small-things/Makefile @@ -1,6 +1,5 @@ # Universal Makefile for X16 code - ASM_CMD=$(H316)/bin/asm FRTN_CMD=$(H316)/bin/frtn SRC_DIR=src @@ -8,19 +7,21 @@ BUILD_DIR=build PROGRAMS=$(foreach n, $(wildcard $(SRC_DIR)/*.f $(SRC_DIR)/*.asm),$(notdir $(basename $(n)))) -#$(PROGRAMS):%:/$(BUILD_DIR)/%.f +default: all -default: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) +all: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.f @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(FRTN_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(FRTN_CMD) "$(subst $$,\$$,$^)" &&\ + mv "$(notdir $(basename $(subst $$,\$$,$^))).obj" $(BUILD_DIR) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.asm @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(ASM_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(ASM_CMD) "$(subst $$,\$$,$^)" &&\ + mv "$(notdir $(basename "\"$(subst $$,\$$,$^)\"")).obj" $(BUILD_DIR) clean : @rm -rf *.obj $(BUILD_DIR)/ *.lst *.go *.par -.PHONY: default clean +.PHONY: default clean all diff --git a/programs/tools/Makefile b/programs/tools/Makefile index 17cd216..686e7d1 100644 --- a/programs/tools/Makefile +++ b/programs/tools/Makefile @@ -1,6 +1,5 @@ # Universal Makefile for X16 code - ASM_CMD=$(H316)/bin/asm FRTN_CMD=$(H316)/bin/frtn SRC_DIR=src @@ -8,19 +7,21 @@ BUILD_DIR=build PROGRAMS=$(foreach n, $(wildcard $(SRC_DIR)/*.f $(SRC_DIR)/*.asm),$(notdir $(basename $(n)))) -#$(PROGRAMS):%:/$(BUILD_DIR)/%.f +default: all -default: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) +all: $(foreach prog, $(PROGRAMS),$(BUILD_DIR)/$(prog).obj) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.f @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(FRTN_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(FRTN_CMD) "$(subst $$,\$$,$^)" &&\ + mv "$(notdir $(basename $(subst $$,\$$,$^))).obj" $(BUILD_DIR) $(BUILD_DIR)/%.obj:$(SRC_DIR)/%.asm @if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi - $(ASM_CMD) $< && mv $(notdir $(basename $<)).obj $(BUILD_DIR) + @$(ASM_CMD) "$(subst $$,\$$,$^)" &&\ + mv "$(notdir $(basename "\"$(subst $$,\$$,$^)\"")).obj" $(BUILD_DIR) clean : @rm -rf *.obj $(BUILD_DIR)/ *.lst *.go *.par -.PHONY: default clean +.PHONY: default clean all diff --git a/resources/dap16-mode.el b/resources/dap16-mode.el new file mode 100644 index 0000000..52f1b8b --- /dev/null +++ b/resources/dap16-mode.el @@ -0,0 +1,489 @@ +;;; dap16-mode.el --- mode for editing DAP-16 assembler code + +;;; Commentary: + +;; This mode was written by Philipp Hachtmann . +;; It is based on the asm mode by Eric S. Raymond + +;; 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 +;; dap16-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 dap16-mode-set-comment-hook before the part of the initialization +;; depending on dap16-comment-char, and +;; 2) an dap16-mode-hook at the end of initialization. + +;;; Code: + +(defgroup dap16 nil + "DAP-16 Assembler programming" + :group 'languages) + +(defcustom dap16-comment-char ?* + "*The comment-start character assumed by Asm mode." + :type 'sexp + :group 'asm) + +;; XEmacs change (This is the primary difference, why was this +;; feature removed? -sb) +(defcustom dap16-support-c-comments-p nil + "*Support C style comments. If t C style comments will be +supported. This is mainly for the benefit of font-lock." + :type 'boolean + :group 'asm) + +(defcustom dap16-mode-syntax-table nil + "Syntax table used while in Asm mode.") + +(defvar dap16-mode-abbrev-table nil + "Abbrev table used while in Asm mode.") +(define-abbrev-table 'dap16-mode-abbrev-table ()) + +(defvar dap16-mode-map nil + "Keymap for Asm mode.") + +;;(if dap16-mode-map +;; nil + ;; XEmacs change + (setq dap16-mode-map (make-sparse-keymap 'dap16-mode-map)) + ;; Note that the comment character isn't set up until dap16-mode is called. + (define-key dap16-mode-map ":" 'dap16-colon) + (define-key dap16-mode-map "\C-h" 'dap16-backspace) + (define-key dap16-mode-map "\C-l" 'dap16-halfdelim) + (define-key dap16-mode-map "\M-l" 'dap16-fulldelim) + (define-key dap16-mode-map "\C-i" 'dap16-tabulator) + (define-key dap16-mode-map "\C-cc" 'dap16-comment-region) + (define-key dap16-mode-map "\C-c\C-c" 'dap16-comment-region) + (define-key dap16-mode-map "\C-a" 'beginning-of-line) + (define-key dap16-mode-map "\C-j" 'dap16-newline) + (define-key dap16-mode-map "\C-m" 'dap16-newline) +;; ) + +;;(defconst dap16-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.") + +;; XEmacs change +;;(put 'dap16-mode 'font-lock-defaults '(dap16-font-lock-keywords)) + +;;(defvar dap16-code-level-empty-comment-pattern nil) +;;(defvar dap16-flush-left-empty-comment-pattern nil) +;;(defvar dap16-inline-empty-comment-pattern nil) + +;;;###autoload +(defun dap16-mode () + "Major mode for editing Honeywell DAP-16 assembler code. +Features a private abbrev table and the following bindings: + +\\[dap16-colon]\toutdent a preceding label, tab to next tab stop. +\\[tab-to-tab-stop]\ttab to next tab stop. +\\[dap16-newline]\tnewline, then tab to next tab stop. +\\[dap16-comment]\tsmart placement of assembler comments. + +Turning on Asm mode runs the hook `dap16-mode-hook' at the end of initialization. + +Special commands: +\\{dap16-mode-map} +" + (interactive) + + (kill-all-local-variables) + + ;; The space after a comment char at the beginning of a line + (make-local-variable 'dap16-comment-space) + (setq dap16-comment-space " ") + + (setq mode-name "DAP-16") + (setq major-mode 'dap16-mode) + (setq local-abbrev-table dap16-mode-abbrev-table) + +;; (make-local-variable 'tab-stop-list) +;; (setq tab-stop-list '(6 12 30)) + +;;(defconst dap16-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.") + + + (setq dap16-font-lock-keywords + '( + (dap16-comment-matcher . font-lock-comment-face) +;; ("\\<[0-9]+H[^ \t\n]*\\>" . font-lock-keyword-face) + + ("^\\(\\(\\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)) +) + + + ) + + + (make-local-variable 'dap16-mode-syntax-table) + (setq dap16-mode-syntax-table (make-syntax-table)) + + (set-syntax-table dap16-mode-syntax-table) + + (make-local-variable 'font-lock-defaults) + + (setq font-lock-defaults '( + dap16-font-lock-keywords + nil + nil + ) + ) + + + + (run-hooks 'dap16-mode-set-comment-hook) + ;; Make our own local child of dap16-mode-map + ;; so we can define our own comment character. + + ;; XEmacs change + (let ((ourmap (make-sparse-keymap))) + (set-keymap-parents ourmap (list dap16-mode-map)) + (use-local-map ourmap)) + (local-set-key (vector dap16-comment-char) 'dap16-comment) + ;; XEmacs change + +;; (modify-syntax-entry dap16-comment-char "<" dap16-mode-syntax-table) +;; (modify-syntax-entry ?\n ">" dap16-mode-syntax-table) + +;; (modify-syntax-entry ?a "w" dap16-mode-syntax-table) + + +;; (let ((cs (regexp-quote (char-to-string dap16-comment-char)))) +;; (make-local-variable 'comment-start) +;; (setq comment-start (concat cs dap16-comment-space)) +;; (make-local-variable 'comment-start-skip) +;; (setq comment-start-skip (concat cs "+[ \t]*")) +;; (setq dap16-inline-empty-comment-pattern (concat "^.+" cs "+ *$")) +;; (setq dap16-code-level-empty-comment-pattern (concat "^[\t ]+" cs cs " *$")) +;; (setq dap16-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 'dap16-mode-hook)) + +(defun dap16-colon () + "Insert a colon; if it follows a label, delete the label's indentation." + (interactive) + (cond + ( (and (is-comment-line) (= (current-column) (length '(dap16-comment-char dap16-comment-space)))) + (dap16-comment-line) + (tab-to-tab-stop) + ) + + ( (and (not (is-comment-line)) (save-excursion (beginning-of-line) (looking-at "[ \t]+\\(\\sw\\|\\s_\\)+$"))) + (save-excursion (beginning-of-line) (delete-horizontal-space)) + (tab-to-tab-stop) + ) + + (t + (insert ":") + ) + ) + ) + + +;_____________________________________________________________________________________________ + +(defun col () + (+ 1 (current-column)) +) + +(defun fc-pos() + (save-excursion + (end-of-line) + (setq cstart (col)) + (while (> (col) 16) + (if (or (= (following-char) ? ) (= (following-char) ?\t) (= (following-char) ?\n)) + (setq cstart (col))) + (backward-char 1)) + ) + cstart +) + +(defun dap16-comment-matcher (limit) +;;(setq p1 (point)) +;;(setq p2 (+ 2 (point))) + + (setq success nil) + (setq end-of-buffer-exit nil) + + ;; Consume Newline characters if present. + (while (and (< (point) limit) (= (following-char) ?\n) ) (forward-char)) + + ;; Save first location to highlight + (setq p1 (point)) + (while (and (< (point) limit) (not (and (= (following-char) ?\n) success)) (not end-of-buffer-exit)) + (if (or (> (col) (fc-pos)) (is-comment-line)) + (progn (setq p2 (+ 1 (point))) + (if success nil (progn (setq success t) (setq p1 (- (point) 0)))))) + + (forward-char)) + + (if success (set-match-data (list (- p1 0) (- p2 0)))) + success +) + + +;_____________________________________________________________________________________________ + +(defun dap16-line-matches (pattern &optional withcomment) + (save-excursion + (beginning-of-line) + (looking-at pattern))) + +(defun dap16-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) dap16-comment-char) + (delete-backward-char 1)) + (delete-horizontal-space) + (if (bolp) + nil + (beginning-of-line) + (open-line 1)) + ) + + +(defun dap16-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 dap16-comment +repeatedly until you are satisfied with the kind of comment." + (interactive) + + (setq comment-start "") + + (cond + + ;; Blank line? Then start comment. + ((dap16-line-matches "^[ \t]*$") + (delete-horizontal-space) + (insert dap16-comment-char dap16-comment-space) + ) + + ;; Nonblank line with no comment chars in it? + ;; Then start a comment at the current comment column + ((and (= (col) 1) (is-comment-line)) + (dap16-comment-line) + ) + + ;; Flush-left comment present? Just insert character. +;; ((dap16-line-matches dap16-flush-left-empty-comment-pattern) +;; (insert dap16-comment-char)) + + ;; Fresh comment line?? + ((dap16-line-matches (format "^%c%s$" dap16-comment-char dap16-comment-space)) + (end-of-line) + (delete-backward-char (length dap16-comment-space)) + (insert dap16-comment-char dap16-comment-char) + (end-of-line) + ) + + + ;; Empty code-level comment already present? + ;; Then start flush-left comment, on line above if this one is nonempty. +;; ((dap16-line-matches dap16-code-level-empty-comment-pattern) +;; (dap16-pop-comment-level) +;; (insert dap16-comment-char dap16-comment-char comment-start)) + + ;; Empty comment ends line? + ;; Then make code-level comment, on line above if this one is nonempty. +;; ((dap16-line-matches dap16-inline-empty-comment-pattern) +;; (dap16-pop-comment-level) +;; (tab-to-tab-stop) +;; (insert dap16-comment-char comment-start)) + + ;; If all else fails, insert character + (t + (insert dap16-comment-char)) + + ) + + ) + +;; **************************************************************************** + + +(defun pos-in-line () + (- (point) (save-excursion (beginning-of-line) (point)))) + + +;; Muss verbessert werden! +(defun at-begin-of-line () +;; (interactive) +;; (setq pos (point) ) +;;(save-excursion +;; (beginning-of-line) +;; (if (= pos (point)) t nil) +;; ) +;;) + (interactive) + (if (= 0 (current-column)) t nil)) + + +(defun is-comment-line () + (if (dap16-line-matches (format "^%c" dap16-comment-char)) + t + nil) +) + +(defun in-comment-spacing () + (if (> (current-column) (length (format "%c%s" dap16-comment-char dap16-comment-space))) nil t) +) + +(defun dap16-comment-line() + (interactive) + (if (is-comment-line) + (save-excursion + (beginning-of-line) + (delete-char 1) + (if (looking-at "^ ") + (delete-char 1) + ) + ) + (save-excursion (beginning-of-line) (insert dap16-comment-char dap16-comment-space)) + ) +) + +(defun line-start() + (save-excursion + (beginning-of-line) + (point) + ) +) + + +(defun line-end() + (save-excursion + (end-of-line) + (point) + ) +) + +(defun dap16-comment-region() + (interactive) + + (if (not (region-active-p)) (dap16-comment-line) + (save-excursion + (goto-char (region-end)) + (setq lastline (line-number)) + (goto-char (region-beginning)) + (while (< (line-number) lastline) + (dap16-comment-line) + (next-line 1) + )))) + + +(defun dap16-backspace () + (interactive) + (if (and (is-comment-line) (in-comment-spacing)) + (delete-region (max (- (line-start) 1) 1) (point)) + (delete-backward-char 1) + ) +;;delete-backward-char (length (format "%c%s" dap16-comment-char dap16-comment-space))) (tab-to-tab-stop)) +;; (delete-backward-char 1) + ) + +(defun dap16-fulldelim () + (interactive) + (make-local-variable 'count) + (setq count 0) + (if (dap16-line-matches (format "^%c%s$" dap16-comment-char dap16-comment-space)) + (progn (setq count 1) + (end-of-line) + (delete-backward-char (length dap16-comment-space))) + ) + + (while (< count 80) + (insert dap16-comment-char) + (setq count ( 1+ count))) +) + + +(defun dap16-halfdelim () + (interactive) + (make-local-variable 'count) + (setq count 0) + (if (dap16-line-matches (format "^%c%s$" dap16-comment-char dap16-comment-space)) + (progn (setq count 1) + (end-of-line) + (delete-backward-char (length dap16-comment-space))) + ) + + (while (< count 40) + (insert dap16-comment-char) + (setq count ( 1+ count))) + +) + + +(defun dap16-tabulator () + (interactive) + (if (is-comment-line) + (progn + (setq target (prog2 (insert "\t") (current-column) (delete-backward-char 1) )) + (while (< (current-column) target) (insert " ")) + ) + + (tab-to-tab-stop) + ) +) + + +(defun dap16-newline () + "Insert LFD + fill-prefix, to bring us back to code-indent level." + (interactive) + + (if (is-comment-line) + (progn + (if (at-begin-of-line) (goto-char (+ (point) 1))) + (insert "\n" dap16-comment-char dap16-comment-space)) + ;; Not comment line + (if (eolp) + (progn (delete-horizontal-space) + (insert "\n") + (tab-to-tab-stop) + ) + (insert "\n") + ;; (tab-to-tab-stop) + ) + ) +) + + +;; XEmacs addition +;;;###autoload(add-to-list 'auto-mode-alist '("\\.[sS]\\'" . dap16-mode)) +;;;###autoload(add-to-list 'auto-mode-alist '("\\.asm\\'" . dap16-mode)) + +;;; dap16-mode.el ends here diff --git a/systems/dap/Makefile b/systems/dap/Makefile index 8e06533..2f91820 100644 --- a/systems/dap/Makefile +++ b/systems/dap/Makefile @@ -2,7 +2,7 @@ # first! default: - $(MAKE) -C .. dap.sys + @$(MAKE) -C .. dap.sys clean: -- 2.32.0