You're running a self-modifying code: depending on the platform, it may work or not. In protected mode, it will not work, because the code segment is read-only (it would work perfectly in DOS on a 386)
You must put the strings in the data segment, or instruct the linker to place a "writeable" tag in the .text segment (something like: /SECTION:.text,EWR
).
This last method is frowned upon, because (a) it is poor coding practice, (b) it is used by so-called "polymorphic" virus engines, and disapproved by antivirus software, (c) may interfere with virtualized environment operations, finally (d) may not work, apparently at random, with some hardware configurations due to processor prefetch.
Unless you have a really pressing reason to do so, I'd suggest declaring a data segment and place your string there.