From bf34309f946621e4369606e4ceba3ccb28050de6 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 18 Nov 2020 17:40:47 +0000 Subject: Pretty cool FossilOrigin-Name: 78a3fce27b2e7b39da0eeb58d3d28e5997e438d4 --- src/c_bsdsetsid.S | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/c_bsdsetsid.S') 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" -- cgit v1.2.3