Skip to content

Instantly share code, notes, and snippets.

@thautwarm
Created October 30, 2019 13:40
Show Gist options
  • Save thautwarm/17b99ddb17d038d3826efa6c3b409919 to your computer and use it in GitHub Desktop.
Save thautwarm/17b99ddb17d038d3826efa6c3b409919 to your computer and use it in GitHub Desktop.
mips-alloc
.word 0x10000002 ; MERL cookie
.word 0x00000760 ; File Length (in bytes) is 1888
.word 0x00000640 ; Code Length (in bytes) is 1600
init:
sw $1, -4($30)
sw $2, -8($30)
sw $3, -12($30)
sw $4, -16($30)
sw $5, -20($30)
sw $6, -24($30)
sw $7, -28($30)
sw $8, -32($30)
lis $4
.word 0x00000020
sub $30, $30, $4
lis $1
.word 0x00000630 ; REL'd
lis $3
.word 0x00000400
lis $6
.word 0x00000010
lis $7
.word 0x00001000
lis $8
.word 0x00000001
add $2, $2, $2
add $2, $2, $2
add $2, $2, $6
add $5, $1, $6
add $5, $5, $2
add $5, $5, $3
sw $5, 0($1)
add $5, $5, $7
sw $5, 4($1)
sw $8, 8($1)
add $5, $1, $6
add $5, $5, $2
sw $5, 12($1)
sw $8, 0($5)
sw $0, 4($5)
add $30, $30, $4
lw $1, -4($30)
lw $2, -8($30)
lw $3, -12($30)
lw $4, -16($30)
lw $5, -20($30)
lw $6, -24($30)
lw $7, -28($30)
lw $8, -32($30)
jr $31
new:
sw $1, -4($30)
sw $2, -8($30)
sw $4, -12($30)
sw $5, -16($30)
sw $6, -20($30)
sw $7, -24($30)
sw $8, -28($30)
sw $9, -32($30)
sw $10, -36($30)
sw $11, -40($30)
sw $12, -44($30)
lis $10
.word 0x0000002c
sub $30, $30, $10
slt $3, $0, $1
beq $3, $0, 87
lis $11
.word 0x00000001
add $1, $1, $11
add $1, $1, $1
add $1, $1, $1
add $2, $11, $11
add $4, $0, $0
sub $1, $1, $11
beq $1, $0, 4
div $1, $2
mflo $1
add $4, $4, $11
beq $0, $0, -5
add $1, $1, $11
add $4, $4, $11
lis $5
.word 0x0000000e
sub $4, $5, $4
lis $5
.word 0x00000009
slt $6, $5, $4
beq $6, $0, 1
add $4, $5, $0
slt $3, $0, $4
beq $3, $0, 62
add $6, $4, $0
add $7, $11, $0
add $7, $7, $7
sub $6, $6, $11
bne $6, $0, -3
sub $7, $7, $11
lis $8
.word 0x000003a4 ; REL'd
sw $31, -4($30)
lis $31
.word 0x00000004
sub $30, $30, $31
jalr $8
lis $31
.word 0x00000004
add $30, $30, $31
lw $31, -4($30)
beq $3, $0, 44
add $7, $7, $11
div $7, $2
mflo $7
slt $6, $3, $7
bne $6, $0, 1
beq $0, $0, 17
add $3, $3, $3
lis $6
.word 0x0000063c ; REL'd
lw $8, -4($6)
lw $6, 0($6)
add $8, $8, $8
add $8, $8, $8
add $6, $6, $8
add $8, $3, $11
sw $8, 0($6)
sw $0, 4($6)
lis $6
.word 0x0000063c ; REL'd
lw $8, -4($6)
add $8, $8, $11
sw $8, -4($6)
beq $0, $0, -20
add $12, $3, $0
add $7, $0, $0
lis $8
.word 0x00000630 ; REL'd
lw $9, 4($8)
lw $8, 0($8)
sub $9, $9, $8
beq $3, $11, 8
div $3, $2
mflo $3
mfhi $10
beq $10, $0, 1
add $7, $7, $9
div $7, $2
mflo $7
beq $0, $0, -9
add $3, $8, $7
lis $4
.word 0x00000004
add $3, $3, $4
sw $12, -4($3)
lis $10
.word 0x0000002c
add $30, $30, $10
lw $1, -4($30)
lw $2, -8($30)
lw $4, -12($30)
lw $5, -16($30)
lw $6, -20($30)
lw $7, -24($30)
lw $8, -28($30)
lw $9, -32($30)
lw $10, -36($30)
lw $11, -40($30)
lw $12, -44($30)
jr $31
delete:
sw $1, -4($30)
sw $2, -8($30)
sw $3, -12($30)
sw $4, -16($30)
sw $5, -20($30)
sw $6, -24($30)
sw $11, -28($30)
sw $12, -32($30)
sw $14, -36($30)
lis $6
.word 0x00000024
sub $30, $30, $6
lis $11
.word 0x00000001
lis $12
.word 0x00000002
lis $14
.word 0x00000004
lw $2, -4($1)
beq $2, $11, 19
add $3, $2, $0
div $3, $12
mfhi $4
beq $4, $0, 2
sub $3, $3, $11
beq $0, $0, 1
add $3, $3, $11
lis $5
.word 0x00000488 ; REL'd
sw $31, -4($30)
sub $30, $30, $14
add $1, $3, $0
jalr $5
add $30, $30, $14
lw $31, -4($30)
beq $3, $0, 3
div $2, $12
mflo $2
beq $0, $0, -20
lis $4
.word 0x0000063c ; REL'd
lw $5, -4($4)
lw $4, 0($4)
add $5, $5, $5
add $5, $5, $5
add $5, $4, $5
sw $2, 0($5)
sw $0, 4($5)
lis $4
.word 0x0000063c ; REL'd
lw $5, -4($4)
add $5, $5, $11
sw $5, -4($4)
lis $6
.word 0x00000024
add $30, $30, $6
lw $1, -4($30)
lw $2, -8($30)
lw $3, -12($30)
lw $4, -16($30)
lw $5, -20($30)
lw $6, -24($30)
lw $11, -28($30)
lw $12, -32($30)
lw $14, -36($30)
jr $31
sw $1, -4($30)
sw $2, -8($30)
sw $4, -12($30)
sw $5, -16($30)
sw $6, -20($30)
sw $7, -24($30)
sw $8, -28($30)
sw $9, -32($30)
sw $10, -36($30)
lis $1
.word 0x00000024
sub $30, $30, $1
lis $1
.word 0x0000063c ; REL'd
lw $2, -4($1)
lw $1, 0($1)
lis $4
.word 0x00000004
lis $9
.word 0x00000001
add $3, $0, $0
add $10, $0, $0
beq $2, $0, 21
add $5, $2, $0
lw $6, 0($1)
slt $8, $7, $6
bne $8, $0, 4
slt $8, $3, $6
beq $8, $0, 2
add $3, $6, $0
add $10, $1, $0
add $1, $1, $4
sub $5, $5, $9
bne $5, $0, -10
beq $3, $0, 9
lw $6, 4($10)
sw $6, 0($10)
add $10, $10, $4
bne $6, $0, -4
lis $2
.word 0x00000630 ; REL'd
lw $4, 8($2)
sub $4, $4, $9
sw $4, 8($2)
lis $1
.word 0x00000024
add $30, $30, $1
lw $1, -4($30)
lw $2, -8($30)
lw $4, -12($30)
lw $5, -16($30)
lw $6, -20($30)
lw $7, -24($30)
lw $8, -28($30)
lw $9, -32($30)
lw $10, -36($30)
jr $31
sw $1, -4($30)
sw $2, -8($30)
sw $4, -12($30)
sw $5, -16($30)
sw $6, -20($30)
sw $7, -24($30)
sw $8, -28($30)
sw $9, -32($30)
sw $11, -36($30)
sw $14, -40($30)
lis $9
.word 0x00000028
sub $30, $30, $9
lis $11
.word 0x00000001
lis $14
.word 0x00000004
lis $2
.word 0x0000063c ; REL'd
lw $4, -4($2)
lw $2, 0($2)
add $3, $0, $0
add $6, $0, $0
add $7, $0, $0
beq $4, $0, 19
lw $5, 0($2)
bne $5, $1, 2
add $6, $6, $2
beq $0, $0, 3
add $2, $2, $14
add $7, $7, $11
bne $7, $4, -8
beq $6, $0, 11
lw $8, 4($2)
sw $8, 0($2)
add $2, $2, $14
add $7, $7, $11
bne $7, $4, -5
add $3, $11, $0
lis $2
.word 0x0000063c ; REL'd
lw $5, -4($2)
sub $5, $5, $11
sw $5, -4($2)
lis $9
.word 0x00000028
add $30, $30, $9
lw $1, -4($30)
lw $2, -8($30)
lw $4, -12($30)
lw $5, -16($30)
lw $6, -20($30)
lw $7, -24($30)
lw $8, -28($30)
lw $9, -32($30)
lw $11, -36($30)
lw $14, -40($30)
jr $31
printFreeList:
sw $1, -4($30)
sw $2, -8($30)
sw $3, -12($30)
sw $4, -16($30)
sw $5, -20($30)
sw $6, -24($30)
sw $7, -28($30)
sw $8, -32($30)
lis $6
.word 0x00000020
sub $30, $30, $6
lis $3
.word 0x0000063c ; REL'd
lis $4
.word 0x00000004
lis $5
.word 0x00000000 ; ESR - print
lis $6
.word 0x00000001
lw $2, -4($3)
lw $3, 0($3)
beq $2, $0, 9
lw $1, 0($3)
sw $31, -4($30)
sub $30, $30, $4
jalr $5
add $30, $30, $4
lw $31, -4($30)
add $3, $3, $4
sub $2, $2, $6
bne $2, $0, -10
lis $6
.word 0xffff000c
lis $5
.word 0x0000000a
sw $5, 0($6)
lis $6
.word 0x00000020
add $30, $30, $6
lw $1, -4($30)
lw $2, -8($30)
lw $3, -12($30)
lw $4, -16($30)
lw $5, -20($30)
lw $6, -24($30)
lw $7, -28($30)
lw $8, -32($30)
jr $31
.word 0x00000000
.word 0x00000000
.word 0x00000000
.word 0x00000000
.word 0x01 ; REL
.word 0x000003d8
.word 0x01 ; REL
.word 0x000001f8
.word 0x01 ; REL
.word 0x00000444
.word 0x01 ; REL
.word 0x0000033c
.word 0x01 ; REL
.word 0x000001d0
.word 0x01 ; REL
.word 0x00000360
.word 0x01 ; REL
.word 0x00000528
.word 0x01 ; REL
.word 0x000005a0
.word 0x01 ; REL
.word 0x000004d0
.word 0x01 ; REL
.word 0x0000030c
.word 0x01 ; REL
.word 0x00000218
.word 0x01 ; REL
.word 0x0000003c
.word 0x01 ; REL
.word 0x00000184
.word 0x11 ; ESR - print
.word 0x000005b0
.word 5
.word 112 ; p
.word 114 ; r
.word 105 ; i
.word 110 ; n
.word 116 ; t
.word 0x05 ; ESD - new
.word 0x000000c4
.word 3
.word 110 ; n
.word 101 ; e
.word 119 ; w
.word 0x05 ; ESD - printFreeList
.word 0x00000570
.word 13
.word 112 ; p
.word 114 ; r
.word 105 ; i
.word 110 ; n
.word 116 ; t
.word 70 ; F
.word 114 ; r
.word 101 ; e
.word 101 ; e
.word 76 ; L
.word 105 ; i
.word 115 ; s
.word 116 ; t
.word 0x05 ; ESD - delete
.word 0x0000029c
.word 6
.word 100 ; d
.word 101 ; e
.word 108 ; l
.word 101 ; e
.word 116 ; t
.word 101 ; e
.word 0x05 ; ESD - init
.word 0x0000000c
.word 4
.word 105 ; i
.word 110 ; n
.word 105 ; i
.word 116 ; t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment