conversion from single cycle to multicycle

Thread Starter

GipsyDanger

Joined Dec 12, 2013
3
hello again
i wanna ask how to convert a single cycle MIPS code to multicycle
i dont have any idea to do this

for example, MIPS code

Rich (BB code):
.data 0x10010000 
prompt1:  	.asciiz "Insert an integer: " 
prompt2:  	.asciiz "Insert number of loops: " 
 	 	.text  	 	
.globl main 
 	 	 	 
main:  	# preparation  	 	
addu $s0, $ra, $0  	 	# save $31 in $16 
 	 	 	 
 	 	# input x 
 	 	la $a0,prompt1   	 		# print string  	 	
li $v0,4   	 	 		# service 4  	 	
syscall  	 	

li $v0,5   	 	 		# read int into $v0 (x) 
 	 	syscall  	 	 	 	# service 5 
 	 	move $t3, $v0  	 	 	# move x to $t3 
 	 	 	 
 	 	# input p 
 	 	la $a0,prompt2   	 		# print string  	 	
li $v0,4   	 	 		# service 4  	 	
syscall  	 	

li $v0,5   	 	 		# read int into $v0 (p)  	 	
syscall  	 	 	 	# service 5 
 	 	move $t1, $v0  	 	 	# move p to $t1 
 	 	 	 
 	 	# prepare counter (a)  	 	
li $t0, 0 
 	 	 	 
 	 	# prepare multiplier  	 	
li $t2, -2  	 		# looping 
 	 	 	 
loop : 	bge $t0, $t1, ended 
 	 	mult $t3, $t2 
 	 	mflo $t3 
 	 	addi $t0, $t0, 1  	 	
j loop 
 
ended : 	# print result  	 	
move $a0, $t3  	 	
li $v0,1 
 	 	syscall 
 	 	 	 
 	 	# ending 
 	 	addu $ra, $0, $s0  	 	# return address back in $31 
 	 	jr $ra  	 	 	 	# return from main
this code is a code to compute the value of a using recursion and wont stop until a value is same with other value.
The question is how do i convert them to multicycle?
and what about if different code is used?

please help me
best regards
 
Last edited by a moderator:

WBahn

Joined Mar 31, 2012
33,193
Usually, single-cycle and multicycle refer to the processor architecture and not the program running on that processor.

Are you using Patterson and Hennessey? If so, which edition? If you can, get yourself a 1st or 2nd edition -- they are pretty cheap now -- as they are much better than later editions.
 
Top