!************************* * * 
!************************* * * 
!* Apostolos Pantazis.	 * * * 
!* maximus@cs.unm.edu    * * * 
!* CS 341 Spring 2002.   * * * 
!* Dr Barak P.	         * * * 
!* TA: Leigh McGlinchey. * * * 
!* File: prog1.s         * * * 
!* Created on: 2/11/02.  * * * 
!* Updated on: 2/11/02.	 * * * 
!************************* * * 
!Program Description:    * * * 
!To Implement:           * * *  
![(x^4)/y] - (63*y)+(y/2)* * * 
!************************* * * 
!************************* * * 
 
 
 
	.data 
 
x:	.word 0x1f			!sample value for x 
y: 	.word 0x11			!sample value for y 
z:	.word 0x00			!store result for z 
part1:  .word 0x00			!store formual part_1 
part2:	.word 0x00			!store formual part_2 
part3:  .word 0x00	                !store formula part_3 
const1:	.word 0x3f			!store const 63 in Hex 
const2: .word 0x02			!store const 2 in Hex 
 
	.text				!instructions 
 
start: 
	set	x, %r1			!&x-->%r1 
	ld 	[%r1], %r1		!x --> %r1 
	set	y, %r2			!&y-->%r2 
	ld	[%r2], %r2		!y -->%r2 
	set	z, %r3			!&z-->%r3 
	ld	[%r3], %r3		!z -->%r3 
	set	part1, %r4		!&p1-->%r4 
	ld	[%r4], %r4		!p1 -->%r4 
	set     part2, %r5		!&p2-->%r5 
	ld	[%r5], %r5		!p2 -->%r5 
	set	part3, %r6		!&p3-->%r6 
        ld	[%r6], %r6		!p3 -->%r6 
	set 	const1, %r7		!&c1-->%r7 
	ld	[%r7], %r7		!c1 -->%r7 
 	set	const2, %r8		!&c2-->%r8 
	ld	[%r8] ,%r8		!c2 -->%r8 
 
 
	smul	%r1, %r1, %r4		!%r1 * %r1 --> %r4 (x^2) 
	smul	%r4, %r4, %r4		!%r4 * %r4 --> %r4 (x^4)	 
	umul	%r0, %r0, %r0		!Clear the Y register 
	sdiv	%r4, %r2, %r4		!%r4 / %r2 --> %r4 [(x^4)/y] 
	smul	%r7, %r2, %r5		!%r7 * %r2 --> %r5 (63 * y) 
	sub	%r4, %r5, %r3		!%r4 - %r5 --> %r3 [(x^4)/y]-(63*y) 
	umul	%r0, %r0, %r0		!Clear the Y register 
	sdiv	%r2, %r8, %r6		!%r2 / %r8 --> %r6 (y/2) 
	add	%r3, %r6, %r3		!%r3 + %r6 --> %r3 [(x^4)/y]-(63*y)+(y/2) 
  
		 
end:	ta	 0 			!The end..



! * This is a sample of how I write programs.
! * There might be Errors in this code since I wrote it in a rush.
! * It will for sure assemble.
! * Generally my algorithm (Brief description) would be included
! * In the comments, this is a simple enought program so I did 
! * not worry about it that much.
! * For use by Cs 341 Professor/TA/Students.
! * Cut/Paste this code and play with it if you wish...