这段代码中DATA SEGMENT下的代码什么时候执行?
我是汇编编程的初学者...... 我在谷歌上浏览了很多。信息很多,但是我还是看不懂下面的代码。 我将不胜感激
如果有人能解释MOV AX,DATA
,我也不明白数据段中存在的代码何时会在该程序中执行。
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,@DATA
mov DS,AX
...
...
CODE ENDS
DATA SEGMENT
...
...
... //SOMECODE
DATA ENDS
另外,有人可以向我解释一下以下指令的作用吗?..
MOV AH , ??H (?? 可以用 09,4c 等填充)。
MOV DS,AX
<代码>MOV ES,AX
I am a beginner of Assembly Programming...
I surfed a lot in google. There is a lot of information, but I still do not understand the following code. I would be grateful if someone could explain
MOV AX,DATA
I also don't understand when the code that is present in data segment would be executed in this program.
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,@DATA
mov DS,AX
...
...
CODE ENDS
DATA SEGMENT
...
...
... //SOMECODE
DATA ENDS
Also, can someone explain to me what the following instructions do?..
MOV AH , ??H ( ?? can be filled with 09,4c etc).
MOV DS,AX
MOV ES,AX
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
警告:我一生中从未编写过 8086 程序集,但这就是我的想法。
MOV AX,@DATA
是运行的第一行代码。我相信 @DATA 是一个变量,它保存数据段所在内存位置的值。它将 @DATA 的内存位置移动到 AX 寄存器(16 位寄存器)中。这里需要注意的一件事是 DATA 一词前面的@。我相信这是因为 @DATA 在链接过程中被评估,并将被其实际值替换。请注意其他示例前面没有@,因为它们首先引用的是实际的内存位置。然后,
MOV DS,AX
会将该内存位置设置为变量DS
,它是 8086 汇编的标准变量(或在本例中为寄存器)。它应该始终指向您想要保存值的存储位置(如果您熟悉 C++ 术语,则为堆)。AX 寄存器只是一个临时占位符,您可以加载值并对其执行执行命令。
MOVE AH, ??H
首先,AH 指的是 AX 寄存器的“高”端。它的兄弟是 AL,它指的是 AX 寄存器的“低”端。当您想要针对 8 位而不是 16 位执行命令时,可以使用此选项。第二部分,您所指的 ??H 是您要存储在 AH 寄存器中的值。末尾的H表示“十六进制”。因此,如果您有 00H,则意味着零(十六进制)。如果输入 FFH,则与十进制中的 255 相同。回到你最初的问题“这段代码中DATA SEGMENT下的代码什么时候执行?” -- 我相信你问的是DATA SEGMENT什么时候会被执行。通常不应执行此操作,因为它应该存储在代码段中使用的数据(变量)。在某些操作系统上,我相信您可以绕过这个问题,只需跳转或分支到该代码段并将其视为常规代码段即可。有时,这就是堆栈溢出、堆溢出、(黑客)等的工作原理。
Warning: I've never written 8086 assembly in my life but this is what I make of it.
MOV AX,@DATA
is the first line of code that gets run. I believe @DATA is a variable that holds the value of the location in memory where the data segment lives. It moves the memory location of @DATA into the AX register (16 bit register). One thing to note here is the @ in front of the word DATA. I believe this is because @DATA is evaluated during the linking process and it will be replaced by its actual value. Notice how the other examples to not have the @ in front because they are referring to an actual memory location to begin with.MOV DS,AX
will then set that memory location as the variableDS
which is a standard variable (or register in this case) for 8086 assembly. It should always point to the location of your storage where you want to keep values (the heap if you're familiar with C++ terminology).The AX register is simply a temporarily place holder that you can load with values and perform execute commands against.
MOVE AH, ??H
First of all, the AH refers to the "high" side of the AX register. The brother of this would be AL which refers to the "low" side of the AX register. This is used when you want to perform commands against 8 bits instead of 16 bits. The second part of this, the ??H as you refer to it is the value you want to store in the AH register. The H at the end means "hexadecimal". So if you have 00H that would mean zero (in hex). If you put in FFH that would be the same as 255 in decimal number system.Back to your initial question "When Will the Code Under DATA SEGMENT execute in this code?" -- I believe you're asking when the DATA SEGMENT will be executed. This normally should not be executed because it's supposed to store data (variables) for use in your CODE SEGMENT. On some operating systems you can get around this I believe and simply JUMP or BRANCH to that section of code and treat it as a regular CODE SEGMENT. This is sometimes how stack overflows, heap overflows, (hacks), etc, all work.
Mov ax,@data
是加载ax中数据段起始地址的方式。然后使用mov ds,ax
数据段被初始化。该指令用于 tasm 汇编器。Mov ax,@data
is way of loading starting address of data segment in ax. then by usingmov ds,ax
data segment gets initialized. this instruction is used in tasm assembler.