Difference between revisions of "CSC231 Homework 2 2012"

From dftwiki3
Jump to: navigation, search
(Submission)
(Extra Credit)
Line 144: Line 144:
 
You get 1/3 extra point if you use the exact same variables as my original program!
 
You get 1/3 extra point if you use the exact same variables as my original program!
  
'' '''Note:''' I will grade using the Smith scale: A = 4 points, A- = 3.7 points, B+ = 3.3 points, etc...  1/3 point extra credit makes for A+ for the total grade on Problem 1)''
+
'' '''Note:''' I will grade using the Smith scale: A = 4 points, A- = 3.7 points, B+ = 3.3 points, etc...  1/3 point extra credit makes for A+ for the total grade on Problem 1.''
  
 
=Problem #2=
 
=Problem #2=

Revision as of 16:58, 12 September 2012

--D. Thiebaut 15:44, 12 September 2012 (EDT)


Page under construction!
UnderConstruction.jpg

This assignment can be done in pair. If you elect to work with somebody else in the class, make sure the work is done only when the two people working on the homework are together. The homework is due Wednesday 9/19/12 evening at 11:59 p.m. + 1 minute.




Problem #1

Recreate the original hw2a.asm program whose hexdump is shown below. Make sure your program is written such that once it's assembled and linked, its executable "hexdumps" the same output as the one shown below.


