Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 什么是;13、10“;“中的平均值”;DB 13、10和#x27;你好,世界';,0";?_Assembly_X86 16 - Fatal编程技术网

Assembly 什么是;13、10“;“中的平均值”;DB 13、10和#x27;你好,世界';,0";?

Assembly 什么是;13、10“;“中的平均值”;DB 13、10和#x27;你好,世界';,0";?,assembly,x86-16,Assembly,X86 16,很长一段时间以来,我一直在键入db13,10,'helloworld',0,而不知道13,10和0是用来做什么的 我最近注意到: PTHIS DB 'hello world', 0 产生了相同的结果,所以我想知道第一个参数是用来做什么的,用这种方式写是否是个好主意。有人能写一个简短的解释吗?(我想主题应该是字符串声明)这是ASCII CR/LF(回车/换行)序列,用于前进到下一行的开头 历史课程:在老式电传打字机上,回车功能正是这样做的,它将回车(打印头)返回到当前行的起始位置,而行式进纸使纸

很长一段时间以来,我一直在键入
db13,10,'helloworld',0
,而不知道13,10和0是用来做什么的

我最近注意到:

PTHIS
DB 'hello world', 0
产生了相同的结果,所以我想知道第一个参数是用来做什么的,用这种方式写是否是个好主意。有人能写一个简短的解释吗?(我想主题应该是字符串声明)

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

历史课程:在老式电传打字机上,回车功能正是这样做的,它将回车(打印头)返回到当前行的起始位置,而行式进纸使纸张前进,以便在下一行进行打印

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

末尾的零只是字符串的终止符。一些早期系统在原始BIOS中使用了其他字符,如
$

str   db "Hello, world$"
这使得将
$
符号输出到控制台非常痛苦:-)

终止符就在那里,因为您的字符串输出几乎肯定是以字符输出的形式编写的,例如伪asm代码:

; 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
这是ASCII CR/LF(回车/换行)序列,用于前进到下一行的开头

历史课程:在老式电传打字机上,回车功能正是这样做的,它将回车(打印头)返回到当前行的起始位置,而行式进纸使纸张前进,以便在下一行进行打印

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

末尾的零只是字符串的终止符。一些早期系统在原始BIOS中使用了其他字符,如
$

str   db "Hello, world$"
这使得将
$
符号输出到控制台非常痛苦:-)

终止符就在那里,因为您的字符串输出几乎肯定是以字符输出的形式编写的,例如伪asm代码:

; 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是CR ASCII码()的十进制值,10是LF ASCII码()的十进制值,0是字符串的终止零


这个常量背后的思想是在打印
hello world
之前切换到下一行。零终止符是打印子例程知道何时结束打印所必需的。这类似于。

13是CR ASCII码()的十进制值,10是LF ASCII码()的十进制值,0是字符串的终止零

这个常量背后的思想是在打印
hello world
之前切换到下一行。零终止符是打印子例程知道何时结束打印所必需的。这类似于。

试试这个

PTHIS
DB 'hello world'      
DB 10                 ;line feed
DB 13                 ;carriage return
DB 'hello world2',0
然后抖动代码

PTHIS
DB 'hello world'      
DB 10                    ;line feed no carriage return
DB 'hello world2',0

PTHIS
DB 'hello world'      
DB 13                    ;carriage return no line feed
DB 'hello world2',0
看看会发生什么

试试这个

PTHIS
DB 'hello world'      
DB 10                 ;line feed
DB 13                 ;carriage return
DB 'hello world2',0
然后抖动代码

PTHIS
DB 'hello world'      
DB 10                    ;line feed no carriage return
DB 'hello world2',0

PTHIS
DB 'hello world'      
DB 13                    ;carriage return no line feed
DB 'hello world2',0
看看会发生什么