$39
Purpose:
Points:
Become more familiar with data representation, program control instructions, procedure handling, stacks, and operating system interaction. 175
Assignment:
Write an assembly language program to repeatedly plot a circle. Each time the circle is redraw it will be deformed which will appear in a cycling pattern. The program should read the draw speed, draw color, and background color from the command line. For example:
ed-vm% ./circles -sp 1 -dc 360178b -bk 0
The required format for the options is: "-sp <tridecimalNum>", "-dc <tridecimalNum>", and "-bk <tridecimalNum>". The
program must verify the format, read the arguments, and ensure the arguments are valid. The provided main program calls the following routines:
The sStep is the draw speed value read from the command line divided by 10,000.0.
All functions must follow the standard calling convention as discussed in class. The functions for the command line arguments and drawing functions must be in a separate assembly source file from the provided main program. The provided C++ main program should be linked with the assembly language functions. Only the functions file will be submitted. As such, the provided main file can not be altered in any way.
Submission:
Program Header Block
All source files must include your name, section number, assignment, NSHE number, and program description. The required format is as follows:
Failure to include your name in this format will result in a loss of up to 10%.
Scoring Rubric
Scoring will include functionality, code quality, and documentation. Below is a summary of the scoring rubric for this assignment.
Debugging -> Command Line Arguments
When debugging a program that uses command line arguments, the command line arguments must be entered after the debugger has been started. The debugger is started normally (ddd <program>) and once the debugger comes up, the initial breakpoint can be set. Then, when you are ready to run the program, you must enter the command line arguments. This can be done either from the menu (Propgram -> Run which will display a window for the arguments) or in the GDB Console Window (at bottom) by typing run <commandLineArguments> at the (gdb) prompt.
Example Executions (with errors):
Below are some sample executions showing the error handling.
ed-vm% ./circles
Usage: circles -sp <triDecimalNum> -dc <triDecimalNum> -bk <triDecimalNum> ed-vm%
ed-vm%
ed-vm% ./circles -s 3 -dc 360178b -bk 0 Error, speed specifier incorrect. ed-vm%
ed-vm%
ed-vm% ./circles -sp 7 -dc 360178b -bk 0
Error, speed value must be between 1 and 4344(6).
ed-vm%
ed-vm%
ed-vm% ./circles -sp 5 dc 360178b -bk 0 Error, draw color specifier incorrect. ed-vm%
ed-vm%
ed-vm% ./circles -sp 15 -dc 360178b -bk 360178b Error, draw color and background color canbe the same. ed-vm%
ed-vm%
ed-vm% ./circles -sp 3 -dc 451354104520 -bk 0
Error, draw color value must be between 0 and 1355332143(6). ed-vm%
ed-vm%
ed-vm% ./circles -sp 3 -dc 360178b -bkk 0 Error, background color specifier incorrect. ed-vm%
ed-vm%
ed-vm% ./circles -sp 13 -dc 360178b -bk gray
Error, background color value must be between 0 and 1355332143(6). ed-vm%
Open GL Plotting Functions:
In order to plot points with openGl, a series of calls is required. First, the draw color must be set, the point plot mode must be turned on. Then, the points can be plotted in a loop. Once all the points hve been plotted, the plot mode can be ended and the points dispalyed.
The following are the sequence of calls required:
glColor3ub(r,g,b) ;
glBegin(GL_POINTS);
glEnd ();
glFlush ();
glutPostRedisplay();
The calls must be performed at assembly level with the appropriate argument transmission. For example, to set a draw color of red, glColor3ub (255, 0, 0), and set point plot mode, glBegin(GL_POINTS), the code would be as follows:
mov
mov
mov
call
rdi, 255
rsi, 0
rdx, 0
glColor3ub
mov
call
rdi, GL_POINTS
glBegin
Assuming the variables x and y are delcared as quad words and set to valid floating points values, the call to glVertex2d(x,y) would be as follows:
This call would be iterated in a plot loop (unless a single point is to be plotted).
The calls for glEnd(), glFlush(), and glutPostRedisplay() are as follows:
call glEnd
call glFlush
call glutPostRedisplay
These function calls should not be included in the loop.
OpenGL Errors
Note, some VM's may generate error, similar to the below, which can be ignored:
libGL error: pci id for fd 4: 80ee:beef, driver (null)
OpenGL Warning: Failed to connect to host. Make sure 3D acceleration is enabled for this VM.
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
Example Execution:
Below is a example execution showing the displayed output. The pattern will cycle and several static images of the cycling pattern are shown for reference.
ed-vm% ./circles -sp 1 -dc 360178b -bk 0