diff options
| author | Klaatu <[email protected]> | 2015-05-17 15:33:21 +1200 |
|---|---|---|
| committer | Klaatu <[email protected]> | 2015-05-17 15:33:21 +1200 |
| commit | b0de699679e8f1e39af847ed172d1ba605b4370c (patch) | |
| tree | 01dac00471d61f727394e508c613b29cff0ceae5 /S | |
bulk upload of source
Diffstat (limited to 'S')
| -rw-r--r-- | S/atoulong.S | 17 | ||||
| -rw-r--r-- | S/byte_copy.S | 23 | ||||
| -rw-r--r-- | S/byte_copyr.S | 22 | ||||
| -rw-r--r-- | S/byte_diff.S | 19 | ||||
| -rw-r--r-- | S/byte_set.S | 5 | ||||
| -rw-r--r-- | S/byte_zero.S | 16 | ||||
| -rw-r--r-- | S/str_chr.S | 17 | ||||
| -rw-r--r-- | S/str_copy.S | 18 | ||||
| -rw-r--r-- | S/str_copyn.S | 22 | ||||
| -rw-r--r-- | S/str_diff.S | 22 | ||||
| -rw-r--r-- | S/str_diffn.S | 26 | ||||
| -rw-r--r-- | S/str_len.S | 11 | ||||
| -rw-r--r-- | S/str_rchr.S | 24 |
13 files changed, 242 insertions, 0 deletions
diff --git a/S/atoulong.S b/S/atoulong.S new file mode 100644 index 0000000..7d141ed --- /dev/null +++ b/S/atoulong.S @@ -0,0 +1,17 @@ +.globl atoulong +.type atoulong,@function +atoulong: + xorl %edx,%edx + xorl %eax,%eax + movl 4(%esp),%ecx + jmp .L1 +.L2: + imull $10,%eax,%eax + addl %edx,%eax + incl %ecx +.L1: + movb (%ecx),%dl + subb $48,%dl + cmpb $9,%dl + jbe .L2 + ret diff --git a/S/byte_copy.S b/S/byte_copy.S new file mode 100644 index 0000000..44ff449 --- /dev/null +++ b/S/byte_copy.S @@ -0,0 +1,23 @@ +.globl byte_copy +.type byte_copy, @function +byte_copy: + pushl %edi + pushl %esi + movl 12(%esp), %edi + movl 16(%esp), %ecx + movl 20(%esp), %esi + cld + +#ifdef BYTE_COPY_FAST + movl %ecx, %eax + shrl $2, %ecx + andl $3, %eax + + rep movsl + movl %eax, %ecx +#endif + rep movsb + + popl %esi + popl %edi + ret diff --git a/S/byte_copyr.S b/S/byte_copyr.S new file mode 100644 index 0000000..bcc9b21 --- /dev/null +++ b/S/byte_copyr.S @@ -0,0 +1,22 @@ +.text +.globl byte_copyr +.type byte_copyr, @function +byte_copyr: + pushl %edi + pushl %esi + movl 12(%esp), %edi + movl 20(%esp), %esi + movl 16(%esp), %ecx + + decl %edi + decl %esi + addl %ecx, %edi + addl %ecx, %esi + + std + rep movsb + cld + + popl %esi + popl %edi + ret diff --git a/S/byte_diff.S b/S/byte_diff.S new file mode 100644 index 0000000..f9d6c16 --- /dev/null +++ b/S/byte_diff.S @@ -0,0 +1,19 @@ +.global byte_diff +.type byte_diff,function +byte_diff: + pushl %esi + pushl %edi + xorl %eax, %eax + movl 12(%esp), %esi + movl 16(%esp), %ecx + movl 20(%esp), %edi + + cld + rep cmpsb + jz .Lout + sbbl %eax, %eax + orl $1, %eax +.Lout: + popl %edi + popl %esi + ret diff --git a/S/byte_set.S b/S/byte_set.S new file mode 100644 index 0000000..a61b3ad --- /dev/null +++ b/S/byte_set.S @@ -0,0 +1,5 @@ +.globl byte_set +.type byte_set, @function +byte_set: + movb 12(%esp), %al + jmp byte_zero_end diff --git a/S/byte_zero.S b/S/byte_zero.S new file mode 100644 index 0000000..01c166b --- /dev/null +++ b/S/byte_zero.S @@ -0,0 +1,16 @@ +.globl byte_zero +.type byte_zero, @function +byte_zero: + xorb %al, %al + +.globl byte_zero_end +byte_zero_end: + pushl %edi + movl 8(%esp), %edi + movl 12(%esp), %ecx + + cld + rep stosb + + popl %edi + ret diff --git a/S/str_chr.S b/S/str_chr.S new file mode 100644 index 0000000..5fec8b2 --- /dev/null +++ b/S/str_chr.S @@ -0,0 +1,17 @@ +.globl str_chr +.type str_chr, @function +str_chr: + pushl %esi + movl 8(%esp), %esi + movb 12(%esp), %ah +.L1: + lodsb + cmpb %ah,%al + je .L2 + testb %al,%al + jne .L1 +.L2: + leal -1(%esi), %eax + subl 8(%esp), %eax + popl %esi + ret diff --git a/S/str_copy.S b/S/str_copy.S new file mode 100644 index 0000000..c24dbac --- /dev/null +++ b/S/str_copy.S @@ -0,0 +1,18 @@ +.globl str_copy +.type str_copy, @function +str_copy: + pushl %edi + pushl %esi + movl 12(%esp), %edi + movl 16(%esp), %esi +.L1: + lodsb + stosb + testb %al,%al + jne .L1 + + leal -1(%edi), %eax + subl 12(%esp), %eax + popl %esi + popl %edi + ret diff --git a/S/str_copyn.S b/S/str_copyn.S new file mode 100644 index 0000000..7a8765c --- /dev/null +++ b/S/str_copyn.S @@ -0,0 +1,22 @@ +.globl str_copyn +.type str_copyn, @function +str_copyn: + pushl %edi + pushl %esi + movl 12(%esp), %edi + movl 16(%esp), %esi + movl 20(%esp), %ecx +.L1: + decl %ecx + js .L2 + lodsb + stosb + testb %al,%al + jne .L1 + decl %edi +.L2: + movl %edi, %eax + subl 12(%esp), %eax + popl %esi + popl %edi + ret diff --git a/S/str_diff.S b/S/str_diff.S new file mode 100644 index 0000000..a90724e --- /dev/null +++ b/S/str_diff.S @@ -0,0 +1,22 @@ +.globl str_diff +.type str_diff, @function +str_diff: + pushl %edi + pushl %esi + movl 12(%esp), %esi + movl 16(%esp), %edi +.L1: + lodsb + scasb + jne .L2 + testb %al,%al + jne .L1 + xorl %eax,%eax + jmp .L3 +.L2: + sbbl %eax,%eax + orb $1,%al +.L3: + popl %esi + popl %edi + ret diff --git a/S/str_diffn.S b/S/str_diffn.S new file mode 100644 index 0000000..954d88f --- /dev/null +++ b/S/str_diffn.S @@ -0,0 +1,26 @@ +.globl str_diffn +.type str_diffn, @function +str_diffn: + pushl %edi + pushl %esi + movl 12(%esp), %esi + movl 16(%esp), %edi + movl 20(%esp), %ecx +.L1: + decl %ecx + js .L2 + lodsb + scasb + jne .L3 + testb %al,%al + jne .L1 +.L2: + xorl %eax,%eax + jmp .L4 +.L3: + sbbl %eax,%eax + orb $1,%al +.L4: + popl %esi + popl %edi + ret diff --git a/S/str_len.S b/S/str_len.S new file mode 100644 index 0000000..ba3fa7e --- /dev/null +++ b/S/str_len.S @@ -0,0 +1,11 @@ +.globl str_len +.type str_len, @function +str_len: + movl 4(%esp), %ecx + orl $-1, %eax +.L1: + incl %eax + cmpb $0, (%ecx, %eax) + jne .L1 + + ret diff --git a/S/str_rchr.S b/S/str_rchr.S new file mode 100644 index 0000000..032c393 --- /dev/null +++ b/S/str_rchr.S @@ -0,0 +1,24 @@ +.globl str_rchr +.type str_rchr, @function +str_rchr: + pushl %esi + movl 8(%esp), %esi + movb 12(%esp), %ah + xorl %ecx, %ecx +.L1: + lodsb + cmpb %ah,%al + jne .L0 + movl %esi, %ecx +.L0: + testb %al,%al + jne .L1 + + testl %ecx, %ecx + jnz .L3 + movl %esi, %ecx +.L3: + subl 8(%esp), %ecx + leal -1(%ecx), %eax + popl %esi + ret |
