【发布时间】:2016-06-04 02:03:32
【问题描述】:
来自我之前的疑问 - Difference between “mov eax, [num]” and “mov eax, num”
我知道“mov eax, num”将num的地址存储在eax中,“mov eax, [num]”将num的值存储在eax中
现在在这里!
mov edx, strLen ; Arg three: the length of the string
mov ecx, str ; Arg two: the address of the string
mov ebx, 1 ; Arg one: file descriptor, in this case stdout
mov eax, 4 ; Syscall number, in this case the write(2)
int 0x80 ; Interrupt 0x80
section .data
str: db 'Hello, world!',0xA
strLen: equ $-str
理想的edx寄存器应该有长度,所以
- as " mov ecx, str " - 将 str 的地址 存储在 ecx 中
- 没有“mov edx, strlen”也应该存储strlen的地址而不是edx中的值。
- 在edx中存储strlen的值,为什么不使用“mov edx, [strlen]”
以下代码引用自此链接 - http://asm.sourceforge.net/intro/hello.html
它杀了我!
在此先感谢...
【问题讨论】:
-
是 .data 部分中的声明,而不是 .bss 部分中的声明与我的问题有任何关系! PS:我知道 .data 部分用于声明常量,而 .bss 部分用于声明变量。
-
"mov eax, [num] " 将值 of num in eax" 可能更准确地表述为 "mov eax, [num] " 将值 at num in eax" 存储值,这可能就是您的意思。
-
@lurker 是的,Lurker 就是我的意思
标签: assembly nasm inline-assembly