aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <JozanLeClerc@noemail.net>2020-11-19 20:57:22 +0000
committerJozanLeClerc <JozanLeClerc@noemail.net>2020-11-19 20:57:22 +0000
commitb5266802fb585596234faff4ee92bc4d04294ea2 (patch)
treea20aefbfc4dfcac5c694136187f0aaf65b4d5570
parentIn progress (diff)
downloadbsdsetsid-b5266802fb585596234faff4ee92bc4d04294ea2.tar.gz
bsdsetsid-b5266802fb585596234faff4ee92bc4d04294ea2.tar.bz2
bsdsetsid-b5266802fb585596234faff4ee92bc4d04294ea2.tar.xz
bsdsetsid-b5266802fb585596234faff4ee92bc4d04294ea2.tar.zst
bsdsetsid-b5266802fb585596234faff4ee92bc4d04294ea2.zip
In good progress
FossilOrigin-Name: 40f3efb8963f27cbb111250ced45c7623211eec7
-rw-r--r--.fossil-settings/ignore-glob1
-rw-r--r--Makefile2
-rw-r--r--src/c_bsdsetsid.S46
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*
diff --git a/Makefile b/Makefile
index 67a99cc..88f7aa4 100644
--- a/Makefile
+++ b/Makefile
@@ -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"