所以我有问题。我正在尝试在这个简单的字符串“Hello World”中更改一个字母 所以我正在尝试为这样的内存单元分配值
.section .text
string:
.ascii "Hello, world!"
length:
.quad . -string #Dot = 'here'
.globl _start #Make entry point visible to linker
_start:
movl $4, %eax #4=write
movl $1, %ebx #1=stdout
movl $string, %ecx
movl length, %edx
int $0x80 #Call Operating System
movl $98,4(%ecx) #Critical moment why cannot I do this?
movl $98,string(,%ebx,1) #cannot do this too ;(
movl $4, %eax #4=write
movl $1, %ebx #1=stdout
movl $string, %ecx
movl length, %edx
int $0x80
movl $0, %ebx #Make program return syscall exit status
movl $1, %eax #1=exit
int $0x80 #Call System Again
和其他信息我正在x64(linux)工作,并通过linux gas在仿真模式x32中组装它应该没事,TY回复
答案 0 :(得分:3)
您已将字符串放入.text
部分,该部分为只读。您应该将其放入.data
部分(但不要忘记切换回.text
以获取程序代码。)