![]() |
HomeworkHomework can either be printed out and turned in to me in class, or emailed to me (ztomasze@hawaii.edu). You may either attach the necessary files or paste them into the email itself. Please do not zip your files. You should send me both your code and example output for a couple test cases (as appropriate). Each complete, on-time homework is worth 10 points. Partially incomplete or incorrect homeworks may receive a 5. Homework may be turned in up to 1 week past the due date at one point off. Homeworks are not otherwise graded, though you must complete them in order to pass the course. Projects are properly graded. Note that projects have a different late policy. Projects are deducted 10% for each class meeting they are late. Thus, if a project is due Tuesday, you will be deducted 10% the following Thursday, 20% (total) the following Tuesday, and so on. You still have until midnight to submit it on whatever day it's due. 12 May (11:59pm) -- Final cut-off for submission of all lost/missing work.PROJECT #5 (Due: 12 May - extended)Write a compiler that translates the "airplane" language into assembly code. Tip: Be sure to check out the sample compiler. If you have trouble with the links to the lex and yacc files, they are at lexair.txt and air.txt.
Hint: To code the Extra Credit Project (optional) (Due: 12 May - extended)Write an airplane arcade game. FINAL EXAM: Tues, 09 May. Noon to 2pm.HW #25 (Due: 02 May)
Supply in hex the machine code for:
Solution: a) 001010 11 11 010 011 => 2BD3h b) 000100 11 00 001 110 00111011 00101010 => 130E 3B2Ah HW #24 (Due: 02 May)
Minimize the states in the following DFA: Solution: a,b,d,e,f,g,h c On 0: / \ | a,b,e,g,h d,f c On 1: / | \ | | g a,e b,h d,f c On 0 and 1 again: no change. ![]() HW #23 (Due: 27 Apr)
Provide NFAs mechanically constructed (that is, combine the 7 basic building blocks given in Set27 slides) for:
3.) Construct DFAs for 1 & 2 above. Solution: here. HW #22 (Due: 27 Apr)Write a floating-point calculator interpreter. Please include some sample output when you submit. (I recommend using the string given on the homework page to test the calculator!) Hint: I recommend starting with the framework given for a calculator that handles only integers and addition.
Tip: Blank lines in the lex rule section should be completely blank--no spaces, tabs, or similar white space. If your lex file gets turned into yy.lex.c okay, but then you get a bunch of odd Tip: Watch out for macros and how they get expanded. Remember that macros are only glorified cut-and-pastes. If you have this macro: M [eE][0-9] and use it in a expression like this: ...{M}? it will get expanded like this: ...[eE][0-9]? Note how only the last element of the M macro becomes optional. (This is a common evil of macros--it's hard to see the code that is going to reach the compiler just by looking at the macro invocation.) A fix for the M macro here would be: M ([eE][0-9]) This doesn't mean you should go crazy with the parentheses. It just means you should give a little thought whenever you use a macro as to what your code will look like when the macro is expanded. (Again, this not always an easy thing to do!) Solution: calc.l, calc.y, and hw22output.txt HW #21 (Due: 20 Apr)
Supply a regular expression for strings of the alphabet {0,1} for the language of all strings: Solution: hw21.txt HW #20 (Due: 20 Apr)Counting vowel-consonant pairs. Send me the output of both counter.l and of your vowel-consonant counter. Hint: Remember, if you don't have a rule for a certain character, lex just prints it to the screen. This is why it was noted in class you often have a rule for "\n" and ".".
Tip: I don't mind if you do this assignment on uhunix. I don't know if there will be important differences in later homeworks between the PC and unix versions. (If I discover any, I'll let you know.) We might later be using flex and bison, which can be found on uhunix in Solution: hw20.l and hw20output.txt HW #19 (Due: 18 Apr)Grammar homework -- 6 problems. Tip: For problem #3, the grammar should literally produce all the possible even integers (positive only, if you want). It should not produce math formulas that evaluate to even integers. Solution: hw19.txt HW #18 (Due: 13 Apr)Solution: hw18.txt HW #17 (Due: 11 Apr)1.) Show the derivation and syntax tree for "the man pushed the poor boy", based on the grammar given in the beginning of the Set24 slides. 2.) Can you derive "the man pushed the poor pretty cat" from the grammar? (Show/explain why or why not.) Solution: hw17.txt PROJECT #4 (minor) (Due: 04 Apr)
Play a tune. Write a program that uses 23 Mar: Midterm ExamPROJECT #3 (minor) (Due: 21 Mar)
Euler's Extended Algorithm: Write a program to evaluate the recursive function HW #16 (Due: 14 Mar)Intro to Masm32. Write the two programs described. Send me your source code and screenshots of your two windows. (Examples with different window titles below.) (Screenshot directions were given in HW14.) Tip: If you have trouble opening the .chm file (as in it opens, but none of the pages can be found), download the file to your desktop. Right-click it and go to Properties. Click the Unblock button and hit OK.
Examples/Solution: hw16first.png and hw16window.png. PROJECT #2 (Due: 14 Mar)Draw a plane that moves with the mouse, as described. 10 Mar: Last day for restricted withdrawals (with "W" grade)HW #15 (Due: 09 Mar - extended) -- OPTIONALWrite a TSR that hijacks the function keys. Since it's a little hard to demonstrate the output for this one, just tell me how much you got to work. How far in this progression did you get?
Help: TSR Walk-thru
Tip: Don't " Solution: hw15.asm PROJECT #1 (Due: 28 Feb)Draw a house, as described. It seems you cannot take screen captures of DOS graphics mode, so no capture is required of your code. Just send me the source code. Tip: When you run in graphics mode (13h), your command window usually goes to full screen. Switching back to text mode (03h) at the end of your program will make sure you get a readable command prompt back when your program quits. If your command window is still fullscreen, Alt + Enter will restore it to window-size, Alt + Tab will let you switch to a different application window, and just typing "exit" will let you quit. Tip: You cannot have duplicate labels in your program. If you expand a macro with a label in it (such as when your macro contains a loop), you will get an error like this: Assembling: proj1.asm proj1.asm(25) : error A2005: symbol redefinition : v_again vert(4): Macro Called From proj1.asm(25): Main Line Code
To avoid this, declare your label LOCAL at the beginning of your macro with the line Tip: In graphics mode 13h, pixel colors are specified according to a palette. Although it is possible to display 64^3 (ie, 2^18) different colors in this mode, only 256 (2^8) different colors can be on the screen at one time. It is possible to change what colors are in the palette, but the details of doing so are beyond this course. However, for your projects, it might be handy to know what colors are available. The first 16 colors are the same as they are in text mode. In other words, the lower 3 bits (bits 2,1,0) correspond to RGB and bit 3 determines intensity. Setting bit 4 gives you a 16-color greyscale. Beyond that, the indexing doesn't make much sense, and there are some duplicate colors. To see all the colors available in the default palette (given in order, so you can figure out what the corresponding value would be), you can run palette.asm HW #14 (Due: 16 Feb)Video Text. Draw the described red-on-black square in text mode (03h). Hints:
Screen shot:You can't "Mark" and cut+paste from the graphical text mode. Instead, you'll have to take a screen capture in order to send me your output. To do this:
Solution: hw14.asm and hw14output.png HW #13 (Due: 14 Feb)Floating Point. Compute the volume of a sphere as described. Solution: hw13.asm and hw13output.txt. HW #12 (Due: 14 Feb)File I/O. Print a file to the screen as described. Solution: hw12.asm and hw12output.txt. HW #11 (Due: 09 Feb)Macros. Again, includes two parts: exercises (A) and a program (B).
Solution: HW #10 (Due: 09 Feb)String processing instructions. Includes two parts: exercises (A) and a program (B). You may change/customize the contents of your SHOUT variable if you like.
Solution: HW #9 (Due: 07 Feb)Passing arguments via the stack. 2 programs, as specified. The subroutines do not need to be external (in separate files) from their calling functions. Solution: hw9.asm, hw9b.asm, and hw9output.txt. HW #8 (Due: 02 Feb)Adding up a variable number of numbers.
Solution: As above, but with some error-checking: hw8extra.asm and hw8extra-output.txt Exercise (Finish by: 31 Jan)
Explore the You do not need to submit anything for this exercise. (But still do it! It really will make your life easier later knowing how to use this.) Solution: None. HW #7 (Due: 31 Jan)
Write 2 programs to evaluate "X + Y - Z". Each program should employ an external subroutine. The first program should pass arguments through registers; the second should pass arguments via PUBLIC/EXTRN declarations.
Solution: HW #6 (Due: 26 Jan)
Exercise 9.2 (p.233-234), nos. 1 & 2. Omit questions involving ROL, ROR. You do not need to write/type out the question again. You can just give me the solutions in the same order of as the blanks--12 answers for 1 (after omitting), 7 answers for 2. Solution: See Answers at the back of the book, p631-633. HW #5 (Due: 26 Jan)
Write a program to read in a string of characters up to 20 bytes long using function 0Ah and then print it out using function 09h. Give me both the code and the output for a couple test runs. Solution:hw5.asm and hw5output.txt. HW #4 (Due: 24 Jan)
Exercise 5.1 (p.109), nos. 1 - 4 Solution: hw4.txt HW #3 (Due: 24 Jan)All 3 Example problems from the Set7:Flags lecture slides. (If you are using the Notes, 1d should be "NEG AL", not "NEG AX".) Solution: hw3.txt HW #2 (Due: 19 Jan)Exercises 10.2 (p. 269), Problems 1 & 2 Solution: 1) See Answers at the back of the book, p.637. 2.a) Sums all the values in WArray into AX b) Sets AX to the largest value in WArray c) Sets WArray to contain 1, 2, 3, 4, 5, 6 d) Finds the first occurrence of any digit in CArray. (BX will contain the offset/index within CArray of the first digit.) HW #1 (Due: 19 Jan)Write a program to read a character from the keyboard and display it at the beginning of the next line. (Use a question mark as a prompt, use Dos function 02h to read a single character, and save the character in another register.)
Solution: |
~ztomasze Index :
TA Details : ICS312 : Homework http://www2.hawaii.edu/~ztomasze |
Last Edited: 15 May 2006 ©2006 by Z. Tomaszewski. |