tags:

views:

126

answers:

2

I am using vim in windows to edit assembly code. It is a nonstandard language and disassembly of the binary is done by a custom script so I define the format myself. I would like to use tags to be able to jump through the code for subroutine calls. I have searched around quite a bit and all roads seem to lead to using ctags to generate a tags file, but obviously this won't work in my case as I am not dealing with C code. How is it possible to create a custom tag file? Here is an example of the code. First, each subroutine is defined by the keyword and the hex offset (the 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 jump to the sub is executed;

d9ad 20 b7 e2    JSR $e2b7

Thanks for any help you can provide

+2  A: 

ctags supports a lot of languages, including assembly -- if your favorite variant isn't included, perhaps you could add it in...?

Alex Martelli
+2  A: 

Use ctags together with the taglist-plugin (http://vim.sourceforge.net/scripts/script.php?script_id=273). The source package of ctags contains the file EXTENDING.html which describes how to define an extension. I did this for several languages. Here 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 additional 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 the taglist navigation window with additional POD section.

fgm