home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-3.ZIP / ASM.SRC < prev    next >
Encoding:
Text File  |  1989-11-08  |  4.0 KB  |  181 lines

  1. {@ME.FORMAT                                                                      }
  2. $MACRO_FILE ASM;
  3. {******************************************************************************
  4.                                                             MULTI-EDIT MACRO FILE
  5.  
  6. Name: ASM
  7.  
  8. Description:  Language support for Assembly language.
  9.  
  10. ASM_IND - Smart Indenting
  11. PROC        - Creates the shell of a procedure for 8086 assembly language.
  12. ASMFORM - Reformats 8086 assembly language source code.
  13.  
  14.                              (C) Copyright 1989 by American Cybernetics, Inc.
  15. ******************************************************************************}
  16.  
  17. $MACRO ASM_IND;
  18. {******************************************************************************
  19.                                                         MULTI-EDIT MACRO
  20.  
  21. Name: ASM_IND
  22.  
  23. Description:  This macro will capitalize all characters on the current line
  24. up to the end of the line, or    the ";" comment delimiter, whichever comes
  25. first.  Then it will perform a carriage return.  This coding style may not be
  26. to everyones liking, so if you don't like it, simply turn smart indent off.
  27.  
  28.                         (C) Copyright 1989 by American Cybernetics, Inc.
  29. ******************************************************************************}
  30.     Def_Int(Temp_Integer);
  31.     Def_Int( i_col );
  32.     refresh := false;
  33.     i_col := c_col;
  34.     First_Word;
  35.     set_indent_level;
  36.     Temp_Integer := XPos(';',Get_Line,1);
  37.     IF Not(Temp_Integer) THEN
  38.         Temp_Integer := Length(Get_Line);
  39.     END;
  40.     IF (Temp_Integer) THEN
  41.         Put_Line(Caps(Copy(Get_Line,1,Temp_Integer)) + Copy(Get_Line,Temp_Integer + 1,254));
  42.     END;
  43.     goto_col( i_col );
  44.     refresh := true;
  45.     Cr;
  46. END_MACRO;
  47.  
  48. $MACRO PROC;
  49. {******************************************************************************
  50.                                                         MULTI-EDIT MACRO
  51.  
  52. Name: PROC
  53.  
  54. Description:  Creates the shell of a procedure for 8086 assembly language.
  55.  
  56.                         (C) Copyright 1989 by American Cybernetics, Inc.
  57. ******************************************************************************}
  58.     def_str(tstr);
  59.  
  60.     Goto_Col(1);
  61.     tstr := Get_Word('');
  62.     text(' PROC FAR');
  63.     Goto_Col(1);
  64.     Undent;
  65.     CR;
  66.     UP;
  67.     text('PUBLIC ' + tstr);
  68.     down;
  69.     down;
  70.     goto_Col(1);
  71.     indent;
  72.     text('SAVE_BP');
  73.     CR;
  74.     CR;
  75.     Text('RESTORE_BP');
  76.     CR;
  77.     TEXT('RET');
  78.     CR;
  79.     Goto_COL(1);
  80.     Text(TSTR + ' ENDP');
  81.     CR;
  82.     UP;
  83.     UP;
  84.     UP;
  85.     UP;
  86.     GOTO_COL(1);
  87.     INDENT;
  88.  
  89. END_MACRO;
  90.  
  91. $MACRO ASMFORM;
  92. {******************************************************************************
  93.                                                         MULTI-EDIT MACRO
  94.  
  95. Name: ASMFORM
  96.  
  97. Description:  Reformats 8086 assembly language source code.
  98.  
  99.                         (C) Copyright 1989 by American Cybernetics, Inc.
  100. ******************************************************************************}
  101.     def_str( tstr[10] );
  102.     def_int( space_found );
  103.  
  104.     working;
  105.     refresh := false;
  106.     mark_pos;
  107.     if block_stat <> 1 then
  108.         goto exit;
  109.     end;
  110.  
  111.     goto_line(block_line1);
  112.     while c_line <= block_line2 do
  113.         first_word;
  114.  
  115.         if cur_char = ';' then        {If first character is a ; then ignore line}
  116.             goto do_loop;
  117.         end;
  118.  
  119.         while c_col > 1 do                {Delete all leading characters}
  120.             back_space;
  121.         end;
  122.  
  123.         while not(at_eol) and (xpos(cur_char,' |9:',1) = 0) do
  124.             right;
  125.         end;
  126.  
  127.         if cur_char = ':' then      {If this is a label the go on}
  128.             goto do_loop;
  129.         end;
  130.  
  131.         if at_eol then
  132.             goto do_indent;
  133.         end;
  134.  
  135. do_indent:
  136.         goto_col(1);
  137.         tab_right;
  138.  
  139.         space_found := false;
  140.  
  141.     find_comment:
  142.         tstr := Get_Word('''"; |9');
  143.         if (cur_char = '''') then
  144.             right;
  145.             tstr := get_word('''');
  146.             right;
  147.             goto find_comment;
  148.         end;
  149.         if (cur_char = '"') then
  150.             right;
  151.             tstr := get_word('"');
  152.             right;
  153.             goto find_comment;
  154.         end;
  155.         while xpos(cur_char,'|9 ',1) <> 0 do
  156.             del_char;
  157.         end;
  158.         if not(at_eol) then
  159.             if cur_char = ';' then
  160.                 while c_col < 41 do
  161.                     tab_right;
  162.                 end;
  163.                 goto do_loop;
  164.             else
  165.                 if space_found = false then
  166.                     tab_right;
  167.                     space_found := true;
  168.                 else
  169.                     text(' ');
  170.                 end;
  171.                 goto find_comment;
  172.             end;
  173.         end;
  174.  
  175. do_loop:
  176.         down;
  177.     end;
  178. exit:
  179.     refresh := true;
  180.     goto_mark;
  181. END_MACRO;