你机器是64位cpu吧,你按32位汇编教材上的例子,64位机器上直接跑一旦涉及到内存地址必然会报段错误的。64位机器上函数调用方法也和32位不同了,即使不扯到内存地址,你的程序也没法达到目的的。
section .datareadfile: , .ascii "r"createfile: , .ascii "w"readfilepath: , .ascii "/home/cpp/compile/5/hey.s0"createfilepath: , .ascii "/home/cpp/compile/5/hey0".section .bss.equ BUFFER_SIZE, 500.lcomm BUFFER_DATA, BUFFER_SIZE.section .text#栈位置.equ ST_SIZE_RESERVE, 8.equ ST_FD_IN, -4.equ ST_FD_OUT, -8.equ END_OF_FILE, 0.globl _start_start: ,movl %esp, %ebp,subl $ST_SIZE_RESERVE, %espopen_files:open_fd_in: ,pushl $readfile ,pushl $readfilepath ,call fopenstore_fd_in: ,movl %eax, ST_FD_IN(%ebp)open_fd_out: ,pushl $createfile ,pushl $createfilepath ,call fopenstore_fd_out: ,movl %eax, ST_FD_OUT(%ebp)read_loop_begin: ,pushl ST_FD_IN(%ebp) ,pushl $BUFFER_SIZE ,pushl $BUFFER_DATA ,call fgets ,cmpl $0, %eax ,jle end_loopcontinue_read_loop: ,p