nasm x64编程
输出resb类型的变量出现段错误
section .data
msg dq "hello",10,0
len equ 5
hiii dq "hi ",10,0
section .bss
input resd 15
section .text
global _start
_start:
push rbp
mov rbp,rsp
call inpmain
mov rax,1
mov rdi,1
mov rsi,hiii
mov rdx,6
syscall
mov rsi,input
mov rdx,15
syscall
leave
ret
;---------------------------------
inpmain:
push rbp
mov rbp,rsp
mov rax,0
mov rdi,1
mov rsi,input
mov rdx,15
syscall
leave
ret
编译命令:
nasm -f elf64 hi.s -o hi.o
ld hi.o -o hi.out
运行时报错:
h
hi zsh: segmentation fault ./hi.out
我刚学汇编,求解决。