Question

2. Write a MIPS program that translates the following C code int a 1234; b 5678 int sum void main () atb sum = cout <<sum; }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.globl a

.data

.align 2

.type a, @object

.size a, 4

a:

.word 1234

.globl b

.align 2

.type b, @object

.size b, 4

b:

.word 5678

.comm sum,4,4

.rdata

.align 2

$LC0:

.ascii "%d\000"

.text

.align 2

.globl main

.ent main

.type main, @function

main:

.frame $fp,32,$31 # vars= 0, regs= 2/0, args= 16, gp= 8

.mask 0xc0000000,-4

.fmask 0x00000000,0

.set noreorder

.cpload $25

.set nomacro

addiu $sp,$sp,-32

sw $31,28($sp)

sw $fp,24($sp)

move $fp,$sp

.cprestore 16

movz $31,$31,$0

lw $2,%got(a)($28)

nop

lw $3,0($2)

lw $2,%got(b)($28)

nop

lw $2,0($2)

nop

addu $3,$3,$2

lw $2,%got(sum)($28)

nop

sw $3,0($2)

lw $2,%got(sum)($28)

nop

lw $2,0($2)

nop

move $5,$2

lw $2,%got($LC0)($28)

nop

addiu $4,$2,%lo($LC0)

lw $2,%call16(printf)($28)

nop

move $25,$2

.reloc 1f,R_MIPS_JALR,printf

1: jalr $25

nop

lw $28,16($fp)

move $2,$0

move $sp,$fp

lw $31,28($sp)

lw $fp,24($sp)

addiu $sp,$sp,32

j $31

nop

Add a comment
Know the answer?
Add Answer to:
2. Write a MIPS program that translates the following C code int a 1234; b 5678 int sum void main () atb sum = cout &lt...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT