user14222280
user14222280

Reputation:

Telling GAS to use semicolons for comments in Intel syntax mode

Can I use semicolons in GAS for comment characters?

I am using GAS 2.30 with the Intel syntax as below.

.intel_syntax noprefix

.section .text

# Program entry point
.globl _start

_start:

    # Put the code number for system call
    mov eax, 1

    # Return value
    mov ebx, 0

    # Kernel call
    int 0x80

This works nicely except that I have to use '#' as a comment character instead of ';'.

The main reason why it matters is that the editor that I have (SublimeText 3.2.2, build 3211) only has syntax highligting for ARM or NASM assembly syntax, neither of which understands '#' for comments and as I am following materials that mainly use Intel syntax, this is something I would just like to keep consistent with what I am reading about.

I checked the Intel manuals, the 5000+ pages PDF document, and unless I missed it somehow, it says nothing about comments although an introductory page by Intel uses semicolons for comments.

My question is if there is maybe a switch to let GAS use semicolons instead of pound signs in this context or is that perhaps one of the little differences to simply get used to?

I understand that GAS will also accept /, // and /* */ but none of these is understood by SublimeText.

Interestingly enough, telling SublimeText to use Bash syntax highlighting is quite a good solution as in the screenshot below but perhaps there is a way to configure GAS to use semicolons too? Thanks.

GAS assembly syntax highlighting in SublimeText

Upvotes: 4

Views: 1458

Answers (1)

Nate Eldredge
Nate Eldredge

Reputation: 58673

No, gas has no command-line switch or directive for this. The comment characters are hardcoded.

However, it looks like it wouldn't be too hard to change them in the gas source and compile a custom version, if you really want that. At a glance you would want to add ; to i386_comment_chars and line_comment_chars, and remove it from line_separator_chars.

Upvotes: 5

Related Questions