Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a new line assembly 8086

I'm learning assembly language and I have a doubt. I'm programming a simple "hello world" with this code:

.model small
.stack
.data
    message db 'Hello world! $'
.code
start:
    mov dx,@data
    mov ds.dx

    lea dx,message
    move ah,09h
    int 21h

mov ax,4c00h
int 21h
end start

I'm assuming that message db 'Hello world! $' works like a String, and now I'm wondering if it is possible to add something like \n to make the output in two lines, like this message db 'Hello\nworld! $'. Is that possible?

like image 735
Luis Diego Rodríguez González Avatar asked Dec 11 '16 21:12

Luis Diego Rodríguez González


Video Answer


1 Answers

message db 'Hello world! $'

Many assemblers will not interpret the \n embedded in a string.
Most assemblers will accept the following to insert a newline:

message db 'Hello',13,10,'world!',13,10,'$'

The value 13 is carriage return, and the value 10 is linefeed.

like image 145
Sep Roland Avatar answered Nov 17 '22 10:11

Sep Roland