4

I am using emu8086. I am trying to define a string like "I don't "listen" to radio".
When I use either of the following:

mystr db "I don't ""listen"" to radio"

mystr db 'I don"t "listen" to radio'

and try to print mystr, it prints either of the following, respectively:

I don't ""listen"" to radio

I don"t "listen" to radio

which is not what I want (I don't "listen" to radio). So, how can I define such a string?

Community
  • 1
  • 1
Cror2014
  • 417
  • 1
  • 6
  • 16

2 Answers2

4

Assemblers differ in how they treat embedded special characters like quotation marks, but the ASCII code comes to the rescue.

When a string you need to define has some difficult characters in it, you can always replace these by their ASCII codes. The double quotation mark has 34 for its ASCII code.

mystr db "I don't ", 34, "listen", 34, " to radio"

This will output:

I don't "listen" to radio

Fifoernik
  • 9,779
  • 1
  • 21
  • 27
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
3

In NASM you can use single quotes for strings with embedded double quotes (and vise versa):

mystr db "I don't ", '"listen" to radio'
AlexDarkVoid
  • 485
  • 3
  • 12