Thread: loop problem!
View Single Post
Old Sep 27th, 2006, 6:23 PM   #5
sackarias
Programmer
 
sackarias's Avatar
 
Join Date: Jan 2006
Posts: 58
Rep Power: 3 sackarias is on a distinguished road
Not at all..
main:
	save %sp, -64, %sp

	loop:	
		!printf(prompt)
		sethi %hi(prompt), %o1
		call printf, 0
		or %o1, %lo(prompt), %o0

		!scanf(formati, %x, %y)
		set formati, %o0
		set x, %o1
		set y, %o2
		call scanf, 0
		nop
                		

                !basically, branch not equals, so you want to be done
                !otherwise, it will run through the code, hitting the end
                !and going right back to 'loop' 


		!while(scanf(formati, %x, %y) == 2)
		cmp %o0,2
		bne done 
		nop

                !code was here
                
		!printf(formato, %o1, %o2, %o3)
		sethi %hi(formato), %l1 
		call printf,0
		or %l1, %lo(formato), %o0	

	ba loop
	nop
done:
	call exit, 0
	mov 0, %o0

Last edited by big_k105; Sep 27th, 2006 at 6:52 PM. Reason: Added Code Tags
sackarias is offline   Reply With Quote