hexdump -C hw2a
00000000  7f 45 4c 46 01 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  02 00 03 00 01 00 00 00  80 80 04 08 34 00 00 00  |............4...|
00000020  60 03 00 00 00 00 00 00  34 00 20 00 02 00 28 00  |`.......4. ...(.|
00000030  08 00 05 00 01 00 00 00  00 00 00 00 00 80 04 08  |................|
00000040  00 80 04 08 10 01 00 00  10 01 00 00 05 00 00 00  |................|
00000050  00 10 00 00 01 00 00 00  10 01 00 00 10 91 04 08  |................|
00000060  10 91 04 08 5f 00 00 00  5f 00 00 00 06 00 00 00  |...._..._.......|
00000070  00 10 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  b8 04 00 00 00 bb 01 00  00 00 b9 10 91 04 08 ba  |................|
00000090  02 00 00 00 cd 80 b8 04  00 00 00 bb 01 00 00 00  |................|
000000a0  b9 49 91 04 08 ba 05 00  00 00 cd 80 b8 04 00 00  |.I..............|
000000b0  00 bb 01 00 00 00 b9 18  91 04 08 ba 02 00 00 00  |................|
000000c0  cd 80 b8 04 00 00 00 bb  01 00 00 00 b9 1e 91 04  |................|
000000d0  08 ba 01 00 00 00 cd 80  b8 04 00 00 00 bb 01 00  |................|
000000e0  00 00 b9 16 91 04 08 ba  0c 00 00 00 cd 80 b8 04  |................|
000000f0  00 00 00 bb 01 00 00 00  b9 53 91 04 08 ba 1c 00  |.........S......|
00000100  00 00 cd 80 bb 00 00 00  00 b8 01 00 00 00 cd 80  |................|
00000110  49 20 68 61 74 65 20 63  68 6f 63 6f 6c 61 74 65  |I hate chocolate|
00000120  2c 20 61 6e 64 20 70 72  65 66 65 72 20 61 6e 63  |, and prefer anc|
00000130  68 6f 76 69 65 73 2c 20  61 6e 64 20 49 20 65 73  |hovies, and I es|
00000140  70 65 63 69 61 6c 6c 79  20 6c 69 6b 65 20 74 68  |pecially like th|
00000150  65 6d 20 77 69 74 68 20  77 68 69 70 70 65 64 20  |em with whipped |
00000160  63 72 65 61 6d 20 6f 6e  20 74 6f 70 21 0a 0a 00  |cream on top!...|
00000170  01 00 00 00 00 00 23 00  0a 00 00 00 01 00 00 00  |......#.........|
00000180  64 00 00 00 80 80 04 08  00 00 00 00 44 00 21 00  |d...........D.!.|
00000190  80 80 04 08 00 00 00 00  44 00 22 00 85 80 04 08  |........D.".....|
000001a0  00 00 00 00 44 00 23 00  8a 80 04 08 00 00 00 00  |....D.#.........|
000001b0  44 00 24 00 8f 80 04 08  00 00 00 00 44 00 25 00  |D.$.........D.%.|
000001c0  94 80 04 08 00 00 00 00  44 00 27 00 96 80 04 08  |........D.'.....|
000001d0  00 00 00 00 44 00 28 00  9b 80 04 08 00 00 00 00  |....D.(.........|
000001e0  44 00 29 00 a0 80 04 08  00 00 00 00 44 00 2a 00  |D.).........D.*.|
000001f0  a5 80 04 08 00 00 00 00  44 00 2b 00 aa 80 04 08  |........D.+.....|
00000200  00 00 00 00 44 00 2d 00  ac 80 04 08 00 00 00 00  |....D.-.........|
00000210  44 00 2e 00 b1 80 04 08  00 00 00 00 44 00 2f 00  |D...........D./.|
00000220  b6 80 04 08 00 00 00 00  44 00 30 00 bb 80 04 08  |........D.0.....|
00000230  00 00 00 00 44 00 31 00  c0 80 04 08 00 00 00 00  |....D.1.........|
00000240  44 00 33 00 c2 80 04 08  00 00 00 00 44 00 34 00  |D.3.........D.4.|
00000250  c7 80 04 08 00 00 00 00  44 00 35 00 cc 80 04 08  |........D.5.....|
00000260  00 00 00 00 44 00 36 00  d1 80 04 08 00 00 00 00  |....D.6.........|
00000270  44 00 37 00 d6 80 04 08  00 00 00 00 44 00 3b 00  |D.7.........D.;.|
00000280  d8 80 04 08 00 00 00 00  44 00 3c 00 dd 80 04 08  |........D.<.....|
00000290  00 00 00 00 44 00 3d 00  e2 80 04 08 00 00 00 00  |....D.=.........|
000002a0  44 00 3e 00 e7 80 04 08  00 00 00 00 44 00 3f 00  |D.>.........D.?.|
000002b0  ec 80 04 08 00 00 00 00  44 00 41 00 ee 80 04 08  |........D.A.....|
000002c0  00 00 00 00 44 00 42 00  f3 80 04 08 00 00 00 00  |....D.B.........|
000002d0  44 00 43 00 f8 80 04 08  00 00 00 00 44 00 44 00  |D.C.........D.D.|
000002e0  fd 80 04 08 00 00 00 00  44 00 45 00 02 81 04 08  |........D.E.....|
000002f0  00 00 00 00 44 00 4a 00  04 81 04 08 00 00 00 00  |....D.J.........|
00000300  44 00 4b 00 09 81 04 08  00 00 00 00 44 00 4c 00  |D.K.........D.L.|
00000310  0e 81 04 08 00 00 00 00  64 00 00 00 00 00 00 00  |........d.......|
00000320  00 68 77 32 61 2e 61 73  6d 00 00 2e 73 79 6d 74  |.hw2a.asm...symt|
00000330  61 62 00 2e 73 74 72 74  61 62 00 2e 73 68 73 74  |ab..strtab..shst|
00000340  72 74 61 62 00 2e 74 65  78 74 00 2e 64 61 74 61  |rtab..text..data|
00000350  00 2e 73 74 61 62 00 2e  73 74 61 62 73 74 72 00  |..stab..stabstr.|
00000360  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000380  00 00 00 00 00 00 00 00  1b 00 00 00 01 00 00 00  |................|
00000390  06 00 00 00 80 80 04 08  80 00 00 00 90 00 00 00  |................|
000003a0  00 00 00 00 00 00 00 00  10 00 00 00 00 00 00 00  |................|
000003b0  21 00 00 00 01 00 00 00  03 00 00 00 10 91 04 08  |!...............|
000003c0  10 01 00 00 5f 00 00 00  00 00 00 00 00 00 00 00  |...._...........|
000003d0  04 00 00 00 00 00 00 00  27 00 00 00 01 00 00 00  |........'.......|
000003e0  00 00 00 00 00 00 00 00  70 01 00 00 b0 01 00 00  |........p.......|
000003f0  04 00 00 00 00 00 00 00  04 00 00 00 0c 00 00 00  |................|
00000400  2d 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |-...............|
00000410  20 03 00 00 0a 00 00 00  00 00 00 00 00 00 00 00  | ...............|
00000420  01 00 00 00 00 00 00 00  11 00 00 00 03 00 00 00  |................|
00000430  00 00 00 00 00 00 00 00  2a 03 00 00 36 00 00 00  |........*...6...|
00000440  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
00000450  01 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  |................|
00000460  a0 04 00 00 50 01 00 00  07 00 00 00 11 00 00 00  |....P...........|
00000470  04 00 00 00 10 00 00 00  09 00 00 00 03 00 00 00  |................|
00000480  00 00 00 00 00 00 00 00  f0 05 00 00 7f 00 00 00  |................|
00000490  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
000004a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000004b0  00 00 00 00 80 80 04 08  00 00 00 00 03 00 01 00  |................|
000004c0  00 00 00 00 10 91 04 08  00 00 00 00 03 00 02 00  |................|
000004d0  00 00 00 00 00 00 00 00  00 00 00 00 03 00 03 00  |................|
000004e0  00 00 00 00 00 00 00 00  00 00 00 00 03 00 04 00  |................|
000004f0  01 00 00 00 00 00 00 00  00 00 00 00 04 00 f1 ff  |................|
00000500  0a 00 00 00 10 91 04 08  01 00 00 00 01 00 02 00  |................|
00000510  0c 00 00 00 02 00 00 00  00 00 00 00 00 00 f1 ff  |................|
00000520  11 00 00 00 12 91 04 08  01 00 00 00 01 00 02 00  |................|
00000530  16 00 00 00 17 91 04 08  01 00 00 00 01 00 02 00  |................|
00000540  20 00 00 00 0b 00 00 00  01 00 00 00 01 00 f1 ff  | ...............|
00000550  29 00 00 00 2d 91 04 08  01 00 00 00 01 00 02 00  |)...-...........|
00000560  33 00 00 00 0a 00 00 00  01 00 00 00 01 00 f1 ff  |3...............|
00000570  40 00 00 00 49 91 04 08  01 00 00 00 01 00 02 00  |@...I...........|
00000580  45 00 00 00 05 00 00 00  01 00 00 00 01 00 f1 ff  |E...............|
00000590  4d 00 00 00 53 91 04 08  01 00 00 00 01 00 02 00  |M...S...........|
000005a0  55 00 00 00 1c 00 00 00  00 00 00 00 00 00 f1 ff  |U...............|
000005b0  60 00 00 00 80 80 04 08  00 00 00 00 10 00 01 00  |`...............|
000005c0  67 00 00 00 6f 91 04 08  00 00 00 00 10 00 f1 ff  |g...o...........|
000005d0  73 00 00 00 6f 91 04 08  00 00 00 00 10 00 f1 ff  |s...o...........|
000005e0  7a 00 00 00 70 91 04 08  00 00 00 00 10 00 f1 ff  |z...p...........|
000005f0  00 68 77 32 61 2e 61 73  6d 00 49 00 49 6c 65 6e  |.hw2a.asm.I.Ilen|
00000600  00 68 61 74 65 00 63 68  6f 63 6f 6c 61 74 65 00  |.hate.chocolate.|
00000610  63 68 6f 63 6f 4c 65 6e  00 61 6e 63 68 6f 76 69  |chocoLen.anchovi|
00000620  65 73 00 61 6e 63 68 6f  76 69 65 73 4c 65 6e 00  |es.anchoviesLen.|
00000630  6c 69 6b 65 00 6c 69 6b  65 4c 65 6e 00 77 68 69  |like.likeLen.whi|
00000640  70 70 65 64 00 77 68 69  70 70 65 64 4c 65 6e 00  |pped.whippedLen.|
00000650  5f 73 74 61 72 74 00 5f  5f 62 73 73 5f 73 74 61  |_start.__bss_sta|
00000660  72 74 00 5f 65 64 61 74  61 00 5f 65 6e 64 00     |rt._edata._end.|
0000066f

  • Call your program hw2a.asm.
  • Make sure you document it. Its header should contain:
    • Your name or names
    • Your account number or numbers (231a-xx)
    • The date
    • A copy of the output of your program
    • How to assemble, link, and run your program
  • Document your code. Use the examples seen so far in class as example of good documentation. I will not take off points this assignment for bad documentation, but will give you feedback. As we progress this semester, I will post solutions for the assignments, and these will be edited by me to reflect good documentation practices.

Submission

Submit your program from your account on beowulf (or directly from one of the Fedora machines in FH342) as follows:

 rsubmit hw2 hw2a.asm

Extra Credit

You get 1/3 extra point if you use the exact same variables as my original program!

Note: I will grade using the Smith scale: A = 4 points, A- = 3.7 points, B+ = 3.3 points, etc... 1/3 point extra credit makes for A+ for the total grade on Problem 1.

Problem #2

Write an assembly language program that outputs this:

 [231a@beowulf ~/temp]$ ./hw2b
 *********************
 *********************
 *********************
 *********************
 *********************
 *********************
 [231a@beowulf ~/temp]$ 

The output consists of 6 lines of stars.

Requirements

Make the size of your executable as small as possible! In other words, figure out a way to make the strings in your data section small, and the number of time you print small as well, so that the total size of your executable is as small as possible.

You must use these two commands to create your executable:

nasm -f elf -F stabs hw2b.asm
ld -melf_i386 -o hw2b hw2b.o

Submission

rsubmit hw2 hw2b.asm

Problem #3