# Ejects the device located at /dev/cdrom
#
# as eject.s -o eject.o && ld eject.o -o eject
#####################################################

.section .bss
        .lcomm cdrom_fd, 4      # define this variable to hold the fd returned when calling open()

.section .data
cdrom_file:                     # location of the cdrom
        .asciz "/dev/hdc"       # change this if needed

.section .text
.globl _start
_start:
        # open(cdrom_file)
        movl $5, %eax
        movl $cdrom_file, %ebx
        movl $4000, %ecx
        movl $0, %edx
        int $0x80

        movl %eax, cdrom_fd     # copy the return fd to cdrom_fd

        # ioctl()
        movl $54, %eax
        movl cdrom_fd, %ebx
        movl $0x00005309, %ecx
        int $0x80

        # close(cdrom_fd)
        movl $6, %eax
        movl cdrom_fd, %ebx
        int $0x80

        # _exit(0)
        movl $1, %eax
        movl $0, %ebx
        int $0x80

