Files
mips/src/asm/muldiv.s
T
jens 5d894028fb - added
git-svn-id: http://moon:8086/svn/mips@130 a8ebac50-d88d-4704-bea3-6648445a41b3
2017-01-24 17:09:47 +00:00

392 lines
5.4 KiB
ArmAsm

.file 1 "muldiv.c"
.set nobopt
.text
.align 2
.globl sein
.ent sein
sein:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
.mask 0x00000000,0
.fmask 0x00000000,0
li $2,-2147483648 # 0xffffffff80000000
ori $4,$2,0x4
ori $3,$2,0x8
$L2:
lbu $2,0($3)
andi $2,$2,0x10
beq $2,$0,$L2
lbu $2,0($4)
sll $2,$2,24
.set noreorder
.set nomacro
j $31
sra $2,$2,24
.set macro
.set reorder
.end sein
.align 2
.globl saus
.ent saus
saus:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
.mask 0x00000000,0
.fmask 0x00000000,0
li $2,-2147483648 # 0xffffffff80000000
sll $4,$4,24
sra $4,$4,24
ori $5,$2,0x4
ori $3,$2,0x8
$L6:
lbu $2,0($3)
andi $2,$2,0x2
bne $2,$0,$L6
sb $4,0($5)
j $31
.end saus
.align 2
.globl sputs
.ent sputs
sputs:
.frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
.mask 0x80030000,-8
.fmask 0x00000000,0
addiu $sp,$sp,-32
sw $17,20($sp)
sw $16,16($sp)
sw $31,24($sp)
move $16,$4
lb $4,0($4)
.set noreorder
.set nomacro
j $L14
move $17,$16
.set macro
.set reorder
$L15:
.set noreorder
.set nomacro
jal saus
addiu $16,$16,1
.set macro
.set reorder
lb $4,0($16)
$L14:
.set noreorder
.set nomacro
bne $4,$0,$L15
subu $2,$16,$17
.set macro
.set reorder
lw $31,24($sp)
lw $17,20($sp)
lw $16,16($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,32
.set macro
.set reorder
.end sputs
.align 2
.globl print_byte
.ent print_byte
print_byte:
.frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
.mask 0x80030000,-8
.fmask 0x00000000,0
addiu $sp,$sp,-32
sw $16,16($sp)
sll $16,$4,24
sw $17,20($sp)
sw $31,24($sp)
sra $16,$16,24
li $17,1 # 0x1
sra $2,$16,4
$L25:
andi $5,$2,0xf
sll $2,$16,4
sll $16,$2,24
sltu $3,$5,10
addiu $17,$17,-1
sra $16,$16,24
.set noreorder
.set nomacro
bne $3,$0,$L21
addiu $4,$5,48
.set macro
.set reorder
addiu $4,$5,55
$L21:
jal saus
.set noreorder
.set nomacro
bgez $17,$L25
sra $2,$16,4
.set macro
.set reorder
lw $31,24($sp)
lw $17,20($sp)
lw $16,16($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,32
.set macro
.set reorder
.end print_byte
.align 2
.globl print_word
.ent print_word
print_word:
.frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
.mask 0x80030000,-8
.fmask 0x00000000,0
addiu $sp,$sp,-32
sw $17,20($sp)
sw $16,16($sp)
sw $31,24($sp)
move $16,$4
li $17,3 # 0x3
$L30:
sra $4,$16,24
.set noreorder
.set nomacro
jal print_byte
addiu $17,$17,-1
.set macro
.set reorder
.set noreorder
.set nomacro
bgez $17,$L30
sll $16,$16,8
.set macro
.set reorder
lw $31,24($sp)
lw $17,20($sp)
lw $16,16($sp)
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,32
.set macro
.set reorder
.end print_word
.section .rodata.str1.4,"aMS",@progbits,1
.align 2
$LC0:
.ascii "MIPS R3000 CPU\r\n"
.ascii "Mul/Div Test\r\n\000"
.align 2
$LC1:
.ascii "Failed: \000"
.align 2
$LC2:
.ascii "d*quot = \000"
.align 2
$LC3:
.ascii "\r\n\000"
.align 2
$LC4:
.ascii "Iteration \000"
.align 2
$LC5:
.ascii ": Passed\r\n\000"
.text
.align 2
.globl main
.ent main
main:
.frame $sp,88,$31 # vars= 40, regs= 7/0, args= 16, gp= 0
.mask 0x803f0000,-8
.fmask 0x00000000,0
lw $2,$LC0
addiu $sp,$sp,-88
sw $2,16($sp)
lw $3,$LC0+4
lw $2,$LC0+8
sw $3,20($sp)
sw $2,24($sp)
lw $3,$LC0+12
lw $2,$LC0+16
sw $3,28($sp)
sw $2,32($sp)
lw $3,$LC0+20
lw $2,$LC0+24
sw $3,36($sp)
sw $2,40($sp)
lhu $3,$LC0+28
lbu $2,$LC0+30
li $5,-2147483648 # 0xffffffff80000000
ori $6,$5,0x9
sh $3,44($sp)
sb $2,46($sp)
ori $5,$5,0x8
li $3,53
li $2,85
li $4,426770432 # 0x19700000
sb $3,0($6)
ori $4,$4,0x1031
sb $2,0($5)
sw $31,80($sp)
sw $21,76($sp)
sw $19,68($sp)
sw $20,72($sp)
sw $18,64($sp)
sw $17,60($sp)
.set noreorder
.set nomacro
jal srand
sw $16,56($sp)
.set macro
.set reorder
.set noreorder
.set nomacro
jal sputs
addiu $4,$sp,16
.set macro
.set reorder
move $21,$0
addiu $19,$sp,48
move $20,$0
$L44:
.set noreorder
.set nomacro
j $L43
li $18,1 # 0x1
.set macro
.set reorder
$L51:
beq $3,$0,$L50
$L43:
.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
move $6,$16
move $4,$19
.set noreorder
.set nomacro
jal div
move $5,$17
.set macro
.set reorder
lw $2,48($sp)
mult $2,$16
lw $2,52($sp)
mflo $16
addu $2,$2,$16
.set noreorder
.set nomacro
beq $2,$17,$L51
slt $3,$18,1000
.set macro
.set reorder
la $4,$LC1
jal sputs
la $4,$LC2
jal sputs
.set noreorder
.set nomacro
jal print_word
move $4,$16
.set macro
.set reorder
la $4,$LC3
jal sputs
lw $31,80($sp)
lw $21,76($sp)
lw $20,72($sp)
lw $19,68($sp)
lw $18,64($sp)
lw $17,60($sp)
lw $16,56($sp)
li $2,-1 # 0xffffffffffffffff
.set noreorder
.set nomacro
j $31
addiu $sp,$sp,88
.set macro
.set reorder
$L50:
addiu $20,$20,1
slt $2,$20,1000
bne $2,$0,$L44
la $4,$LC4
.set noreorder
.set nomacro
jal sputs
move $20,$0
.set macro
.set reorder
.set noreorder
.set nomacro
jal print_word
move $4,$21
.set macro
.set reorder
la $4,$LC5
.set noreorder
.set nomacro
jal sputs
addiu $21,$21,1
.set macro
.set reorder
.set noreorder
.set nomacro
j $L43
li $18,1 # 0x1
.set macro
.set reorder
.end main