简体   繁体   中英

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! $' 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! $' message db 'Hello\\nworld! $' . Is that possible?

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.

Worked for me (8086 Assembly):

.MODEL SMALL
.STACK 100H 
.DATA
LOADING DB 'Starting LunaOS...','$'
DONELOADING DB 'Starting LunaOS... done.','$'
.CODE

MOV AX,@DATA
MOV DS,AX

LEA DX,LOADING
MOV AH,9
INT 21H    

LEA DX,DONELOADING
MOV AH,9
INT 21H    

;LEA DX,STRING2
;MOV AH,9
;INT 21H  

;LEA DX,STRING3
;MOV AH,9
;INT 21H 

;LEA DX,STRING4
;MOV AH,9
;INT 21H 

MOV AH,4CH
INT 21H   


END

To add a new line, copy the LEA DX,(STRING NAME) and copy the MOV AH, 9. Then copy INT 21h, paste it to a new line, add a string to ".DATA", change the LEA,DX(STRING NAME) to LEA,DX(NEW STRING NAME)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM