本文介绍了"13,10"代表什么?在"DB 13,10,'hello world',0"中表示什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间以来我一直在键入DB 13, 10, 'hello world', 0,却不知道13、10和0代表什么.

I've been typing DB 13, 10, 'hello world', 0 for a long time without wondering what the 13, the 10 and the 0 were for.

我最近注意到这样做:

PTHIS
DB 'hello world', 0

产生了相同的结果,所以我想知道第一个参数是什么意思,以这种方式简单地编写它是否是一个好主意.有人可以对此写一个简短的解释吗? (我想字符串声明将是主题)

produced the same result, so I'm wondering what the first parameters are for and whether is a good idea to simply write it this way. Could someone write a quick explanation on this? (I suppose string declarations would be the topic)

推荐答案

这是ASCII CR/LF(回车/换行)序列,用于前进到下一行的开头.

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

您的两个样本不应产生相同的结果.如果在输出不带CR/LF的字符串时光标不在行首,则Hello world将显示在某行的中间行,即使您 do 从该行的开头开始一行,带有CR/LF的版本应首先将光标向下移动一行.

And your two samples shouldn't produce the same result. If your cursor is not at the start of a line when you output the string without CR/LF, the Hello world will show up mid-line somewhere and, even if you do start at the start of a line, the version with CR/LF should first move the cursor down one row.

最后的零只是字符串的终止符.一些早期的系统在原始BIOS中使用了其他字符,例如$:

The zero at the end is simply a terminator for the string. Some early systems used other characters like the $ in the original BIOS:

str   db "Hello, world$"

这使得将$符号输出到控制台相当麻烦:-)

which made it rather a pain to output the $ sign to the console :-)

之所以有终止符,是因为您的字符串输出几乎可以肯定是根据字符输出来编写的,例如伪asm代码:

The terminator is there because your string output will almost certainly be written in terms of a character output, such as the pseudo-asm-code:

; func:   out_str
; input:  r1 = address of nul-terminated string
; uses:   out_chr
; reguse: r1, r2 (all restored on exit)
; notes:  none

out_str   push    r1            ; save registers
          push    r2

          push    r1            ; get address to r2 (need r1 for out_chr)
          pop     r2

loop:     ld      r1, (r2)      ; get char, finish if nul
          cmp     r2, 0
          jeq     done

          call    out_chr       ; output char, advance to next, loop back
          incr    r2
          jmp     loop

done:     pop     r2            ; restore registers and return
          pop     r1
          ret

; func:   out_chr
; input:  r1 = character to output
; uses:   nothing
; reguse: none
; notes:  correctly handles control characters

out_chr   ; insert function here to output r1 to screen

这篇关于"13,10"代表什么?在"DB 13,10,'hello world',0"中表示什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 06:17