In: Computer Science
Transfer in MIPS
char * strtoupper(char s[]) {
char c;
c = s[0];
/* empty string */
if (c == 0)
return s;
/* convert the first character to upper case*/
if (c >= ‘a’ && d <= ‘z’) { c -= 32;
s[0] = c; }
/* convert the remaining characters*/
strtoupper(s + 1);
return s; }
strtoupper:
.frame $fp,40,$31 # vars= 8, regs= 2/0, args= 16, gp= 8
.mask 0xc0000000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-40
sw $31,36($sp)
sw $fp,32($sp)
move $fp,$sp
.cprestore 16
movz $31,$31,$0
sw $4,40($fp)
lw $2,40($fp)
nop
lbu $2,0($2)
nop
sb $2,24($fp)
lb $2,24($fp)
nop
bne $2,$0,$L2
nop
lw $2,40($fp)
b $L3
nop
$L2:
lb $2,24($fp)
nop
slt $2,$2,97
bne $2,$0,$L4
nop
lb $2,24($fp)
nop
slt $2,$2,123
beq $2,$0,$L4
nop
lbu $2,24($fp)
nop
addiu $2,$2,-32
andi $2,$2,0x00ff
sb $2,24($fp)
lw $2,40($fp)
lbu $3,24($fp)
nop
sb $3,0($2)
$L4:
lw $2,40($fp)
nop
addiu $2,$2,1
move $4,$2
lw $2,%got(strtoupper)($28)
nop
move $25,$2
.reloc 1f,R_MIPS_JALR,strtoupper
1: jalr $25
nop
lw $28,16($fp)
lw $2,40($fp)
$L3:
move $sp,$fp
lw $31,36($sp)
lw $fp,32($sp)
addiu $sp,$sp,40
j $31
nop