News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Continue text on next line

Started by Magnum, August 31, 2010, 11:32:01 PM

Previous topic - Next topic

Magnum

I forgot how to continue text on the next line. (so I can see everything)

test db "Stress - the condition brought about by having to resist the temptation to beat the living daylights out of someone who richly deserves it."
Have a great day,
                         Andy

jj2007

testline db "Stress - the condition brought about by having to resist the temptation"
   db " to beat the living daylights out of someone who richly deserves it."

In the code section, it's a backslash, or, with invoke, a simple comma.

ecube

thestring db 'whatever',13,10
             db 'second part of it',0

frktons

Quote from: E^cube on September 01, 2010, 12:00:28 AM
thestring db 'whatever',13,10
              db 'second part of it',0

Sorry E^cube, what is the purpose of inserting a newline-carriage return
inside the string? If you want to display it in two lines I can understand.
Otherwise what is it useful for?
Mind is like a parachute. You know what to do in order to use it :-)

Magnum

This is only printing the first line.

message1  db 'So the Lord restored what Job had lost after he prayed for',13,10
               db 'his friends, and the Lord doubled all that had belonged to Job.  Job 42:10',0
Have a great day,
                         Andy

Magnum

I think it is not printing right because sizeof isn't calculating the right size.

invoke   WriteFile, ebx, ADDR message1, SIZEOF message1, addr dwBytes, 0
Have a great day,
                         Andy

sinsi

You can use the line continuation character with strings too

message1  db 'So the Lord restored what Job had lost after he prayed for',13,10,\
             'his friends, and the Lord doubled all that had belonged to Job.  Job 42:10'

If you are using WriteFile, the string doesn't have to be zero-terminated either - sizeof will include it and WriteFile will write it.
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

SIZEOF returns the number of bytes that follow DB on the first line. The data is structured as a null-terminated string, and you can use this to get the length or to display it.

;======================================================================================
    include \masm32\include\masm32rt.inc
;======================================================================================
    .data
      message1 db 'So the Lord restored what Job had lost after he prayed for',13,10
      db 'his friends, and the Lord doubled all that had belonged to Job. Job 42:10',0
    .code
;======================================================================================
start:
;======================================================================================
    print str$(SIZEOF message1),13,10
    invoke szLen, ADDR message1
    print str$(eax),13,10,13,10
    print ADDR message1,13,10,13,10
    inkey "Press any key to exit..."
    exit
;======================================================================================
end start


60
133

So the Lord restored what Job had lost after he prayed for
his friends, and the Lord doubled all that had belonged to Job. Job 42:10



eschew obfuscation

Magnum

Have a great day,
                         Andy

jj2007

Quote from: sinsi on September 01, 2010, 02:04:14 AM
You can use the line continuation character with strings too

Yes that works perfectly. If and only if you use JWasm.

include \masm32\include\masm32rt.inc

.data
MyStr db "This is \
a string", 0

.code

start: MsgBox 0, offset MyStr, "Test", MB_OK
exit

end start


However,
MyStr db "This is ",
" a string", 0

works with all versions of ML and JWasm.