	.section	.rodata

# TODO: Fix strings
	.global	sys_nerr
	.type	sys_nerr, @object
sys_nerr:
	.long	36
NONE:
	.ascii	"\010No error\000"
EPERM:
	.ascii	"\027Operation not permitted\000"
ENOENT:
	.ascii	"\031No such file or directory\000"
ESRCH:
	.ascii	"\017No such process\000"
EINTR:
	.ascii	"\027Interrupted system call\000"
EIO:
	.ascii	"\011I/O error\000"
ENXIO:
	.ascii	"\031No such device or address\000"
E2BIG:
	.ascii	"\026Argument list too long\000"
ENOEXEC:
	.ascii	"\021Exec format error\000"
EBADF:
	.ascii	"\017Bad file number\000"
ECHILD:
	.ascii	"\022No child processes\000"
EAGAIN:
	.ascii	"\011Try again\000"
ENOMEM:
	.ascii	"\015Out of memory\000"
EACCES:
	.ascii	"\021Permission denied\000"
EFAULT:
	.ascii	"\013Bad address\000"
ENOTBLK:
	.ascii	"\025Block device required\000"
EBUSY:
	.ascii	"\027Device or resource busy\000"
EEXIST:
	.ascii	"\013File exists\000"
EXDEV:
	.ascii	"\021Cross-device link\000"
ENODEV:
	.ascii	"\016No such device\000"
ENOTDIR:
	.ascii	"\017Not a directory\000"
EISDIR:
	.ascii	"\016Is a directory\000"
EINVAL:
	.ascii	"\020Invalid argument\000"
ENFILE:
	.ascii	"\023File table overflow\000"
EMFILE:
	.ascii	"\023Too many open files\000"
ENOTTY:
	.ascii	"\020Not a typewriter\000"
ETXTBSY:
	.ascii	"\016Text file busy\000"
EFBIG:
	.ascii	"\016File too large\000"
ENOSPC:
	.ascii	"\027No space left on device\000"
ESPIPE:
	.ascii	"\014Illegal seek\000"
EROFS:
	.ascii	"\025Read-only file system\000"
EMLINK:
	.ascii	"\016Too many links\000"
EPIPE:
	.ascii	"\013Broken pipe\000"
EDOM:
	.ascii	"043Math argument out of domain of func\000"
ERANGE:
	.ascii	"\035Math result not representable\000"
	.long	15
ESOVFL:
	.ascii	"String overflow\000"
	.long	18
ESINDEX:
	.ascii	"String index error\000"

	.global	sys_errlist
	.type	sys_errlist, @object
sys_errlist:
	.long	NONE
	.long	EPERM
	.long	ENOENT
	.long	ESRCH
	.long	EINTR
	.long	EIO
	.long	ENXIO
	.long	E2BIG
	.long	ENOEXEC
	.long	EBADF
	.long	ECHILD
	.long	EAGAIN
	.long	ENOMEM
	.long	EACCES
	.long	EFAULT
	.long	ENOTBLK
	.long	EBUSY
	.long	EEXIST
	.long	EXDEV
	.long	ENODEV
	.long	ENOTDIR
	.long	EISDIR
	.long	EINVAL
	.long	ENFILE
	.long	EMFILE
	.long	ENOTTY
	.long	ETXTBSY
	.long	EFBIG
	.long	ENOSPC
	.long	ESPIPE
	.long	EROFS
	.long	EMLINK
	.long	EPIPE
	.long	EDOM
	.long	ERANGE
	.long	ESOVFL
	.long	ESINDEX

	.section	.text
	.global	strerror
	.type	strerror, @function
strerror:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$36, %edx
	cmpl	8(%ebp), %edx
	jnb	keep_value
	movl	$0, 8(%ebp)
keep_value:
	movl	8(%ebp), %edx
	movl	$0, %eax
	movl	sys_errlist(%eax, %edx, 4), %eax
	popl	%ebp
	ret
