Assembly 当esp没有';T
是否有理由在以下情况下取消引用Assembly 当esp没有';T,assembly,x86,nasm,Assembly,X86,Nasm,是否有理由在以下情况下取消引用ebp寄存器会对程序进行分段故障诊断 取消引用esp寄存器没有? 两个寄存器包含相同的值 例如,下面的代码片段将为我崩溃 mov ebp, esp mov eax, [ebp] 但下一个代码段不会 mov eax, [esp] 我已经包括了一个完整的nasm程序,该程序因这个问题而崩溃。 我弄不懂原因 section .text global main %define TEST 'My test' BITS 32 main: push dword
ebp
寄存器会对程序进行分段故障诊断
取消引用esp
寄存器没有?
两个寄存器包含相同的值
例如,下面的代码片段将为我崩溃
mov ebp, esp
mov eax, [ebp]
但下一个代码段不会
mov eax, [esp]
我已经包括了一个完整的nasm程序,该程序因这个问题而崩溃。
我弄不懂原因
section .text
global main
%define TEST 'My test'
BITS 32
main:
push dword msg
jmp print_message
carry_on_here:
mov eax, 1 ; The system call (sys_exit)
int 0x80 ; System interupt which invokes the kernel
print_message:
mov ebp, esp ; Store esp in ebp
mov ecx, [ebp] ; <---- CRASH BECAUSE OF THIS, works with "mov ecx, [esp]"
mov edx, len ; Length of message
mov ebx, 1 ; the stdout file descriptor
mov eax,4 ; the system call (sys_write)
int 0x80 ; system interupt which invokes the kernel
jmp carry_on_here
section .bss
section .data ; The memory here is initialised
msg db "My message" ,10 ;the message. Allocate d (initialised), b (bytes) , 10 of them which is: db "Initalised" 10
len equ $ - msg ;the message length
section.text
全球主要
%定义测试“我的测试”
第32位
主要内容:
推送德沃德消息
jmp打印消息
在这里随身携带:
mov-eax,1;系统调用(系统退出)
int 0x80;调用内核的系统中断
打印信息:
mov-ebp,esp;将esp存储在ebp中
mov-ecx[ebp];无法复制问题。对我来说很好。组装为“nasm-f elf32 myprog.asm”,链接为“ld-o myprog.o-e main-melf_i386”。你做了什么?它是否会给你一个特定的错误消息?在调试器中按指令逐步检查代码,看看发生了什么?我首先想到了段寄存器的问题,但esp和ebp都使用SS作为默认段。不过,检查段寄存器的内容也无妨。谢谢弗兰克!我造错了。应该是“-f elf32”,但我把elf64留在那里了。