什么是语法来定义一个串在装配常数

编程入门 行业动态 更新时间:2024-10-27 01:31:21
本文介绍了什么是语法来定义一个串在装配常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我学习组装我看到定义一个字符串的两个例子:

I am learning assembly I see two examples of defining a string:

味精分贝你好,世界!,为0xA

msg db 'Hello, world!',0xa

  • 是什么的意思是0xA这里?

信息DB'我爱它!​​,0

message DB 'I am loving it!', 0

  • 为什么我们有一个0这里?
  • 是结尾的空字符?
  • 为什么我们是0xA上面的例子,但在这里0? (似乎没有他们与字符串的长度)

如果上面的例子是定义组装线两种方式,怎么可能在程序区分开来?

If the above examples are two ways of defining an assembly string, how could the program differentiate them?

提前感谢您的帮助:)

推荐答案

不同的汇编器有不同的语法,但在分贝指令的情况下,他们是pretty是一致的。

The different assemblers have different syntax, but in the case of db directive they are pretty consistent.

分贝是汇编指令,即定义了在该指令位于源地的给定值字节。任选地,一些标签可以被分配到的指令。

db is an assembly directive, that defines bytes with the given value in the place where the directive is located in the source. Optionally, some label can be assigned to the directive.

常见的语法是:

[label] db n1, n2, n3, ..., nk

在哪里n1..nk一些字节大小的数字(从0..0xff)或一些字符串常量。

只要ASCII字符串由字节,该指令简单地在存储器中放置这些字节,完全按照该指令的其它数目

As long as the ASCII string consists of bytes, the directive simply places these bytes in the memory, exactly as the other numbers in the directive.

例如:

db 1, 2, 3, 4

将分配4字节和将填补它们与数字1,2,3及4

will allocate 4 bytes and will fill them with the numbers 1, 2, 3 and 4

string db 'Assembly', 0, 1, 2, 3

将被编译为:

string: 41h, 73h, 73h, 65h, 6Dh, 62h, 6Ch, 79h, 00h, 01h, 02h, 03h

与ASCII code 0AH字符(是0xA)是字符LF(换行),它在Linux中用作控制台新行命令。

The character with ASCII code 0Ah (0xa) is the character LF (line feed) that is used in Linux as a new line command for the console.

与ASCII code 00H(0)的特点是作为结束的字符串标记的类C语言的NULL字符。 (可能在OS API调用,因为大多数操作系统都写在C)

The character with ASCII code 00h (0) is the NULL character that is used as a end-of-string mark in the C-like languages. (and probably in the OS API calls, because most OSes are written in C)

附录1:有几个其他装配指令类似分贝,它们在内存中定义了一些数据,但与其他尺寸。最常见的是DW(定义字),DD(定义双字)和DQ(定义四倍字)16,32和64位的数据。然而,他们的语法,只接受数字,而不是字符串。

Appendix 1: There are several other assembly directives similar to DB in that they define some data in the memory, but with other size. Most common are DW (define word), DD (define double word) and DQ (define quadruple word) for 16, 32 and 64 bit data. However, their syntax accepts only numbers, not strings.

更多推荐

什么是语法来定义一个串在装配常数

本文发布于:2023-11-13 09:21:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:常数   语法   定义

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!