1

i want to know the explanation how , 10, 13, makes the string in new line and what does the 10 and 13 mean and why are they separated in " , " comma

this is my code

.model small
.stack 100h

.data

dog db "Hellowww" , 10, 13, "Earth, $"

cat db "im valen the alien $"

.code
start:

    mov ax, @data
    mov ds, ax

    mov ah, 09h

    mov dx, offset dog
    int 21h

    mov dx, offset cat
    int 21h

    mov ah, 4ch
    int 21h

end start

the result is

Hellowww
Earth, im valen the alien

Assembly code to print a new line string

Community
  • 1
  • 1
flyingpluto7
  • 1,079
  • 18
  • 20
  • 2
    They are Line Feed (LF) - ASCII Character 10, and Carriage Return (CR) - ASCII Character 13 https://en.wikipedia.org/wiki/Newline#Representations – TessellatingHeckler May 17 '16 at 04:04
  • 1
    by the way what is the bearing of adding 13 in ", 10, 13," if the ", 10," can already add new line my string? – flyingpluto7 May 17 '16 at 04:28
  • 3
    @ElecTreeFrying On some terminals, LF moves the cursor down one line (without changing the horizontal position), and CR moves the cursor back to the left-most column. Note that on systems that use the CR (like Windows), it's customary to have the CR first. So the 13 should be before the 10 in the code. – user3386109 May 17 '16 at 04:44
  • Note that `10, 13` is backwards from the standard convention. You want `CR, LF` (`13, 10`). [Why we use 10,13 after MSG1 DB in the line MSG1 DB 10,13, 'NUMBER IS POSITIVE $'?](https://stackoverflow.com/q/28152124) – Peter Cordes May 23 '21 at 22:19

1 Answers1

6

It's the ASCII CR/LF (carriage return/line feed) sequence, 13 and 10 respectively, used for advancing to the beginning of the next line.

A good explanation can be found here: https://stackoverflow.com/a/1552775/5760411

Community
  • 1
  • 1
Brendan
  • 908
  • 2
  • 15
  • 30