VIM and Custom Labeling

I use vim in windows to edit assembly code. This is a non-standard language, and the binary is disassembled using a custom script, so I determine the format myself. I would like to use tags to be able to jump over the code for subroutine calls. I searched around quite a bit, and all roads seem to lead to using ctags to create a tag file, but obviously this will not work in my case, since I am not dealing with C code. How to create your own tag file? Here is a sample code. First, each subroutine is defined by a keyword and a hexadecimal offset (first column).

Subroutine e2b7 e2b7 2c c0 11 03 BBS [Branch if bits are '1'] #$03, $11c0, 00e2ce ($12) e2bc a9 00 LDA [Load A with mem] #$00 . blah . blah . blah 

And somewhere in the code, a transition to the sub is performed;

 d9ad 20 b7 e2 JSR $e2b7 

Thanks for any help you can provide.

+4
source share
2 answers

Use ctags along with taglist-plugin ( http://vim.sourceforge.net/scripts/script.php?script_id=273 ). The source ctags package contains an EXTENDING.html file that describes how to determine the extension. I have done this for several languages. Here are two examples (make (1) and POD (perl old document)):

 %%%%%%%%%% file '~/.ctags' %%%%%%%%%%%%%%%%%%%% --langmap=perl:+.pod --regex-perl=/^=head1[[:space:]]*(.+)/\1/o,pod/ --regex-perl=/^=head2[[:space:]]*(.+)$/. \1/o,pod/ --regex-perl=/^=head3[[:space:]]*(.+)$/.. \1/o,pod/ --regex-perl=/^=head4[[:space:]]*(.+)$/... \1/o,pod/ --regex-perl=/^=for[[:space:]]+([^:]+):(.*)$/*\1:\2/o,pod/ --regex-perl=/^__(DATA|END)__$/__\1__/l,labels/ --regex-make=/^([^:# \t]+)[ \t]*:($|[^=]+)/\1/t,targets/ 

To use this with taglist, you need two extra lines in ~ / .vimrc. For the above examples:

 %%%%%%%%%% file '~/.vimrc' %%%%%%%%%%%%%%%%%%%% let tlist_perl_settings = 'perl;c:constants;f:formats;l:labels;p:packages;s:subroutines;d:subroutines;o:POD' let tlist_make_settings = 'make;m:makros;t:targets' 

This screenshot shows a taglist navigation window with an additional POD section.

+5
source

ctags supports many languages, including assembly - if your favorite option is not possible, could you add it to ...?

+2
source

Source: https://habr.com/ru/post/1286048/


All Articles