SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 4 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Dec 2017 My Price 10.00

MIPS program (which must be named as hw4_prob2.s)

I need some help to finish a code to answer the following problem. My code is not printing the histogram. I tried to convert the C/C++ function to a mips code but is not working.

Problem

Write a MIPS program (which must be named as hw4_prob2.s) that will 1) read in an image name (gray level image in binary format), the number of rows and the number of columns, 2) read in the image (must be implemented using a function), 3) compute its histogram (must be implemented using a function), and 4) then output the histogram (must be implemented using a function). You can assume the image size is no larger than 500x500. Then you need to test program using three different cases Additional information: The histogram of an image is widely used to characterize the image in content-based retrieval and other applications. It counts the number of occurrences of all the pixel values (0 – 255 in this case). Attached is a C/C++ function that computes the histogram of the input image, that needs to be converted to mips

 

My code

.data
str: .asciiz "Enter a base (between 2 and 36 in decimal): "
str1: .asciiz "Enter a number in base "
str2: .asciiz "The value in decimal is:"
str3: .asciiz ":"
str4: .asciiz "Error, wrong value"
num: .space 25
newl: .asciiz "n"
.text
main:
    li $v0, 4       # $system call code for print_str
    la $a0, str     # $address of string to print
    syscall         # print the string

    li $v0, 5       # $system call code for read_int
    syscall         # read the int 
    move $s0, $v0   #store value
	li $t1, 37
	slt $t0, $s0, $t1 #checks less than 37
	beq $t0,1, IF
	li $v0, 4
	la $a0, str4
	syscall
	j main

IF:   
        li $t2, 1
	slt $t3, $t2, $s0 #checks greater than 1
	beq $t0,1, STR
	li $v0, 4
	la $a0, str4
	syscall
	j main
   
STR:	
 	li $v0,4
	la $a0,str1
	syscall
	move $a0,$s0
	li $v0, 1
	syscall
	li $v0, 4
	la $a0, str3
	syscall
	li $v0, 8 #syscall to read a string
	la $a0, num #store in num
	li $a1, 25
	syscall
	move $a0, $s0
	la $a1, num
	jal CONV
	move $s1, $v0
	li $v0, 4
	la $a0, newl #newline
	syscall
	li $v0, 4
	la $a0,str2
	syscall
	li $v0,1
	move $a0, $s1
	syscall
	li $v0, 10
	syscall
	
CONV: #convertion function
 li $v0,1
 
 syscall
move $s0, $zero
move $v0, $zero
move $t1, $a0
move $t1, $a1
    loop: 
    lb $t2, 0($t1)
    beq $t2, $zero, exit
    addi $t5, $zero, 10
    beq $t2, $t5, exit
    addi $t3, $t3, 58
    slt $t4, $t2, $t3
    beq $t4, $zero, if2
 mul $v1, $v0, $t0
 add $v0, $v1, $t2
 addi $v0, $v0, -48
 j loop2
 	if2:
 	mul $v1, $v0, $t0
 	add $v0, $v1, $t2
 	addi $v0, $v0, -87
 	loop2: 
 	addi $t1, $t1, 1
 	addi $s0, $s0, 1
 	j loop
 	loop3:
 	beq $a1, $zero, exit
 	add $v1, $a0, $zero
 	addi $a1, $a1, -1
 	j loop3
exit:

Attachments:

Answers

(5)
Status NEW Posted 12 Dec 2017 10:12 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)