
CS301, Fall 2004


Assignment #4: 10 Points.

Due Date: Monday, 10/11/04.


(2)  1.	Compile the C source file code.c on pg 130 of the text using
	a gcc compiler to obtain the assembly code file code.s.  Compare
	the contents of code.s with the code on the bottom of pg 130.
	Explain any differences.**

(4)  2.	In each of the following instructions, indicate the result. Assume 
	BYTE1 is a memory location containing 0x5f: 
 
	    Instruction      Before            After

	 a) movw $0x25,%cx ; %cx = 0x0000      %cx = 
	 b) movb $0,%cl    ; %cx = 0xffff      %cx =
	 c) movb BYTE1,%dh ; %dx = 0xbeef      %dx =
	 d) xorl %eax,%eax ; %eax = 0x12345678 %eax = 

(1)  3.	In what significant way do the following instructions differ in 
	execution?

		movl $0x1234ABCD,%eax
		movl $0x1234ABCD,(%eax) 

(3)  4.	Problem 3.31.  Test your solution by compiling your C code with 
	the -S switch to obtain gcc assembly code.  Explain any differences
	from the assembly code given in the problem.**


      **For full credit, turn in a well commented program listing,
	including your name and the problem number, and the results
	of the computer run for this problem.

