这是代码(exit.s):
.section .data,
.section .text,
.globl _start
_start:
movl $1, %eax
movl $32, %ebx
syscall
Run Code Online (Sandbox Code Playgroud)
当我执行 " as exit.s -o exit.o && ld exit.o -o exit -e _start && ./exit"
返回是"总线错误:10",输出" echo $?"是138
我也在这个问题中尝试了正确答案的例子:Linux 64位中的进程命令行
stil得到"总线错误"......
这是我第一次尝试用汇编编程。我使用的是 64 位 Mac 操作系统。我也在使用 NASM。我已经做了很多寻找解决方案的工作,但我找不到任何适合我的机器的东西。
谁能帮我解决这个问题?这是代码和错误,谢谢!
你好.asm
global start
section .text
start:
mov rax, 1
mov rdi, 1
mov rsi, message
mov rdx, 13
syscall
mov eax, 60
xor rdi, rdi
syscall
message:
db "Hello, World", 10
Run Code Online (Sandbox Code Playgroud)
我尝试执行:
nasm -f macho64 hello.asm -o hello.o
ld -arch i386 -o hello hello.o
./hello
Run Code Online (Sandbox Code Playgroud)
错误
ld: warning: -macosx_version_min not specified, assuming 10.10
ld: warning: ignoring file hello.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 …Run Code Online (Sandbox Code Playgroud) 我是新来的汇编语言,我必须做出的实现读取用汇编语言功能x64在MAC。到目前为止,这就是我所做的:
;;;;;;ft_read.s;;;;;;
global _ft_read:
section .text
extern ___error
_ft_read:
mov rax, 0x2000003 ; store syscall value of read on rax
syscall ; call read and pass to it rdi , rsi, rdx ==> rax read(rdi, rsi, rdx)
cmp rax, 103 ; compare rax with 103 by subtracting 103 from rax ==> rax - 103
jl _ft_read_error ; if the result of cmp is less than 0 then jump to _ft_read_error
ret ; else return …Run Code Online (Sandbox Code Playgroud)