[Nasm-bugs] [Bug 3392813] New: Assembly comments may affect generated machine instructions

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Wed Sep 28 10:25:56 PDT 2022


            Bug ID: 3392813
           Summary: Assembly comments may affect generated machine
           Product: NASM
           Version: 2.15.xx
          Hardware: PC
                OS: Linux
            Status: OPEN
          Severity: normal
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: pw.piotr.wyrwas at gmail.com
                CC: chang.seok.bae at intel.com, gorcunov at gmail.com,
                    hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: From OS distribution

So I've been working on low-level software project when I noticed odd
behaviour, which is very likely to be related to the comments in the assembly
source code.

The following is small segment of said project's code which is responsible for
the video mode:

[program.asm] -----------------------------------


;; Just for finding this segment later in the disassembler output

        mov ah, 0x0             ;; \
        mov al, 0x2             ;; | Change the video mode to 80x25 text
        int 0x10                ;; /





This code was later compiled using the following command:
nasm -f bin program.asm -o program

.. and then disassembled:
objdump --disassemble-all --target binary --architecture i386
--disassembler-options=intel program

The `mov al, 10x2` command does not exist at the expected location in the

  20:   90                      nop
  21:   b4 00                   mov    ah,0x0
  23:   cd 10                   int    0x10
  25:   c3                      ret    
  26:   90                      nop

Then I removed the comments from the code, which yielded the following

  20:   90                      nop
  21:   b4 00                   mov    ah,0x0
  23:   b0 02                   mov    al,0x2
  25:   cd 10                   int    0x10
  27:   c3                      ret    
  28:   90                      nop

Conclusion: For some reason the comments placed in the source code may affect
machine instruction generated by NASM. The code fragment I've shared in this
bug report is just an example - I've noticed the same behaviour with other
parts of my code involving comments with the '\' (backslash) character.

The full source code on gist:

You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.

More information about the Nasm-bugs mailing list