From b5266802fb585596234faff4ee92bc4d04294ea2 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 19 Nov 2020 20:57:22 +0000 Subject: In good progress FossilOrigin-Name: 40f3efb8963f27cbb111250ced45c7623211eec7 --- src/c_bsdsetsid.S | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src') 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" -- cgit v1.2.3