aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_bsdsetsid.S
blob: 17cf57b551784426c490db8d38a7c79261e099e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.text
.extern	u_strlen
.extern	u_pout
.extern	u_perr
.globl	main

main:
	cmpb	$0x1, %dil
	jle		c_noarg
	pushq	%rdi
	pushq	%rsi
	pushq	%rdx
	xorq	%rcx, %rcx
	movq	(%rsi, %rcx, 8), %rdi
	movq	%rcx, %r8
	callq	u_pout
	movq	%r8, %rcx
	popq	%rdx
	popq	%rsi
	popq	%rdi
	pushq	%rdi
	pushq	%rsi
	pushq	%rdx
	inc		%rcx
	movq	(%rsi, %rcx, 8), %rdi
	callq	u_pout
	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_exit:
	xorq	%rdi, %rdi
	xorq	%rax, %rax
	movb	$0x1, %al	# SYS_exit
	syscall

.data
noarg_str:	.asciz "bsdsetsid: no command specified"