Author Topic: Assembler tools for CB  (Read 47491 times)

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Assembler tools for CB
« on: March 07, 2014, 10:08:32 pm »
There has been an ongoing discussion about assembler tools for CB in the topic:
http://forums.codeblocks.org/index.php/topic,19026.msg130238.html#msg130238

A fork named emblocks claims to have some good features which I think can be summarized below:
1- Assembler options (a tab dedicated to assembler options next to compiler and linker) to pass assembler specific options directly to assembler (i.e as).
2- Native assembler support to edit (syntax highlighting would be nice) and assemble the assembly files (.s, .S, .asm whatever) with designated options from feature 1 maybe by intervening between the compiler and linker and then let the linker link them all. As far as I know gcc compiles c/c++ files into assembly first then lets the assembler do its job so this feature doesn't look much unnatural at all. ;)

These 2 options would be a nice enhancement to cb imo, so here they are to discuss.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Assembler tools for CB
« Reply #1 on: March 07, 2014, 10:35:00 pm »
Another thing the E::B has is a location in the tool chain setting for the hex tool.
The hex tool is needed by many Embedded Compilers.

Hex tool converts object code (Binary) to hex code (ASCII).
Link to images http://community.silabs.com/t5/32-Bit-Discussion/Em-Blocks-IDE-with-EnergyMicro-support/td-p/107147

I think adding the assembler and hextool to the toolchain.
Along with the assembler options would be a good idea.

I have download the open source part of E::B; will look at the SDK changes needed to do the above items I posted.

Tim S.
« Last Edit: March 07, 2014, 10:58:03 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Assembler tools for CB
« Reply #2 on: March 07, 2014, 10:41:25 pm »
As far as I know we have syntax highlight for asm files.
Syntax highlight is a job of scintilla, so if your asm variant isn't supported then post a bug report to them.
After they make a lexer for it we can easily expose it in the options.
If it is supported by scintilla and it is not exposed, please say so and I'll expose it (it is pretty trivial task).

About separate options:
What king of options?
Do you want to have check boxes with the most common options?
We could probably add another tab in Build options -> Compiler settings (next to the tab "Other options").
How often do you edit asm files by hand in the embedded world?
In the desktop/server world people (almost) never need to do it.

As far as you probably know it is not problem to add asm files to the build system http://wiki.codeblocks.org/index.php?title=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system
Probably we can add asm support for specific compilers in the trunk version of C::B.
Can you provide patches for the compilers you're using?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Assembler tools for CB
« Reply #3 on: March 07, 2014, 10:47:15 pm »
Adding the hextool would be a bit more complex and would require more options as far as I can see.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Assembler tools for CB
« Reply #4 on: March 07, 2014, 11:04:09 pm »
oBFusCATed is likely right in the amount of work for only a small gain might be the result.

So, I will look at the features wanted and how easy it is to solve the problem in another way.

The ToolPlus plugin could likely do the hex convertor operation.

And, a special file property would likely be enough to set assembly file options.

Tim S.
 
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Assembler tools for CB
« Reply #5 on: March 08, 2014, 12:14:56 am »
Another thing the E::B has is a location in the tool chain setting for the hex tool.
The hex tool is needed by many Embedded Compilers.

Hex tool converts object code (Binary) to hex code (ASCII).
Link to images http://community.silabs.com/t5/32-Bit-Discussion/Em-Blocks-IDE-with-EnergyMicro-support/td-p/107147
I think inclusion of the hex tool won't be a good idea because it doesn't have a standard among compilers. Take AVR for example, there are many post processing steps to separate the object file (.elf) into output files program, eeprom, fuses, lock bits, signature etc... That is not the case for i.e. PICs so how would the hex tool behave for each compiler will complicate the things much more than it should imo. I vote on post processing for hex tool.

As far as I know we have syntax highlight for asm files.
Syntax highlight is a job of scintilla, so if your asm variant isn't supported then post a bug report to them.
After they make a lexer for it we can easily expose it in the options.
If it is supported by scintilla and it is not exposed, please say so and I'll expose it (it is pretty trivial task).
I think that would be more than enough for the editor support of assembler files.

About separate options:
What king of options?
Do you want to have check boxes with the most common options?
We could probably add another tab in Build options -> Compiler settings (next to the tab "Other options").
How often do you edit asm files by hand in the embedded world?
In the desktop/server world people (almost) never need to do it.
For separate options I was thinking about the lines of assembler flags (yeah checkboxes would be nice) to be inserted directly into the assembler command line.
For the tab position why not add it next to 'Compiler settings' and 'Linker settings' as 'Assembler settings' in 'Build options'? It would be nice to make use of flags, other options and defines for the assembler too just as the compiler.
I edit assembler files for a couple of reasons in my embedded work. First to see what the compiler is generating in case I suspect a compiler bug, second to create optimized routines in case I am in a very narrow time window to perform that routine, third to code general purpose hand optimized libraries specific to my needs. These are some usages I can think of in the first place but as I mentioned in the other topic, I don't think assembler usage is that little in the desktop world judging by the fact that even I know a couple of assembler gurus from school and work despite me being a no desktop programmer at all. ;)

