简体   繁体   English

插入新线组件 8086

[英]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:我正在使用以下代码编写一个简单的“hello world”:

.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! $' 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 world! $'像一个字符串一样工作,现在我想知道是否可以添加像 \\n 这样的东西来使输出分成两行,比如这条message db 'Hello\\nworld! $' 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.许多汇编程序不会解释嵌入在字符串中的 \\n。
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.值 13 是回车,值 10 是换行。

Worked for me (8086 Assembly):为我工作(8086 程序集):

.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)要添加新行,请复制 LEA DX,(STRING NAME) 并复制 MOV AH, 9。然后复制 INT 21h,将其粘贴到新行,将字符串添加到“.DATA”,更改 LEA,DX(字符串名称)到 LEA,DX(新字符串名称)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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