gpt4 book ai didi

assembly - 如果不添加 start : and end start in EMU8086? 会发生什么

转载 作者:行者123 更新时间:2023-12-02 16:50:33 27 4
gpt4 key购买 nike

我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 < br/>(end start)(围绕执行代码的标签)?

所以我的问题是这个标签是否是执行所必需的,当这些标签被排除在外时,代码是否访问了一些不应该访问的地址,这些围绕执行代码的标签是否与 start(=='{' ) 和 java 类中 main() 的结尾(=='}')?

*附加信息和结果

我正在编写一个程序来打印数组中包含的数字 1-5。我在添加和不添加标签的情况下进行了尝试,结果如下:

;assembly for printing an array of the integers 1-5

;data segment
data segment
NIZA db 1,2,3,4,5
ends

;code segment
code segment
start: ;the "start:" label

;setting ds and es
mov ax,data
mov ds,ax
mov es,ax


mov bx,OFFSET NIZA
mov cx,5
pecatenje_na_niza:
mov dl,[bx]
add dx,48d
mov ah,2
int 21h
inc bx
loop pecatenje_na_niza
mov ah,1
int 21h
mov ah,4ch
int 21h

end start ;the "end start" label

ends

1) start:end start 包括:

  • 程序按预期运行,输出是打印的数组的所有元素。

2) start: and end start not included (相同的代码,但排除了标签):

  • 当程序启动时,会执行以下几行,但不在我包含 start:end start 的行中:
    (我找不到从模拟器复制的方法,所以我要粘贴截图) extra lines added when <code>start:</code> and <code>end start</code> are not included
    下面是执行这行代码前后模拟器中NIZA数组的值:

  • 之前: Array values before executing the starting code

  • 之后: Array values after executing the starting code

最后输出全为零。

  • 输出: Result after the execution of the whole program

因为add dx,48d这一行,所以打印是原样,所以它打印的都是00000。顺便说一句,每次 mov dl,[bx] 执行时 DX 都会重置。

这就是我目前所能理解和找到的全部内容。

最佳答案

如果您不包含 start,emu8086 显然会默认从头开始。由于您将数据放在那里,您的指令只是您的 NIZA 数组值被解释为代码。

 1 00000000 0102                    add [bp+si], ax
2 00000002 0304 add ax, [si]
3 00000004 050000 add ax, strict word 0
4 00000007 0000 add [bx+si], al

您可以看到您的字节 1-5,然后是一些零填充。 cpu 不关心你打算将它们作为数据,如果它们在执行路径中,它会尝试将它们解码为指令。

关于assembly - 如果不添加 start : and end start in EMU8086? 会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58902858/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com