News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

What About Textequ < 13 , 10 > ???

Started by Shahmeerm, October 01, 2013, 07:27:38 PM

Previous topic - Next topic

Shahmeerm

I Got some code by searching on google which joins two Bytes and insert a new line character ... I just want to know what does it mean ..
Seniors Plz help me out in this ....

nl textequ <13,10>
.data
        msg1 byte "Hello World",nl
                  byte "Hello Worlds",nl
                  byte "Hi ......",nl,0
           


if i put this code in my assembly code and print this "msg1" variable with "Call WriteString" then it prints like that :

Hello World
Hello Worlds
Hi .......


What is happening here ... Help Needed

jj2007

It's simply a newline sequence:
msg1 byte "Hello World", nl
msg1 byte "Hello World", 13, 10

13 = CR, carriage return
10 = LF, linefeed

dedndave

nl textequ <13,10>
just replaces every occurance of "nl" with "13,10"
it's a TEXTEQU, which works on strings, not numeric values

it's a little ambiguous, because in C, a NewLine is 10 only
for example, if you want a NewLine in a MessageBox, you can just use 10

jj2007

Even the console is happy with LF. But CR alone is still an interesting option for console apps:

include \masm32\include\masm32rt.inc
.code
start:
   push 100
   stack equ dword ptr [esp]
   .Repeat
      mov eax, stack
      print str$(eax), " ", 13
      invoke Sleep, 50
      dec stack
   .Until Sign?
   pop eax
   inkey " bye"
   exit
end start

dedndave

didn't know that one - lol

i am pretty sure that, under DOS, a lone line-feed might get you something like this
12345
     6789


at least, that was the old VT-100 behaviour - for those who remember that   :biggrin:

nidud

#5
deleted

jj2007


KeepingRealBusy

Quote from: Shahmeerm on October 01, 2013, 07:27:38 PM
I Got some code by searching on google which joins two Bytes and insert a new line character ... I just want to know what does it mean ..
Seniors Plz help me out in this ....

nl textequ <13,10>
.data
        msg1 byte "Hello World",nl
                  byte "Hello Worlds",nl
                  byte "Hi ......",nl,0
           


if i put this code in my assembly code and print this "msg1" variable with "Call WriteString" then it prints like that :

Hello World
Hello Worlds
Hi .......


What is happening here ... Help Needed

Shahmmerm,

Please be more specific about "What is happening here ...". Are you questioning why the three lines all appear on separate lines (the above answers explain that) or are you questioning why three messages are output instead of just one message since you only made one "Call WriteString? The reason for that is that WriteString writes out all data until it encounters the null terminator, which is only on the last line.

Dave.