Created
November 12, 2009 19:05
-
-
Save stepancheg/233190 to your computer and use it in GitHub Desktop.
newline detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "hello.c" | |
.text | |
.p2align 4,,15 | |
.globl find_newline | |
.type find_newline, @function | |
find_newline: | |
.LFB3: | |
xorl %edx, %edx | |
testq %rsi, %rsi | |
je .L3 | |
movzbl (%rdi), %ecx | |
movl $1, %edx | |
cmpb $10, %cl | |
je .L3 | |
xorl %eax, %eax | |
cmpb $13, %cl | |
movl $1, %edx | |
jne .L11 | |
jmp .L6 | |
.p2align 4,,10 | |
.L9: | |
movzbl (%rdi,%rax), %edx | |
cmpb $10, %dl | |
je .L14 | |
cmpb $13, %dl | |
.p2align 4,,5 | |
je .L15 | |
.L11: | |
addq $1, %rax | |
cmpq %rax, %rsi | |
ja .L9 | |
movq %rax, %rdx | |
.L3: | |
movq %rdx, %rax | |
.p2align 4,,1 | |
ret | |
.p2align 4,,10 | |
.L15: | |
leaq 1(%rax), %rdx | |
.L6: | |
cmpq %rdx, %rsi | |
jbe .L3 | |
addq $2, %rax | |
cmpb $10, (%rdi,%rdx) | |
cmove %rax, %rdx | |
movq %rdx, %rax | |
ret | |
.p2align 4,,10 | |
.L14: | |
leaq 1(%rax), %rdx | |
movq %rdx, %rax | |
ret | |
.LFE3: | |
.size find_newline, .-find_newline | |
.section .eh_frame,"a",@progbits | |
.Lframe1: | |
.long .LECIE1-.LSCIE1 | |
.LSCIE1: | |
.long 0x0 | |
.byte 0x1 | |
.string "zR" | |
.uleb128 0x1 | |
.sleb128 -8 | |
.byte 0x10 | |
.uleb128 0x1 | |
.byte 0x3 | |
.byte 0xc | |
.uleb128 0x7 | |
.uleb128 0x8 | |
.byte 0x90 | |
.uleb128 0x1 | |
.align 8 | |
.LECIE1: | |
.LSFDE1: | |
.long .LEFDE1-.LASFDE1 | |
.LASFDE1: | |
.long .LASFDE1-.Lframe1 | |
.long .LFB3 | |
.long .LFE3-.LFB3 | |
.uleb128 0x0 | |
.align 8 | |
.LEFDE1: | |
.ident "GCC: (GNU) 4.3.4 20090621 (prerelease)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment