assembly - 在汇编 x86-64 AT&T 中写入内存位置
问题描述
我正在尝试将数据从一个内存位置移动到另一个内存位置,然后打印结果。但我得到的只是一些垃圾价值,我不知道为什么。相关代码如下:
.bss
code: .skip 1000000
.data
smth: .asciz "somerandomtext"
format_str: .asciz "Contents of code:\n%s"
.text
main:
pushq %rbp
movq %rsp, %rbp
movq $smth , %rdi # move address of smth in rdi
movq $code , %rax # move address of code in rax
movq %rdi , (%rax) # move contents of rdi to address stored in rax ??
movq $0 , %rax
movq $code , %rsi
movq $format_str , %rdi
call printf
movq %rbp, %rsp
popq %rbp
我知道我选择的寄存器并不理想,我在做其他事情时遇到了这个问题。
解决方案
推荐阅读
- vba - VBA中基于调整单元格的公式
- spring - 我如何 RequestMapping 正则表达式禁用任何单词?
- java - 重新打包 Spring Boot 应用程序
- c - C中文字的生命周期
- python - 如何在linux服务器的python3中使用python2模块?
- java - 使用递归地图(Map of Maps)是一种好习惯吗
- python - 在多个标题数据框中选择一列
- groovy - groovy.lang.MissingPropertyException:没有这样的属性:类的getBtnRCR:CustomerCommonRequestBean
- c# - 在 C# 中通过异步 TCP 损坏包
- jquery - jQuery:textarea 占位符中的换行符不适用于 Mozilla Firefox