Hello,
i have to build a program using assembly with mars system.
the progra...
Computers and Technology, 30.10.2019 01:31 cxttiemsp021
Hello,
i have to build a program using assembly with mars system.
the program is supposed to return a hailstone sequence
a)- get user input (integer) - n
b) check if even or odd
- if the input is even, the next number should n/2
- if the user's input (n*3)+1
c) reproduce the operation on the next number until the number is equal to 1
d) display the sequence
e) count and display the number of iterartion
i have the user input done, and then, i tried to do a bitwise operation using and to see if the number is even or not but the program doesn't work after the user's input, as i have an output equal to zero
can you me ?
here is my code so far
.data
prompt: .asciiz "enter an integer: "
message1: .asciiz "you entered an even number"
message2: .asciiz "you entered an odd number"
message3: .asciiz "and the next numbers should be: "
gototheline: .asciiz "\n"
message4: .asciiz "you just entered the number: "
.text
main:
#print the prompt
li $v0,4
la $a0,prompt
syscall
#get the user's input
li $v0,5
syscall
#store the input'svalue
move $t3, $v0
#display the user's input message
li $v0,4
la $a0,message4
syscall
#go to the line
li $v0,4
la $a0,gototheline
syscall
#print value entered by user
li $v0,1
move $a0, $t3
syscall
#go to the line
li $v0,4
la $a0,gototheline
syscall
#bitwise operation on the input
and $a0,$0,1
#call odd function if number is odd
beq $a0,1,ifodd
#print next number message
li $v0, 4
la,$a0,message3
syscall
#go to the line
li $v0,4
la $a0,gototheline
syscall
#print result
li $v0,1
addi $a0,$v1,0
syscall
li $v0,10
syscall
ifeven:
#print message if even
la $a1,message1
syscall
#call the function operation even to do math on the number entered by user
jal operationeven
ifodd:
#print message if odd
la $a2,message2
syscall
#call method to do math on the number entered by user
jal operationodd
operationeven:
#if even n/2
div $v1,$t3,2 # return value on $v1
jr $ra #go back to the main
operationodd:
#multiply by 3
mul $t1,$t3,3
#add 1 to the result of the multiplication
add $v1, $t1,1 #return value on $v1
jr $ra #go back to the main
Answers: 1
Computers and Technology, 22.06.2019 04:30
Which of the statements below is true? the formatting, standard, and drawing commands are unavailable. the formatting, standard, and drawing commands have been used. the formatting, standard, and drawing toolbars are displayed. the formatting, standard, and drawing toolbars are hidden.
Answers: 1
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
Computers and Technology, 22.06.2019 20:30
In this lab, you complete a prewritten c program that calculates an employee’s productivity bonus and prints the employee’s name and bonus. bonuses are calculated based on an employee’s productivity score as shown below. a productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked.
Answers: 3
Computers and Technology, 22.06.2019 21:00
Write a method so that the main() code below can be replaced by the simpler code that calls method original main(): public class calcmiles { public static void main(string [] args) { double milesperhour; double minutestraveled; double hourstraveled; double milestraveled; milesprhour = scnr.nextdouble(); minutestraveled = scnr.nextdouble(); hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; system.out.println("miles: " + milestraveled); } }
Answers: 2
Mathematics, 11.02.2020 02:56
English, 11.02.2020 02:56
Medicine, 11.02.2020 02:56
Mathematics, 11.02.2020 02:56
Mathematics, 11.02.2020 02:56
English, 11.02.2020 02:56
History, 11.02.2020 02:56
Mathematics, 11.02.2020 02:56
Computers and Technology, 11.02.2020 02:56