Difference between revisions of "CSC231 Homework 11 2012"

From dftwiki3
Jump to: navigation, search
(Optional and Extra-Credits)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] 13:14, 28 November 2012 (EST)
 
--[[User:Thiebaut|D. Thiebaut]] 13:14, 28 November 2012 (EST)
 
----
 
----
<center>
+
<!--center>
 
<font size="+2">Page under construction!</font>
 
<font size="+2">Page under construction!</font>
 
<br \>[[File:UnderConstruction.jpg|300px]]
 
<br \>[[File:UnderConstruction.jpg|300px]]
</center>
+
</center-->
  
=Problem #1=
+
<br />
 +
<bluebox>This assignment is '''required'''.  It is not optional (the next one will).  It is due at midnight the evening of 12/5/12.  You can work on this assignment in groups of at most 2 people.</bluebox>
 +
<br />
 +
<br />
 +
 
 +
=Problem #1 (2 points)=
  
 
This is a continuation of the  first problem of [[CSC231_Homework_8_Fall_2012 | Homework 8]].  Here you need to complete the output of the '''dumpRegs''' function so that it outputs all the registers in decimal, both in unsigned and in signed format.
 
This is a continuation of the  first problem of [[CSC231_Homework_8_Fall_2012 | Homework 8]].  Here you need to complete the output of the '''dumpRegs''' function so that it outputs all the registers in decimal, both in unsigned and in signed format.
  
Here's an example of the output of your program showing how to shows the contents of each register in hexadecimal, as an unsigned it, and as a signed int.
+
Here's an example of the output of your program showing how to show the contents of each register in hexadecimal, as an unsigned it, and as a signed int.
  
 
  -------------------------------------
 
  -------------------------------------
 
  eax = 0x00000004  4 4
 
  eax = 0x00000004  4 4
 
  ebx = 0x00000001  1 1
 
  ebx = 0x00000001  1 1
  ecx = 0xFFFFFFFF  4294966272 -1
+
  ecx = 0xFFFFFFFF  4294967295 -1
 
  edx = 0x000012FC  4860 4860
 
  edx = 0x000012FC  4860 4860
 
  edi = 0xFFFFFFFE  4294966271 -2  
 
  edi = 0xFFFFFFFE  4294966271 -2  
Line 22: Line 27:
  
 
==Requirements==
 
==Requirements==
* You need to store your dumpRegs function and all its accompanying functions in a separate file called '''dumpRegs.ing'''
+
* Figure out how to print negative integers. 
 +
* In the header of the program you will submit, indicate how much stack space is used as a function of the number you are printing.  Express your answer as precisely as possible, and in '''bytes'''.
 +
* You need to store your dumpRegs function and all its accompanying functions in a separate file called '''dumpRegs.inc'''
 
* Your '''printDecimal''' function must be recursive.  The [[CSC231_printInt.asm|one we saw in class ]] isn't.
 
* Your '''printDecimal''' function must be recursive.  The [[CSC231_printInt.asm|one we saw in class ]] isn't.
* Your main program, called '''hw11a.asm''' will be exactly as follows:
+
* Your main program (you won't be submitting it) will look something like this (notice that I am using numbers that are positive and negative in 2's complement format):
  
 
<br />
 
<br />
Line 65: Line 72:
 
*'''0.6 extra points''': same requirement as above, except that the '''printDecimal''' unction has to be recursive.
 
*'''0.6 extra points''': same requirement as above, except that the '''printDecimal''' unction has to be recursive.
  
=Problem #2=
+
==Submission==
 +
 
 +
Submit only dumpRegs.inc.  I will provide my own main program that will use just this line to include your program:
 +
 
 +
%include "dumpRegs.inc"
 +
 
 +
The submit command is:
 +
 
 +
  rsubmit hw11 dumpRegs.inc
 +
 
 +
=Problem #2 (2 points)=
 +
What is the maximum amount of stack space (in bytes) required by the [[CSC231_Homework_10_2012#Problem_.232:_Optional_and_Extra_Credits_.280.6_points.29 | program of Problem 2 of Homework 10]], when computing the ''N''th term of the Fibonacci series?
 +
 
 +
Store your answer in a text file called hw11b.txt and submit it as follows:
 +
 
 +
rsubmit hw11 hw11b.txt
 +
 
  
 
<br />
 
<br />

Latest revision as of 16:03, 1 December 2012

--D. Thiebaut 13:14, 28 November 2012 (EST)



This assignment is required. It is not optional (the next one will). It is due at midnight the evening of 12/5/12. You can work on this assignment in groups of at most 2 people.



Problem #1 (2 points)

This is a continuation of the first problem of Homework 8. Here you need to complete the output of the dumpRegs function so that it outputs all the registers in decimal, both in unsigned and in signed format.

Here's an example of the output of your program showing how to show the contents of each register in hexadecimal, as an unsigned it, and as a signed int.

-------------------------------------
eax = 0x00000004  4 4
ebx = 0x00000001  1 1
ecx = 0xFFFFFFFF  4294967295 -1
edx = 0x000012FC  4860 4860
edi = 0xFFFFFFFE  4294966271 -2 
esi = 0x12235557  304305495 304305495
-------------------------------------

Requirements

  • Figure out how to print negative integers.
  • In the header of the program you will submit, indicate how much stack space is used as a function of the number you are printing. Express your answer as precisely as possible, and in bytes.
  • You need to store your dumpRegs function and all its accompanying functions in a separate file called dumpRegs.inc
  • Your printDecimal function must be recursive. The one we saw in class isn't.
  • Your main program (you won't be submitting it) will look something like this (notice that I am using numbers that are positive and negative in 2's complement format):


;;; your header

%include "dumpRegs.inc"

		section	.data
;;; your data

		section	.text
		global	_start
 
_start:
 
;;; Initialize the registers
		mov	eax, 0x12345678
		mov	ebx, 0x55FF55FF
		mov	ecx, 0xFEDCBA98
		mov	edx, 0x00000000
		mov	esi, 0xFFFFFFFF
		mov	edi, 0xFFFFFFF0
 
;;; dump them twice to verify that no registers gets modified...
	        call    dumpRegs
		call	dumpRegs
 
 
;;; exit back to OS
		mov	ebx, 0
		mov	eax, 1
		int	0x80


Optional and Extra-Credits

  • 0.3 extra points: make your print decimal function output the decimal with commas separating each group of 3 digits. For example, it will display 123456789 as 123,456,789. Similarly, it will display -25668 as -25,668, and -34 as -34. For this version of the program, the printDecimal function does not need to be recursive.
  • 0.6 extra points: same requirement as above, except that the printDecimal unction has to be recursive.

Submission

Submit only dumpRegs.inc. I will provide my own main program that will use just this line to include your program:

%include "dumpRegs.inc"

The submit command is:

 rsubmit hw11 dumpRegs.inc

Problem #2 (2 points)

What is the maximum amount of stack space (in bytes) required by the program of Problem 2 of Homework 10, when computing the Nth term of the Fibonacci series?

Store your answer in a text file called hw11b.txt and submit it as follows:

rsubmit hw11 hw11b.txt