STDIN equ 0 STDOUT equ 1 STDERR equ 2 O_RDONLY equ 0 O_WRONLY equ 1 O_RDWR equ 2 macro scall1 v_rax, v_rdi { mov rax, v_rax mov rdi, v_rdi syscall } macro scall2 v_rax, v_rdi, v_rsi { mov rax, v_rax mov rdi, v_rdi mov rsi, v_rsi syscall } macro scall3 v_rax, v_rdi, v_rsi, v_rdx { mov rax, v_rax mov rdi, v_rdi mov rsi, v_rsi mov rdx, v_rdx syscall } macro ls_read fd, buf, count { scall3 0, fd, buf, count } macro ls_write fd, buf, count { scall3 1, fd, buf, count } macro ls_open filename, flags, mode { scall3 2, filename, flags, mode } macro ls_close fd { scall1 3, fd } ;; kernel: arch/x86/include/uapi/asm/stat.h ;; struc stat ;; { ;; .st_dev rd 1 ;; .st_ino rd 1 ;; .st_mode rw 1 ;; .st_nlink rw 1 ;; .st_uid rw 1 ;; .st_gid rw 1 ;; .st_rdev rd 1 ;; .st_size rd 1 ;; .st_blksize rd 1 ;; .st_blocks rd 1 ;; ;; .st_atime rd 1 ;; .st_atime_nsec rd 1 ;; .st_mtime rd 1 ;; .st_mtime_nsec rd 1 ;; .st_ctime rd 1 ;; .st_ctime_nsec rd 1 ;; ;; .__unused4 rd 1 ;; .__unused5 rd 1 ;; } macro ls_stat filename, statbuf { scall2 4, filename, statbuf } macro ls_exit status { scall1 60, status }