*MLE解决方案2
2025-07-15 08:15:06
发布于:上海
0阅读
0回复
0点赞
dpsk给了几个关于Linux系统核心的代码
// 编译: g++ -nostdlib -O1 -o program program.cpp
// 运行: ./program (输出2)
asm(R"(
.global _start
_start:
# 写入系统调用 (syscall 1)
mov $1, %rax # sys_write
mov $1, %rdi # fd = stdout
lea msg(%rip), %rsi # 消息地址
mov $1, %rdx # 长度=1字节
syscall
# 退出系统调用 (syscall 60)
mov $60, %rax # sys_exit
xor %rdi, %rdi # 退出码=0
syscall
msg:
.ascii "2" # 常量数据
)");
但是编译错误,不行
这里空空如也
有帮助,赞一个