Files
vhdl/lib/CPUs/MIPS/sim/asm/testbench.s
T
jens cd2640e9c6 Initial revision
Committed on the Free edition of March Hare Software CVSNT Server.
Upgrade to CVS Suite for more features and support:
http://march-hare.com/cvsnt/


git-svn-id: http://moon:8086/svn/vhdl/trunk@986 cc03376c-175c-47c8-b038-4cd826a8556b
2013-07-24 18:13:16 +00:00

925 lines
12 KiB
ArmAsm

.file 1 "testbench.c"
.set nobopt
.text
.align 2
.globl fibonacci
.ent fibonacci
fibonacci:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
.mask 0x00000000,0
.fmask 0x00000000,0
li $8,2 # 0x2
slt $2,$8,$7
sw $4,0($6)
.set noreorder
.set nomacro
beq $2,$0,$L7
sw $5,4($6)
.set macro
.set reorder
addiu $6,$6,8
$L5:
lw $2,-8($6)
lw $3,-4($6)
addiu $8,$8,1
addu $2,$2,$3
slt $4,$8,$7
sw $2,0($6)
.set noreorder
.set nomacro
bne $4,$0,$L5
addiu $6,$6,4
.set macro
.set reorder
$L7:
.set noreorder
.set nomacro
j $31
move $2,$8
.set macro
.set reorder
.end fibonacci
.align 2
.globl StatusRegister_read
.ent StatusRegister_read
StatusRegister_read:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
.mask 0x00000000,0
.fmask 0x00000000,0
#APP
.set noreorder
mfc0 $2, $12
.set reorder
#NO_APP
j $31
.end StatusRegister_read
.align 2
.globl RevisionRegister_read
.ent RevisionRegister_read
RevisionRegister_read:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
.mask 0x00000000,0
.fmask 0x00000000,0
#APP
.set noreorder
mfc0 $2, $15
.set reorder
#NO_APP
j $31
.end RevisionRegister_read
.section .rodata.str1.4,"aMS",@progbits,1
.align 2
$LC0:
.ascii "invalid\000"
.align 2
$LC1:
.ascii "R2000\000"
.align 2
$LC2:
.ascii "R3000\000"
.align 2
$LC3:
.ascii "R6000\000"
.align 2
$LC4:
.ascii "R4000\000"
.align 2
$LC5:
.ascii "reserved\000"
.align 2
$LC6:
.ascii "R6000A\000"
.rdata
.align 2
$LC7:
.word $LC0
.word $LC1
.word $LC2
.word $LC3
.word $LC4
.word $LC5
.word $LC6
.section .rodata.str1.4
.align 2
$LC8:
.ascii "Status : \000"
.align 2
$LC9:
.ascii "\r\n\000"
.align 2
$LC10:
.ascii "CPU type: \000"
.align 2
$LC12:
.ascii "Unknown\000"
.align 2
$LC11:
.ascii " Rev.\000"
.text
.align 2
.globl PrintCPUinfo
.ent PrintCPUinfo
PrintCPUinfo:
.frame $sp,64,$31 # vars= 32, regs= 3/0, args= 16, gp= 0
.mask 0x80030000,-8
.fmask 0x00000000,0
lw $2,$LC7
addiu $sp,$sp,-64
lw $3,$LC7+4
sw $2,16($sp)
lw $2,$LC7+8
sw $3,20($sp)
sw $2,24($sp)
lw $3,$LC7+12
lw $2,$LC7+16
sw $3,28($sp)
sw $2,32($sp)
lw $3,$LC7+20
lw $2,$LC7+24
sw $3,36($sp)
sw $31,56($sp)
sw $17,52($sp)
sw $16,48($sp)
.set noreorder
.set nomacro
jal StatusRegister_read
sw $2,40($sp)
.set macro
.set reorder
la $4,$LC8
.set noreorder
.set nomacro
jal sputs
move $17,$2
.set macro
.set reorder
.set noreorder
.set nomacro
jal print_word
move $4,$17
.set macro
.set reorder
la $4,$LC9
jal sputs
jal RevisionRegister_read
sra $16,$2,8
andi $16,$16,0xff
la $4,$LC10
.set noreorder
.set nomacro
jal sputs
move $17,$2
.set macro
.set reorder
sll $3,$16,2
addiu $16,$16,-1
sltu $16,$16,6
la $4,$LC12
.set noreorder
.set nomacro
beq $16,$0,$L12
addu $2,$sp,$3
.set macro
.set reorder
lw $4,16($2)
jal sputs
la $4,$LC11
jal sputs
sll $4,$17,24
.set noreorder
.set nomacro
jal print_byte
sra $4,$4,24
.set macro
.set reorder
la $4,$LC9
jal sputs
lw $31,56($sp)
lw $17,52($sp)
lw $16,48($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,64
.set macro
.set reorder
$L12:
jal sputs
la $4,$LC9
jal sputs
lw $31,56($sp)
lw $17,52($sp)
lw $16,48($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,64
.set macro
.set reorder
.end PrintCPUinfo
.align 2
.globl Test10_LoadStore
.ent Test10_LoadStore
Test10_LoadStore:
.frame $sp,24,$31 # vars= 0, regs= 2/0, args= 16, gp= 0
.mask 0x80010000,-4
.fmask 0x00000000,0
addiu $sp,$sp,-24
li $4,128 # 0x80
sw $31,20($sp)
.set noreorder
.set nomacro
jal malloc
sw $16,16($sp)
.set macro
.set reorder
move $4,$2
li $2,1431633920 # 0x55550000
li $3,-1431699456 # 0xffffffffaaaa0000
ori $5,$2,0x5555
ori $6,$3,0xaaaa
li $7,-1 # 0xffffffffffffffff
sw $0,0($4)
sw $5,4($4)
sw $6,8($4)
sw $7,12($4)
lw $3,0($4)
li $2,-2147483648 # 0xffffffff80000000
.set noreorder
.set nomacro
bne $3,$0,$L16
ori $16,$2,0x10
.set macro
.set reorder
lw $2,4($4)
beq $2,$5,$L73
$L16:
jal free
move $2,$16
lw $31,20($sp)
lw $16,16($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,24
.set macro
.set reorder
$L73:
lw $2,8($4)
bne $2,$6,$L16
lw $2,12($4)
.set noreorder
.set nomacro
bne $2,$7,$L16
move $3,$4
.set macro
.set reorder
move $5,$0
li $7,-2147483648 # 0xffffffff80000000
li $6,31 # 0x1f
$L24:
sra $2,$5,1
addiu $6,$6,-1
sw $5,0($3)
addiu $3,$3,4
.set noreorder
.set nomacro
bgez $6,$L24
or $5,$2,$7
.set macro
.set reorder
move $3,$4
move $5,$0
move $6,$0
.set noreorder
.set nomacro
j $L29
li $8,-2147483648 # 0xffffffff80000000
.set macro
.set reorder
$L74:
addiu $6,$6,1
slt $2,$6,32
.set noreorder
.set nomacro
beq $2,$0,$L26
or $5,$7,$8
.set macro
.set reorder
$L29:
lw $2,0($3)
sra $7,$5,1
.set noreorder
.set nomacro
beq $2,$5,$L74
addiu $3,$3,4
.set macro
.set reorder
$L26:
li $2,32 # 0x20
.set noreorder
.set nomacro
bne $6,$2,$L16
move $3,$4
.set macro
.set reorder
move $5,$0
li $6,31 # 0x1f
$L34:
sll $2,$5,1
addiu $6,$6,-1
sw $5,0($3)
addiu $3,$3,4
.set noreorder
.set nomacro
bgez $6,$L34
ori $5,$2,0x1
.set macro
.set reorder
move $3,$4
move $5,$0
.set noreorder
.set nomacro
j $L39
move $6,$0
.set macro
.set reorder
$L75:
addiu $6,$6,1
slt $2,$6,32
.set noreorder
.set nomacro
beq $2,$0,$L36
ori $5,$7,0x1
.set macro
.set reorder
$L39:
lw $2,0($3)
sll $7,$5,1
.set noreorder
.set nomacro
beq $2,$5,$L75
addiu $3,$3,4
.set macro
.set reorder
$L36:
li $2,32 # 0x20
.set noreorder
.set nomacro
bne $6,$2,$L16
move $3,$4
.set macro
.set reorder
li $5,1 # 0x1
li $6,31 # 0x1f
$L44:
addiu $6,$6,-1
sw $5,0($3)
addiu $3,$3,4
.set noreorder
.set nomacro
bgez $6,$L44
sll $5,$5,1
.set macro
.set reorder
move $3,$4
li $5,1 # 0x1
.set noreorder
.set nomacro
j $L49
move $6,$0
.set macro
.set reorder
$L76:
addiu $6,$6,1
slt $2,$6,32
.set noreorder
.set nomacro
beq $2,$0,$L46
sll $5,$5,1
.set macro
.set reorder
$L49:
lw $2,0($3)
.set noreorder
.set nomacro
beq $2,$5,$L76
addiu $3,$3,4
.set macro
.set reorder
$L46:
li $2,32 # 0x20
.set noreorder
.set nomacro
bne $6,$2,$L16
move $3,$4
.set macro
.set reorder
li $5,-2 # 0xfffffffffffffffe
li $6,31 # 0x1f
$L54:
sll $2,$5,1
addiu $6,$6,-1
sw $5,0($3)
addiu $3,$3,4
.set noreorder
.set nomacro
bgez $6,$L54
ori $5,$2,0x1
.set macro
.set reorder
move $3,$4
li $5,-2 # 0xfffffffffffffffe
.set noreorder
.set nomacro
j $L59
move $6,$0
.set macro
.set reorder
$L77:
addiu $6,$6,1
slt $2,$6,32
.set noreorder
.set nomacro
beq $2,$0,$L56
ori $5,$7,0x1
.set macro
.set reorder
$L59:
lw $2,0($3)
sll $7,$5,1
.set noreorder
.set nomacro
beq $2,$5,$L77
addiu $3,$3,4
.set macro
.set reorder
$L56:
li $2,32 # 0x20
bne $6,$2,$L16
.set noreorder
.set nomacro
j $L16
move $16,$0
.set macro
.set reorder
.end Test10_LoadStore
.align 2
.globl Test11_AddSub
.ent Test11_AddSub
Test11_AddSub:
.frame $sp,120,$31 # vars= 80, regs= 5/0, args= 16, gp= 0
.mask 0x800f0000,-8
.fmask 0x00000000,0
addiu $sp,$sp,-120
li $2,-1431699456 # 0xffffffffaaaa0000
sw $19,108($sp)
sw $18,104($sp)
sw $16,96($sp)
sw $31,112($sp)
sw $17,100($sp)
ori $16,$2,0xaaaa
move $19,$0
move $4,$0
addiu $18,$sp,16
$L92:
move $2,$18
li $6,19 # 0x13
$L85:
addiu $6,$6,-1
sw $16,0($2)
.set noreorder
.set nomacro
bgez $6,$L85
addiu $2,$2,4
.set macro
.set reorder
xor $2,$16,$4
addiu $17,$4,1
addiu $2,$2,-1
move $5,$17
addiu $6,$sp,16
li $7,20 # 0x14
.set noreorder
.set nomacro
jal fibonacci
sll $16,$2,1
.set macro
.set reorder
li $7,2 # 0x2
addiu $5,$18,8
.set noreorder
.set nomacro
j $L90
li $6,17 # 0x11
.set macro
.set reorder
$L88:
bltz $6,$L100
$L90:
lw $2,0($5)
lw $3,-4($5)
lw $4,-8($5)
subu $2,$2,$3
addiu $6,$6,-1
.set noreorder
.set nomacro
bne $4,$2,$L88
addiu $5,$5,4
.set macro
.set reorder
.set noreorder
.set nomacro
bgez $6,$L90
addiu $7,$7,1
.set macro
.set reorder
$L100:
li $6,20 # 0x14
beq $7,$6,$L101
$L81:
slt $2,$17,3
.set noreorder
.set nomacro
bne $2,$0,$L92
move $4,$17
.set macro
.set reorder
li $2,3 # 0x3
.set noreorder
.set nomacro
bne $19,$2,$L102
move $3,$0
.set macro
.set reorder
lw $31,112($sp)
lw $19,108($sp)
lw $18,104($sp)
lw $17,100($sp)
lw $16,96($sp)
move $2,$3
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,120
.set macro
.set reorder
$L101:
.set noreorder
.set nomacro
j $L81
addiu $19,$19,1
.set macro
.set reorder
$L102:
li $2,-2147483648 # 0xffffffff80000000
ori $3,$2,0x11
lw $31,112($sp)
lw $19,108($sp)
lw $18,104($sp)
lw $17,100($sp)
lw $16,96($sp)
move $2,$3
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,120
.set macro
.set reorder
.end Test11_AddSub
.align 2
.globl Test12_MulDiv
.ent Test12_MulDiv
Test12_MulDiv:
.frame $sp,48,$31 # vars= 8, regs= 5/0, args= 16, gp= 0
.mask 0x800f0000,-8
.fmask 0x00000000,0
li $4,426770432 # 0x19700000
addiu $sp,$sp,-48
ori $4,$4,0x1031
sw $19,36($sp)
sw $31,40($sp)
sw $18,32($sp)
sw $17,28($sp)
sw $16,24($sp)
.set noreorder
.set nomacro
jal srand
move $19,$0
.set macro
.set reorder
.set noreorder
.set nomacro
j $L111
li $18,1 # 0x1
.set macro
.set reorder
$L109:
beq $4,$0,$L117
$L111:
.set noreorder
.set nomacro
jal rand
addiu $18,$18,1
.set macro
.set reorder
sll $3,$2,16
sll $2,$2,8
.set noreorder
.set nomacro
jal rand
xor $16,$2,$3
.set macro
.set reorder
.set noreorder
.set nomacro
jal rand
xor $17,$2,$16
.set macro
.set reorder
sll $3,$2,16
sll $2,$2,8
.set noreorder
.set nomacro
jal rand
xor $16,$2,$3
.set macro
.set reorder
xor $16,$2,$16
addiu $4,$sp,16
move $5,$17
.set noreorder
.set nomacro
jal div
move $6,$16
.set macro
.set reorder
lw $3,16($sp)
lw $2,20($sp)
mult $3,$16
mflo $3
addu $2,$2,$3
.set noreorder
.set nomacro
beq $2,$17,$L109
slt $4,$18,1000
.set macro
.set reorder
li $2,-2147483648 # 0xffffffff80000000
ori $2,$2,0x12
$L103:
lw $31,40($sp)
lw $19,36($sp)
lw $18,32($sp)
lw $17,28($sp)
lw $16,24($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,48
.set macro
.set reorder
$L117:
addiu $19,$19,1
slt $2,$19,100
.set noreorder
.set nomacro
bne $2,$0,$L111
li $18,1 # 0x1
.set macro
.set reorder
.set noreorder
.set nomacro
j $L103
move $2,$0
.set macro
.set reorder
.end Test12_MulDiv
.section .rodata.str1.4
.align 2
$LC13:
.ascii "Iteration %d: Passed\r\n\000"
.align 2
$LC14:
.ascii "Iteration \000"
.align 2
$LC15:
.ascii ": Passed\r\n\000"
.align 2
$LC16:
.ascii ":\000"
.align 2
$LC17:
.ascii "Failed with error \000"
.align 2
$LC18:
.ascii " \r\n\000"
.text
.align 2
.globl main
.ent main
main:
.frame $sp,48,$31 # vars= 8, regs= 5/0, args= 16, gp= 0
.mask 0x800f0000,-8
.fmask 0x00000000,0
li $3,-2147483648 # 0xffffffff80000000
li $2,13
ori $3,$3,0x9
addiu $sp,$sp,-48
sb $2,0($3)
sw $19,36($sp)
sw $18,32($sp)
sw $17,28($sp)
sw $31,40($sp)
.set noreorder
.set nomacro
jal PrintCPUinfo
sw $16,24($sp)
.set macro
.set reorder
li $2,1073676288 # 0x3fff0000
ori $19,$2,0xffff
li $18,-2147483648 # 0xffffffff80000000
.set noreorder
.set nomacro
j $L119
move $17,$0
.set macro
.set reorder
$L124:
jal Test11_AddSub
.set noreorder
.set nomacro
bltz $2,$L120
move $16,$2
.set macro
.set reorder
jal Test12_MulDiv
move $16,$2
la $4,$LC13
.set noreorder
.set nomacro
bltz $2,$L120
move $5,$17
.set macro
.set reorder
.set noreorder
.set nomacro
jal printf
addiu $17,$17,1
.set macro
.set reorder
la $4,$LC14
jal sputs
.set noreorder
.set nomacro
jal print_word
move $4,$17
.set macro
.set reorder
la $4,$LC15
.set noreorder
.set nomacro
jal sputs
addiu $17,$17,1
.set macro
.set reorder
.set noreorder
.set nomacro
jal time
move $4,$0
.set macro
.set reorder
addiu $4,$sp,16
.set noreorder
.set nomacro
jal gmtime
sw $2,16($sp)
.set macro
.set reorder
lb $4,8($2)
.set noreorder
.set nomacro
jal print_byte
move $16,$2
.set macro
.set reorder
la $4,$LC16
jal sputs
lb $4,4($16)
jal print_byte
la $4,$LC16
jal sputs
lb $4,0($16)
jal print_byte
la $4,$LC9
jal sputs
$L119:
and $2,$17,$19
sw $2,0($18)
jal Test10_LoadStore
.set noreorder
.set nomacro
bgez $2,$L124
move $16,$2
.set macro
.set reorder
$L120:
li $2,1073741824 # 0x40000000
or $2,$17,$2
la $4,$LC17
sw $2,0($18)
jal sputs
.set noreorder
.set nomacro
jal print_word
move $4,$16
.set macro
.set reorder
la $4,$LC18
jal sputs
lw $31,40($sp)
lw $19,36($sp)
lw $18,32($sp)
lw $17,28($sp)
lw $16,24($sp)
li $2,1 # 0x1
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,48
.set macro
.set reorder
.end main