As far as you probably know it is not problem to add asm files to the build system http://wiki.codeblocks.org/index.php?title=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system
Probably we can add asm support for specific compilers in the trunk version of C::B.
Can you provide patches for the compilers you're using?
I am aware of that method to add support for non C/C++ files in the build system and I've been using it if needed. But I don't think that would be a comparison to native support of assembler files because it is hard to use and customize.
Please forgive my ignorance, what kind of patches do you need and for which compilers? Patches for compilers that have an assembler included?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Assembler tools for CB
« Reply #6 on: March 08, 2014, 01:10:31 am »
I am looking at the E::B SDK (modified from CB SDK).

Thinking of trying a patch to add these things.

ASM
ftAssembler
ctAssembleObjectCmd
$assembler

Those are in 14 files in the SDK, 2 in the src folder, and 1 script binding file.

I figure all the other possible changes will require this one; that looks bigger than I would have guessed.

Tim S.
« Last Edit: March 08, 2014, 01:21:01 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Assembler tools for CB
« Reply #7 on: March 08, 2014, 01:35:20 am »
@scarphin:
1. Is syntax highlighting working for your assembler files or not? Does scintilla support them?
2. I'd prefer to give you just a field where you can type all the options for assembler compilation, everything else seems, too complex. Also there are too many tabs in this dialog already.
3. Do you need to specify different linker flags for the asm files?
4. Desktop people use inline asm or intrinsics. (Almost) No one would bother to write pure asm for more then couple of routines in a project.
5. The options for every compiler are stored in options_*.xml files. I thought that it would be possible to add the asm commands there, but looking at the code this is not the case. So a modification is needed.

@alpha01: Am I correct about 5 or not?
@stahta01: The compiler/sdk in E::B is probably using the old non generic/xml based compilers, so patches taken from there won't work.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Assembler tools for CB
« Reply #8 on: March 08, 2014, 04:16:47 am »
@obfuscated:
1- Syntax highlighting can only distinguish comments, numbers and punctuation (equal sign, comma etc...), I don't get a special color on keywords if that's what you are asking. I never delved into this as it's clear that every mcu's assembler is specific to itself. I do get syntax highlighting for assemblers on the list at 'settings->editor->syntax highlighting->syntax highlighting for', masm for example. Btw I found the link below that makes it possible to introduce other languages to notepad++:
http://sourceforge.net/apps/mediawiki/notepad-plus/?title=User_Defined_Language_Files#P
2- Assembler compilation options would be a good start but I believe locating the assembler settings tab under the compiler settings tab will make it look like assembly step is a sub-process of compilation step, don't you think?
3- I didn't need to but I've never done any C++ work with any embedded compiler either. So I can't judge on this.
4- I completely agree but it's that a couple of routines that makes the usage. ;)
5- I think you're right.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Assembler tools for CB
« Reply #9 on: March 08, 2014, 09:18:06 am »
1. We have something similar. See here http://wiki.codeblocks.org/index.php?title=Creating_a_custom_lexer_for_Code::Blocks_editor
2. I don't think, so. Probably we should even make it the same for C and C++ (add separate tabs for them).
3. I think that if you need to you can pass the settings in the current options. Because I suppose that the asm file will be compiled to object file (.o) and then linked as other object files in a single commands. So I don't think there will be a need for it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Assembler tools for CB
« Reply #10 on: March 08, 2014, 12:49:57 pm »
@stahta01: The compiler/sdk in E::B is probably using the old non generic/xml based compilers, so patches taken from there won't work.

I agree, I am just looking for the files that needed changed in the SDK/src.
I would guess the same files still need changed; maybe, in different ways.

Edit: Decided adding assembler support is premature; will work on adding $device support to C Compiler instead.
http://forums.codeblocks.org/index.php/topic,19044.msg130362.html#msg130362

Tim S.
« Last Edit: March 10, 2014, 03:15:56 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Assembler tools for CB
« Reply #12 on: March 09, 2014, 07:51:45 pm »
This is already supported Debug -> Debug windows -> Disassembly and enable the Mixed mode.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Assembler tools for CB
« Reply #13 on: March 09, 2014, 08:05:46 pm »
This is already supported Debug -> Debug windows -> Disassembly and enable the Mixed mode.
wow thanks! i somehow missed this!

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Assembler tools for CB
« Reply #14 on: March 10, 2014, 04:59:35 am »
@obfuscated:
1- That should be enough to achieve syntax highlighting for assembler files imo. I'll try to implement one when I find the time. There is a slightly bigger problem though. Afaik most gcc based embedded compilers use the same file extension for assembler files (.s, .S) so for different gcc based mcu compilers, assembler file extensions becomes the same. I can think of 2 options here, one being the renaming of the assembler files' extension to something specific to the mcu (which I don't know if it will work but quite probably it will) and second choosing a keyword group somehow. Maybe there is a better option.
2- Separating C and C++ options is a good idea as C/C++ files are compiled and thus fit under compiler settings but assembler files are assembled by assembler into object code thus they don't fit under compiler settings. I get the feeling that you don't want to squeeze the main settings tabs to fit an assembler settings tabs there ;) but I think there are other areas of cb quite cluttered too like right-click menu, tabs in Global compiler settings etc... It's your decision in the end but please be aware that pure assembler projects are not that uncommon in embedded world which involve no compilation at all.
3- Assembler files are always assembled into object files for all gcc-based and most other compilers, no doubt with that. What I had in mind was if the C++ function call conventions would be of trouble or not in the linkage stage.