For the following program, translate all the branch statements (b, beqz, bnez, etc) to machine code, making sure you have correctly calculated the relative branch values. .text .global main main: la $a0, prompt jal PromptInt move $s0, $v0 BeginLoop: seq $t0, $s0, -1 bnez $t0, EndLoop la $a0, result move $a1, $s0 jal PrintInt slti $t0, $s0, 100 beqz $t0, BigNumber la $a0, little jal PrintString b EndIf BigNumber: la $a0, big jal PrintString EndIf: la $a0, tryAgain jal PrintString la $a0 prompt jal PromptInt move $s0, $v0 b BeginLoop EndLoop: jal Exit .data prompt: .asciiz "\nEneter a number (-1 to end)" result: .asciiz "\nYou entered " big: .asciiz "\nThat is a big number" little: .asciiz "\nThat is a little number" tryAgain: .asciiz "\nTry again" .include "utils.asm
For the following
code, making sure you have correctly calculated the relative branch values.
.text
.global main
main:
la $a0, prompt
jal PromptInt
move $s0, $v0
BeginLoop:
seq $t0, $s0, -1
bnez $t0, EndLoop
la $a0, result
move $a1, $s0
jal PrintInt
slti $t0, $s0, 100
beqz $t0, BigNumber
la $a0, little
jal PrintString
b EndIf
BigNumber:
la $a0, big
jal PrintString
EndIf:
la $a0, tryAgain
jal PrintString
la $a0 prompt
jal PromptInt
move $s0, $v0
b BeginLoop
EndLoop:
jal Exit
.data
prompt: .asciiz "\nEneter a number (-1 to end)"
result: .asciiz "\nYou entered "
big: .asciiz "\nThat is a big number"
little: .asciiz "\nThat is a little number"
tryAgain: .asciiz "\nTry again"
.include "utils.asm
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)