Created
March 14, 2012 16:31
-
-
Save wvdschel/2037681 to your computer and use it in GitHub Desktop.
mips memset
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
### memset2 ### | |
.macro f_fill64 dst, offset, val, fixup | |
9: sw \val, (\offset + 0 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 1 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 2 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 3 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 4 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 5 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 6 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 7 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 8 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 9 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 10 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 11 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 12 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 13 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 14 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
9: sw \val, (\offset + 15 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous | |
.endm | |
.set noreorder | |
.align 5 | |
.globl memset2; .align 2; .type memset2, @function; .ent memset2, 0; memset2: .frame $29, 0, $31 | |
beqz $5, 1f | |
move $2, $4 | |
andi $5, 0xff | |
sll $9, $5, 8 | |
or $5, $9 | |
sll $9, $5, 16 | |
or $5, $9 | |
1: | |
.globl __bzero; .type __bzero, @function; __bzero: | |
.set push; .set mips4; pref 1, 0($4); .set pop | |
sltiu $8, $6, 4 | |
bnez $8, .Lsmall_memset2 | |
andi $8, $4, 3 | |
beqz $8, 1f | |
subu $8, 4 | |
9: swr $5, ($4); .section __ex_table,"a"; .word 9b, .Lfirst_fixup; .previous | |
subu $4, $8 | |
addu $6, $8 | |
1: ori $9, $6, 0x3f | |
xori $9, 0x3f | |
beqz $9, .Lmemset2_partial | |
andi $8, $6, 0x40-4 | |
addu $9, $4 | |
.set reorder | |
subu $10, $9, $4 | |
sltu $11, $10, 64 | |
bnez $11, 1f | |
.set push; .set mips4; pref 30, 32($4); .set pop | |
sltu $11, $10, 128 | |
bnez $11, 1f | |
.set push; .set mips4; pref 30, 64($4); .set pop | |
.set push; .set mips4; pref 30, 96($4); .set pop | |
sltu $11, $10, 192 | |
bnez $11, 1f | |
2: | |
.set push; .set mips4; pref 30, 128($4); .set pop | |
.set push; .set mips4; pref 30, 160($4); .set pop | |
1: addiu $4, 64 | |
f_fill64 $4, -64, $5, .Lfwd_fixup | |
subu $10, $9, $4 | |
sltu $11, $10, 192 | |
beqz $11, 2b | |
bne $9, $4, 1b | |
.set noreorder | |
.Lmemset2_partial: | |
la $9, 2f | |
subu $9, $8 | |
jr $9 | |
addu $4, $8 | |
.set push | |
.set noreorder | |
.set nomacro | |
f_fill64 $4, -64, $5, .Lpartial_fixup | |
2: .set pop | |
andi $6, 3 | |
beqz $6, 1f | |
addu $4, $6 | |
9: swl $5, -1($4); .section __ex_table,"a"; .word 9b, .Llast_fixup; .previous | |
1: jr $31 | |
move $6, $0 | |
.Lsmall_memset2: | |
beqz $6, 2f | |
addu $9, $4, $6 | |
1: addiu $4, 1 | |
bne $9, $4, 1b | |
sb $5, -1($4) | |
2: jr $31 | |
move $6, $0 | |
.end memset2; .size memset2, .-memset2 | |
.Lfirst_fixup: | |
jr $31 | |
nop | |
.Lfwd_fixup: | |
lw $8, 0($28) | |
lw $8, 880($8) | |
andi $6, 0x3f | |
addu $6, $9 | |
jr $31 | |
subu $6, $8 | |
.Lpartial_fixup: | |
lw $8, 0($28) | |
lw $8, 880($8) | |
andi $6, 3 | |
addu $6, $9 | |
jr $31 | |
subu $6, $8 | |
.Llast_fixup: | |
jr $31 | |
andi $3, $6, 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment