Author Topic: Assembly language labels in the Defs view?  (Read 5708 times)

rwf

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Assembly language labels in the Defs view?
« on: July 11, 2008, 09:35:36 pm »
For mainstream high-level languages, the "Defs" window handily shows an "index" of functions, prototypes, procedures, constants, etc.  I want to add the same features for typical assembly language files.  The predefined "Intel Assembly" language doesn't seem to recognize labels (much less put them in the "Defs" window), so I'm playing with creating custom assembly language (because I presume a built-in language can't be modified).  I've loosely followed  Dennis B's "Adding Language Support to SlickEdit" note(http://blog.slickedit.com/2008/05/tutorial-adding-language-support-to-slickedit/), but I don't see anything that allows any sort of "regex style" parsing necessary to specify things like labels.

Can anyone suggest where I should look to  specify how to parse items to post in the "Defs" window?

Thanks in advance.

Graeme

  • Senior Community Member
  • Posts: 2103
  • Hero Points: 253
Re: Assembly language labels in the Defs view?
« Reply #1 on: July 12, 2008, 01:03:21 pm »
For mainstream high-level languages, the "Defs" window handily shows an "index" of functions, prototypes, procedures, constants, etc.  I want to add the same features for typical assembly language files.  The predefined "Intel Assembly" language doesn't seem to recognize labels (much less put them in the "Defs" window), so I'm playing with creating custom assembly language (because I presume a built-in language can't be modified).  I've loosely followed  Dennis B's "Adding Language Support to SlickEdit" note(http://blog.slickedit.com/2008/05/tutorial-adding-language-support-to-slickedit/), but I don't see anything that allows any sort of "regex style" parsing necessary to specify things like labels.

Can anyone suggest where I should look to  specify how to parse items to post in the "Defs" window?

Thanks in advance.

The defs window and tagging in general work fine for me with assembly language (I'm very happy to say), including Intel asm.  What do your labels look like?   - an identifier followed by a colon.  They work fine for me.  What filtering are you doing in the defs toolbar?  Try selecting all-tags or select "Labels" from the Functions category.

Two or three years ago I put in a feature request (not knowing about "proc_search") that a regex be allowed for determining what a label is because I sometimes have to work with code that has leading spaces before labels and constants or whatever, or a leading period, which screwed up the recognition of the label.

If you read Step 6 in that article by Denis you can see that you need to write a LANGUAGE_ID_proc_search function to get tagging to work for your language.  In asm.e you'll see asm_proc_search which handles label recognition for Intel assembly so you could modify that if your labels aren't being recognized  - or write your own MY_ASM_proc_search function!  The proc_search function for C and some other languages is in the core (where the parser is) which helps speed a lot I guess.

Graeme

rwf

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Assembly language labels in the Defs view?
« Reply #2 on: July 13, 2008, 07:16:37 pm »
Thanks Graeme.  I stupidly had the filter off for functions/labels.  I thought I tried "show all tags", but obviously I was mistaken.

yur1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Assembly language labels in the Defs view?
« Reply #3 on: September 23, 2008, 10:32:21 am »
Hi guys,

This still doesn't work for me. I don't even get labels in C files.
I'm not using projects i.e. I just open random files straight with SlickEdit... would this make a difference !?

All the other defs types seem to work, except labels i.e. identifier (no leading white space) and colon.

Any ideas !?

Many thanks,
Yuri.

Graeme

  • Senior Community Member
  • Posts: 2103
  • Hero Points: 253
Re: Assembly language labels in the Defs view?
« Reply #4 on: September 24, 2008, 01:04:26 am »
Assembler files still show up in the defs toolbar for me ok, even when they're not part of a project/ tag file.  Check the extension of the file you're using is one that slick understands/ knows how to parse.  If not, you can map it using the file extension manager.

Graeme

yur1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Assembly language labels in the Defs view?
« Reply #5 on: September 24, 2008, 02:52:29 pm »
Thanks for the suggestion Graeme, but it still doesn't want to play.

I have gcc-powerpc files, with extension .s, which I've mapped to masm type. I'm also using the Unix Assembler PPC lexer, if that makes any difference !?

Do you know if there's an easy way to write an extra parsing rule for an existing language, without having to resort to creating a custom language as per Dennis Bs' note mentioned previously ?

Cheers,
Yuri.

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 284
Re: Assembly language labels in the Defs view?
« Reply #6 on: September 24, 2008, 05:32:16 pm »
I'm using '.s' and '.S' referring to 'unixasm' and also the 'Unix Assembly PPC lexer.
This provides quite good tagging support (also in the Defs TB).
HS2

Graeme

  • Senior Community Member
  • Posts: 2103
  • Hero Points: 253
Re: Assembly language labels in the Defs view?
« Reply #7 on: September 25, 2008, 09:36:34 am »
What version of slickedit are you using?

Do you get anything in the defs toolbar if you add this code to a file with asm extension and open it in slick?

Code: [Select]
_main   segment virtual
@_main  proc    near
?live16385@0:
        push      ebp
        mov       ebp,esp
@1:
        push      2
        push      8
        call      @@%f$i%$qii$i
        add       esp,8
   ;   
   ; ...   
@3:
@2:
        pop       ebp
        ret
@_main  endp
_main   ends

Regarding parsing, as I mentioned earlier in this thread, you can modify functions like asm_proc_search in asm.e.  Is that what you mean?

Graeme


yur1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Assembly language labels in the Defs view?
« Reply #8 on: September 25, 2008, 10:14:21 am »
Thanks Graeme & HS2.

Graeme, your code worked as a .asm file! Which really confused me.
Then, I renamed it to a .s file, and it still worked !

And then the penny dropped!
You have to close and re-open a file to see any changes to the context-tagger or lexer  ;D
duh !

HS2, mapping to .unixasm with PPC lexer works a treat, cheers.

Thanks for the advice on the .e files Graeme. That is probably what I mean. I will try to modify the cpp.e file to tag labels, as "goto" is one of my friends in C  :P

Anyway, many thanks all you guys for your help. This has been bugging me for a while with SlickEdit. Glad I finally decided to seek help from the experts.

Yuri.