diff options
-rw-r--r-- | .fossil-settings/ignore-glob | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/c_bsdsetsid.S | 46 |
3 files changed, 30 insertions, 19 deletions
diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index b37143a..bcae5eb 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -5,3 +5,4 @@ bsdsetsid git *.gz *.o +vgcore* @@ -73,7 +73,7 @@ ${NAME}: ${OBJS} all: ${NAME} clean: - ${RM} ${OBJS} ${NAME} + ${RM} ${OBJS} ${NAME} vgcore* .PHONY: all clean diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S index 810fe8c..17cf57b 100644 --- a/src/c_bsdsetsid.S +++ b/src/c_bsdsetsid.S @@ -5,33 +5,43 @@ .globl main main: + cmpb $0x1, %dil + jle c_noarg + pushq %rdi + pushq %rsi + pushq %rdx xorq %rcx, %rcx - callq c_push movq (%rsi, %rcx, 8), %rdi + movq %rcx, %r8 callq u_pout - callq c_pop + movq %r8, %rcx + popq %rdx + popq %rsi + popq %rdi + pushq %rdi + pushq %rsi + pushq %rdx inc %rcx - callq c_push movq (%rsi, %rcx, 8), %rdi callq u_pout - callq c_pop - xorq %rdi, %rdi + popq %rdx + popq %rsi + popq %rdi + jmp c_exit + +c_noarg: + leaq noarg_str, %rdi + callq u_perr + movq $0x1, %rdi xorq %rax, %rax movb $0x1, %al # SYS_exit syscall -c_push: - movq %rdx, %r8 - movq %rsi, %r9 - movq %rdi, %r10 - retq - -c_pop: - movq %r8, %rdi - movq %r9, %rsi - movq %r10, %rdx - retq +c_exit: + xorq %rdi, %rdi + xorq %rax, %rax + movb $0x1, %al # SYS_exit + syscall .data -nl: .asciz "\n" -asd: .asciz "hey\n" +noarg_str: .asciz "bsdsetsid: no command specified" |