很抱歉,这很简单-我对代码很熟悉,但对汇编程序来说是新手,无法在线找到许多对初学者友好的资源。
我想获得一个简单的print语句,以在nasm 64位环境中运行。我正在提取最初在32位上工作的代码,但我不知道为什么它在这里不起作用。
我尝试更改寄存器以使用rax而不是eax-根据我的理解,将“ e”替换为“ r”对应于64位寄存器对应物
;nasm 2.11.08
section .text
global _start
_start:
call func
mov eax, 1
mov ebx, 0
int 0x80
func:
mov ebp, esp ; ebp is the base pointer - holds the value of the top of the stack
sub esp, 2 ; removing 16 bits (2 bytes) from our stack pointer. Means allocating 2 bytes on the stack
mov [esp], byte 'H'
mov [esp+1], byte 'i'
mov eax, 4 ; sys write call
mov ebx, 1
mov ecx, esp
mov edx, 2
int 0x80
mov esp, ebp ; puts stack back into state where it was
ret
我在64位环境中进行编译-具体而言,该网站为:https://rextester.com/l/nasm_online_compiler
但是,出现以下错误
Invalid memory reference (SIGSEGV
我希望看到输出“ Hi”打印到控制台。任何指导表示赞赏!或者只是我可以用来更好地了解寄存器的资源
欢呼