Log   |   Assignments   |   Source   |   Discussion   |   Feedback   |   About Me  |

This page tracks the assignments given and the status

Status Tracker
Assignment Self-imposed Deadline
Assignment 1 2011-02-16   2011-02-23   2011-03-02  
Assignment 2 2011-02-16   2011-02-23   2011-03-02  

2011-03-02

Assignment 3
  1. Become familiar with the DEBUG program under DOS and run 8086 assembly language programs using DEBUG. Similarly, use the Motorola 68000 simulator (68asmsim) to run assembly language programs.
  2. Write assembly language programs for both 8086 and M68k for drawing a straight line on the screen using the Bresenham's algorithm. Compare the performance of the algorithm on both platforms.
  3. Port the M68k simulator to run under Linux.

2011-02-22

The fifth version of the Quadratic Equation Solver (v0.5) is uploaded.

Enhancements in this version:
  • ncurses UI added
This is still buggy and needs a lot of work. The source is available here


2011-02-15

The third version of the HTML Entity Search program (v0.3) is uploaded.

Enhancements in this version:
  • Fixed missing entity bugs. It was a very interesting problem. My test HTML file contained a unicode character (ΓΏ), which C somehow identified as the EOF character and stopped processing my file! In the process of trying to locate the issue, I even rewrote the program without using regular expressions!
  • Valid and invalid entities written to separate files. Reason for rejection is also included along with the invalid entities.
I will be showing this in tomorrow's lab session. The source is available here.


2011-02-09

The third version of the HTML Entity Search program (v0.2) is uploaded.
Enhancements in this version:
  • Reports valid and invalid entity matches by searching a hash table.
Some bugs still seem to be present which results in some entities being missed. The source is available here.

2011-02-08

The fourth revision of the Quadratic Equation Solver (v0.3) is uploaded.
Enhancements in this version:
  • Accepts spaces between sign and number.
  • Tells user the number of guaranteed digits of precision.
The issues listed on 2011-02-01 are still present. The source is available here.

The second version of the HTML Entity Search program (v0.1) is uploaded.
Enhancements in this version:
  • Matches entities with a carriage return after the &.
  • Added some logic to handle entities which occur at the 100-character border
The code is still buggy and I have confirmed that it misses some entities. I'm debugging it presently. Also, the program still matches any string that fits the pattern. I've thought about the hash table design but not yet started coding. The source is available here.

2011-02-02

The first version of the HTML Entity Search program (v0.0) is uploaded here.

2011-02-01

The third revision of the Quadratic Equation Solver (v0.2) is uploaded.

Enhancements in this version:
  • Generates non-zero roots for equations with b*b much greater than 4*a*c.
  • Better user input validation (Character by character input and immediate error reporting).

The following issues are still present:
  • In case the user enters an invalid data, there is no provision for correcting the error alone. That is, user has to enter the whole number again.
  • There are still minor issues with input handling (Do you want to continue? prompt is skipped). It is not repeatable and I think it's because of multiple key-presses rather than junk in stdin.
  • Float number validation still has loop holes.
  • The code is not very clean.

The source is available here.

Write a program which asks the user for an input file (text format) and find out the total number of HTML entities in the file and print each one.

I haven't started writing the program yet. The code will be uploaded as soon as it is completed.

2011-01-30

The Quadratic Equation Solver that I wrote failed to handle the following inputs given by the professor:
  • Value of b*b much greater than 4*a*c results in one root computed as 0.0.
  • Input containing alphabets are rejected totally and user has to re-enter the whole value again.
  • Error message is reported only after entering all three coefficients, instead of immediately after entering.
I have started re-writing the program for handling such input conditions and values. It is not complete yet, but I hope to upload a new version by tomorrow morning.

Edit 1 (22:40): I'm having trouble dealing with getchar and leftover characters in stdin and can't seem to work around the issue. I don't think I'll be able to get a working piece of code by tomorrow morning.

2011-01-18

Quadratic Equation Solver - Rewrite - Now the function for returns a single atomic value and not a pointer / structure

During the discussions in class on 2011-01-18, we were told that we are not allowed to return a pointer from the function which computes the roots. I have rewritten the program so that the function returns a single atomic value. However, I couldn't think of any graceful way of passing back two roots using a single variable. Since we were told not to use pointers, I assumed that we are not allowed to pass the result variables by reference to the function, as parameters. After ruling that out, there was only one option I could think about - Find out a data type large enough to hold two float numbers and flag (Information which was originally in the structure) and pack everything into that variable and return it. An unsigned integer of size at least equal to 66 bits could have been ideal (2*32 bits for storing float values -b/2a and sqrt(determinant)/2a and two bits for indicating nature of the solution - real / imaginary / linear / invalid equation).
However, I was not able to find any integer data type of size greater than 64 bytes (Largest available was long long, which is 64 bits wide).
So, I took a long double variable (96 bits wide) and packed the required information into it using a series of questionable pointer operations. So now, the function returns a single long double value, which holds -b/2a, sqrt (determinant)/2a and the flag denoting nature of the solution. The function which prints the result now extracts the actual values through another set of pointer operations.
I am sure this is not what the professor had in mind, but I can't think of anything else!
The updated source is available here.

2011-01-05

Write a C program which asks the user for three variables a,b,c which are coefficients of a quadratic equation and calculate the roots of the equation. Use a function to calculate the roots and the function should return the roots.

I wrote the program so that it returns a pointer to a structure holding the roots of the equation. The structure itself contains five variables - two floats for each root (real and imaginary) and one unsigned char for denoting the type of solution (roots real, roots imaginary, equation is linear, equation is invalid). The inputs are considered valid if the value entered contains:
  • Digits (and/or)
  • Decimal point (and/or)
  • + or - sign
This validation is by no means complete and it will not catch invalid inputs like 100.0.0.1. Also, after the discussions on 2011-01-07, I realized that valid entries like 10,00,000 will be rejected by my program. Also, I have not yet handled inputs of length larger than the allocated space and such inputs may crash the program. These issues are not yet addressed. The current source can be accessed here.

2011-01-04

Find out the maximum file size supported by the Notepad editor under Windows and vi editor under GNU/Linux.

I took a large text file (report generated by the dmesg utility) and copied it into itself till the editor was not able to handle the file gracefully. I found that Notepad could not handle files larger than 64MB whereas vi could open much larger files. As the file size became larger (around 550 MB), vi started slowing down. It could still open the file, but it was slow and practically unusable.