diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | src/c_bsdsetsid.S | 25 |
2 files changed, 16 insertions, 10 deletions
@@ -23,6 +23,7 @@ PREFIX := /usr/local/ DESTDIR := SRCS := ${SRCS_DIR}c_bsdsetsid.S +SRCS += ${SRCS_DIR}u_strlen.S OBJS = ${SRCS:.S=.o} diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S index 29eacdc..73ab582 100644 --- a/src/c_bsdsetsid.S +++ b/src/c_bsdsetsid.S @@ -1,23 +1,28 @@ .text +.extern u_strlen .globl main -c_main: - movq $0x1, %rdi +main: xorq %rcx, %rcx - inc %rcx - movq (%rdx, %rcx, 8), %rsi - movq $0xa, %rdx + movq (%rsi, %rcx, 8), %rsi + movq %rsi, %rdi + callq u_strlen + movq $0x1, %rdi + movq %rax, %rdx + xorq %rax, %rax movb $0x4, %al syscall - retq - -main: + movq $0x1, %rdi + leaq nl, %rsi + movq $0x1, %rdx + xorq %rax, %rax + movq $0x4, %rax + syscall xorq %rax, %rax - callq c_main xorq %rax, %rax xorq %rdi, %rdi movb $0x1, %al syscall .data - str: .asciz "a string\n" + nl: .asciz "\n" |