我是汇编编程的新手,无法在屏幕上打印字符。每次我执行我的程序时,我都会遇到分段错误,我不知道为什么。
.section .data
A:
.long 65 # ascii code for 'A'
.section .text
.globl _start
_start:
movl $1, %edx # length of character to print, 1
movl A, %ecx # what I want printed
movl $1, %ebx # file descriptor for STDOUT
movl $4, %eax # syscall number for sys_write
int $0x80 # calls kernel
movl $0, %ebx # return status
movl $1, %eax # syscall number for sys_exit
int $0x80 # calls kernel
这些是我用来构建的命令 (我的文件名为 write.s)
as write.s -o write.o
ld write.o -o write
这不是打印字符的正确方法吗?任何帮助,将不胜感激。