SOLUTION TO HOMEWORK #1:
------------------------

1.8  Assume that every operand loads individually.  An add instuction would 
require 1 instruction fetch, 2 operand loads, 1 operand store, 1 instruction decode, one
instruction execute, and one PC update.  Assuming that none of these steps can happen
in parallel (i.e.  there is no pipelining) and that there are no immediate operands (i.e. 
operands are never encoded as part of the instruction-word), all binary arithmetic
instructions will take 10+10+10+1+1+1 = 33 time-units.

1.12  Nominally, the PC is changed to point to the next word in memory *as* the
current instruction is being decoded.  To wait until the type (i.e.  branch, arithmetic, logical) of the instruction being executed is known would in general cause instruction-
execution to take more cycles than neccessary.  Also, it might also require more
complicated chip-logic.

1.13  Upward compatibility allows new hardware to use older software (which is
good because it prevents software from becoming obsolete).  Downward 
compatibility is rarely advertised because it is not consider clever marketing to indicate to the consumers of a product that their product has become obsolete.

1.14 #instructions/s is the best performance indicator, is *better* correpsonds to 
throughput.  But if *better* corresponds to software availability for a given architecture, then the popularity of a platform might not be a bad measure of the 
relative merit of different types of machines.

2.3 
	.data
sum:	.word
i:	.word  
a:	.word

	.text
	move i, 2 
top:	bgt i, z, done
	and a, i, 1
	bnez a, else
	add sum, sum, i
else:	add i, 1, i
	b top
done:

...Since we're just writing a code-fragment here, it's not too important to initialize
sum, although it can't hurt.  It might not even neccessary to include the .data section,
and it for sure  is not importand to include the __start flag.



2.4 
  .data
a:		.word
b:		.word
c:		.word
d:		.word
i:		.word


.text
	move b,13
	move i,2
top:	bgt i, a, done
	mult c,b,i
	beqz c,else
	sub d, b, a
	rem d, d, c
else:	add i, i, 1
	b top
done:

...Same as 2.3 for initialization/declarations that would be overkill...

2.8  
	.data
sum_high:	.word		0
sum_low:	.word 		0
N:		.word		28
i:		.word		0
prompt1:	.asciiz 	"high:"
prompt2:	.asciiz		"low"
temp:		.word

	.text
__start:	
top:		beq i, N, done
		puts prompt1
		get temp
		add sum_high, sum_high, temp
		puts prompt2
		get temp
		add sum_low, sum_low, temp
		add i, i, 1
		b top
done:		div sum_low, sum_low, N
		div sum_high, sum_high, N
		put sum_high
		put sum_low

...I/O considerations aren't too important -- just make sure the user is able to enter
(from the console) temperature values that will be used in the average.

2.10   This one seems a little weird:
				Loop I executes this many lines of code:
					f(i) = 2 + 4(i) + 1

				Loop II executes this many line of code:
					f'(i) = 3 + 3(i)
				
				Where i>=0...
				
				So, if i=0, they execute the same number of instructions, but if i>0, loop II will
				always execute fewer.  If you figure out a way the the problem as state can be
				satisfied, let me know -- I'd be curious.

2.12  The main reason this code is objectionable is that A could be zero, which would
throw a divide-by-zero exception in the first line of code.

3.8  
Binary			Octal		Decimal		Hex
0010 1100  		54 44      	5444		2C
1110 1100  		354		236		EC
0000 0010 1011 0111	01267		695		02B7
0000 0011 0011		063		51		033
0101 1010		132		90		5A
0011 1111		77		63		3F
0110 0011		143		99		63
1010 1011 1111  	5277		2751		ABF	


3.9	1100		102		11
	1101 001	22001		217
	0010 0000	1012		32
	0001 1001	221		25
	0101 0010	10001		82
	0001 0000      121		16



3.10  Pick a large number (say, a couple billion):  binary it takes 32 bits to represent:
Cost = 32*1 = 32

Decimal:  Cost = 10*9 = 90

Hex:  Cost = 8*15 = 120

The trend is obviously that higher radix --> higher cost.  So binary would be best.

3.12	64.5 = 01000010 10000001 00000000 00000000
				0.025 = 00111100 11001100 11001100 11001101
				18.0625= 01000001 10010000 10000000 00000000

3.14 If B is the original, binary representation of the float...
				Assume there is a function CONV that converts a binary representation of
			in integer into its decimal representation:
				Value = (-1)*CONV(B & 0x80000000) *
                       (2^(   CONV((B&0x7f800000)>>23) - 127) * 
												CONV (B | 0x00800000)