I am new to assembly programming and am having trouble printing a character to the screen. Every time I execute my program I get a segmentation fault and I am not sure why.
.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
These are the commands I use to build (my file is named write.s)
as write.s -o write.o
ld write.o -o write
Is this not the correct way to print a character? Any help would be appreciated.