# Look ay my pseudocode for main routine has been written for y
#
#
############################################################################
# Ones counter
# The user will type in an integer.
# the program will pass the integer to a function that will count the
# number of binary bits that are "1".
#
##############################################################################
# Function CountBits(int)
#
# counts the one bits in an integer.
# for example, it the input is "15" the output is "4"
#
# Arguments:
# a0 input integer
#
# Returns
# v0 the bit count of 1 bits
# Other Register usage:
# t0-t7 as required
# S0-S7 as required
##############################################################################
CountBits: (Note: should I just translate this C++ code to MIPS code to
help run my program?
# int count bits(int a0)
{
vo=0;
while (a0){
v0+= a0&1
a0 >> =1,
}
return 0;
}
(Note: do not modify below this line
.data
prompt: .asciiz "\nType in an integer: "
ans: .asciiz "The number of one bits is: "
.text
.globl main
main: la $a0,prompt #do{
li $v0,4 #
syscall # cout<< prompt
li $v0,5 #
syscall # cin >> N;
move $a0,$v0
jal CountBits #
move $s0,$v0 # s0= CountBits(N)
la $a0,ans
li $v0,4
syscall # cout << ans << s0;
move $a0,$s0
li $v0,1
syscall # cout <<bye
b main # }while (true)