aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_bsdsetsid.S
blob: de55b7fd4d42c4118e40522c3906e2efdda94404 (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
	push	%rdi
	push	%rsi
	push	%rdx
	xor		%rcx, %rcx
	mov		(%rsi, %rcx, 8), %rdi
	mov		%rcx, %r8
	call	u_pout
	mov		%r8, %rcx
	pop		%rdx
	pop		%rsi
	pop		%rdi
	push	%rdi
	push	%rsi
	push	%rdx
	inc		%rcx
	mov		(%rsi, %rcx, 8), %rdi
	call	u_pout
	pop		%rdx
	pop		%rsi
	pop		%rdi
	jmp		c_exit

c_noarg:
	lea		noarg_str, %rdi
	call	u_perr
	mov		$0x1, %rdi
	xor		%rax, %rax
	movb	$0x1, %al	# SYS_exit
	syscall

c_exit:
	xor		%rdi, %rdi
	xor		%rax, %rax
	movb	$0x1, %al	# SYS_exit
	syscall

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