我的讲师要求我们编写一个显示诗歌或段落的汇编语言代码。我该怎么做?据我所知,我只能显示一个句子,比如"你好世界"。
一个示例代码是这样的:
.model small
.stack 100h
CR equ 13d
LF equ 10d
.data
message db 'Hello World', CR, LF, '$' ; note the terminating $
.code
start:
mov ax, @data
mov ds, ax
mov dx, offset message
mov ah, 9 ; subprogram for string output
int 21h ; call ms-dos to display string
mov ax, 4c00h
int 21h
end start
"$"是字符串结尾,而 CR 是回车符,LF 是换行符。将整首诗写在"消息"中,并将该 $ 放在末尾。