Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why my code does not compile, it says the label is defined for the second time on line 17 of the file for main: (Please

Why my code does not compile, it says the label is defined for the second time on line 17 of the file for main: (Please speicfy what you modified)

.data

x: .word 1

y: .word 1

z: .word -1

A: .word 10

B: .word 2

str1: .asciiz "z = "

nl: .asciiz " "

.globl main

.text

main:

# Initialization

la $t0, x #t0 = address of x

lw $s3, 0($t0) #s3 <-- x

la $t0, y #t0 = address of y

lw $s4, 0($t0) #s4 <-- y

la $t0, z #t0 = address of z

lw $s2, 0($t0) #s2 <-- z

la $t0, A #t0 = address of A

lw $s0, 0($t0) #s0 <-- A

la $t0, B #t0 = address of B

lw $s1, 0($t0)

START:

bne $s3,$s4, ELSE # if s3 != S4 go to ELSE

li $s2,0 # if s3 == S4 then S2 = 0

j EXIT # jump to EXIT

ELSE:

blt $s3,$s4,ELSE2 # if x < y go to label 1

mult $s2,$s1,4 # get 4 * B

add $s2,$s2,$s0 # z = A + 4*B

j EXIT # jump to EXIT

ELSE2:

mult $s2,$s1,4 # get 4 * B

sub $s2,$s0,$s6 # Z = A - 4*B

j EXIT

EXIT:

li $v0, 4 # system call print_str

la $a0, str1 # "z = "

syscall

li $v0, 1 # system call print_int

add $a0, $zero, $s2 # z

syscall

li $v0, 4 # system call print_str

la $a0, nl # newline

syscall

jr $ra

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions